Azure ruby sdk storage account create params, no method allow_blob_public_access - ruby

While doing a create on storage_accounts
I get:
NoMethodError: undefined method allow_blob_public_access= for #Azure::Storage::Mgmt::V2019_06_01::Models::StorageAccountCreateParameter
This is the link to the StorageAccountCreateParameter on microsofts github.
My code looks like this:
sa_create_params = StorageModels::StorageAccountCreateParameters.new.tap do |sacp|
sacp.kind = 'StorageV2'
sacp.kind = payload['StorageAccountType'] if payload && payload['StorageAccountType']
sacp.sku = sku
sacp.location = params['region']
sacp.access_tier = 'hot'
sacp.access_tier = payload['AccessTier'] if payload && payload['AccessTier']
sacp.tags = system_tags(params)
sacp.allow_blob_public_access = false
end
Without the last line, regarding public access, it works just fine. I've tried upversioning the gems (hence the current version). And looking at their github it looks pretty self-explanatory. I'm at a loss, all help is much appreciated.
I'm using the following gems:
ms_rest_azure 0.11.0
azure_mgmt_storage 0.21.0
Update: it seems the name should be sacp.properties.allow_blob_public_acces as per link.
But this also throws a NoMethodError

I updated all azure gems to the latest version.
Relevant gems:
spec.add_dependency 'ms_rest_azure', '~> 0.12.0'
Spec.add_dependency 'azure_mgmt_storage', '~> 0.22.0'
This did the trick

Related

Specific many gems from the same github account

like with path and source I'd like to do this:
git 'https://github.com/my_company', branch: 'rm_2422-rails5-upgrade' do
gem 'foo'
gem 'bar'
# many more gems...
end
The idea being this would fetch the foo gem with the URL's https://github.com/my_company/foo.git using the rm_2422-rails5-upgrade branch.
I can see from the bundler docs that this is not how it works and I know I can do:
git 'foo', git: 'https://github.com/my_company/foo.git', branch: 'rm_2422-rails5-upgrade'
But I have lots of gems which need to be pulled from said branch.
I also looked at git_source but this does not seem to work for this case either.
You may define a new git_source in your Gemfile:
git_source(:your_source_name) do |repo_name|
repo_name = "company/#{repo_name}"
"https://github.com/#{repo_name}.git"
end
And then use it:
gem "gem_name", your_company: "gem_repo_name"
This was very simple example, but you may pass more options to the block. We use this approach to redefine original github source to be able to pass auth token for private repositories:
git_source(:github) do |(repo_name, auth_token)|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
auth_data = !!auth_token ? "#{auth_token}:x-oauth-basic#" : ""
"https://#{auth_data}github.com/#{repo_name}.git"
end
UPDATE: I found a way to do what you need, but this is quite a dirty hack IMHO. Since Gemfile is a pure ruby file you may define your own functions there:
def my_gem(name, *args)
options = args.last.is_a?(Hash) ? args.pop.dup : {}
version = args || [">= 0"]
options[:branch] = "develop"
gem(name, version, options)
end
And then use it, instead of original gem method:
my_gem "gem_name"
So one solution I used this:
['foo', 'bar'].each do |gem_name|
gem gem_name, git: "https://github.com/my_company/#{gem_name}.git", branch: 'rm_2422-rails5-upgrade'
end

Padrino Tutorial: Can't Modify Frozen String (Runtime Error)

I am following the Padrino tutorial from here:
https://www.padrinorb.com/guides/blog-tutorial
I am copy and pasting the commands but I quickly ran into an error I don't understand:
$ padrino g controller posts get:index get:show
create app/controllers/posts.rb
create app/views/posts
apply tests/shoulda
/Users/waprin/.rvm/gems/ruby-2.1.0/gems/padrino-gen-0.12.4/lib/padrino-gen/generators/controller.rb:66:in `prepend': can't modify frozen String (RuntimeError)
from /Users/waprin/.rvm/gems/ruby-2.1.0/gems/padrino-gen-0.12.4/lib/padrino-gen/generators/controller.rb:66:in `create_controller'
This might be a bit late, but in case anyone else runs across this error (and because I just worked through the same tutorial) I'll post anyway...
It looks like there's an issue when generating controllers if a test component is specified. In this case you're using shoulda, but the same happens when using rspec and maybe others. It's been reported as a bug: https://github.com/padrino/padrino-framework/issues/1850 and has been fixed, but isn't yet part of a stable release.
One option to fix this would be to change your Gemfile to work with the latest from their github repo. To do this delete your GemFile.lock file, and comment out the line under 'Padrino Stable Gem' in your GemFile:
gem 'padrino', '0.12.4'
then uncomment the line under 'Or Padrino Edge':
gem 'padrino', :github => 'padrino/padrino-framework'
then re-run bundle install.
Of course, you'll no longer be running the stable release, and that may come with other trade-offs.
As a side-note, I believe that the guide on that page is fairly out of date. I also needed to replace:
get :index do
#posts = Post.all(:order => 'created_at desc')
render 'posts/index'
end
with:
get :index, :provides => [:html, :rss, :atom] do
#posts = Post.order('created_at desc')
render 'posts/index'
end
in the Post controller as the active record interface has changed since the time that the guide was written.
I was able to sole this problem by simply going to padrino gem path.
For me it was:
/Users/ahmadhassan/.rvm/gems/ruby-2.2.0/gems/padrino-gen-0.12.4/lib/padrino-gen/generators
open controller.rb and change line number 61:
path = #controller
to
path = #controller.dup

undefined method `configure' for Savon:Module

I'm getting the above error in a gem with this code snippet
Savon.configure do |config|
config.log = false
config.log_level = :error
HTTPI.log = false
end
This code used to pass in past runs on Travis, so I'm not sure why this changed when I altered the Readme.
Part of this confusion comes from my situation--inheriting a gem to maintain--along with this line in the gemspec:
gem.add_dependency 'savon'
There's no version number specified, so the newest run switched over to using Savon 2, which ditched the Savon.configure global behavior. If you're in the same boat as me, changing this line to the last pre-2.0 version of Savon will resolve the issue:
gem.add_dependency 'savon', '~>1.2.0'
Then bundle install and you should be good.
Or you want to upgrade your code. I know I do.
Savon.configure was removed from Savon 2.0 because the "problem was global state". The quickest way to keep the behavior the same in your app would be to define a app-level global hash in the same place. You'd then pass this hash into every Savon.client call you make. For instance:
# Where Savon.configure was called
APP_OPTS = {
# disable request logging, silences HTTPI as well
log: false,
# Don't log Laundry xmls to STDOUT
log_level: :error,
#... etc
}
# Elsewhere
#client = Savon::Client.new(APP_OPTS)
I'd consider this a starting point to migrating to the 2.0 configuration style. Ideally, you should always consider the client-specific 2.0 options available when initializing each Savon client.

How to use ohai gem

In the OpsCode Wiki there is there following documentation:
require 'ohai'
# ...
# Profit! ;-)
How can I print the JSON data provided by the 'ohai' command but using IRB? I tried to see the code in application.rb but I get empty data.
require 'ohai/application'
ohai = Ohai::System.new
ohai.json_pretty_print
=> "{\n\n}"
I am not trying to do this within Chef (or Shef), I just want to use the ohai gem itself, in my own app.
Poking about in the Ohai::Application class (what you get when you run ohai), #run_application instantiates Ohai::System and, unless it was configured by a file, it calls all_plugins to populate it with data.
Presumably, Ohai::System#all_plugins delegates the data collection to the lib/ohai/plugins directory.
$ irb -rohai
> system = Ohai::System.new
=> #<Ohai::System:0x00000100988950 #data={}, #seen_plugins={}, #providers={}, #plugin_path="", #hints={}>
> system.all_plugins
=> true
> puts system.to_json
{"languages":{"ruby":{"platform":"x86_64-darwin10.8.0","version":"1.9.2", ...
> system.to_json.size
=> 42395
I too searched for a simple and good library to do that...
I came across
Usagewatch
and after 5 minutes had my monitoring.rb done..
Install : gem install usagewatch
Install on mac : gem install usagewatch_ext
Refer to this article for more info

wrong number of arguments (3 for 2) after upgrading from Rails 3.0.14 to Rails 3.1.4

Everything was working fine in Rails 3.0.14, but after changing
gem 'rails', '3.0.14' to gem 'rails', '3.1.4' and running bundle update rails I now get the following error:
Started GET "/" for 127.0.0.1 at 2012-03-16 11:11:44 -0400
Processing by PagesController#index as HTML
Completed 500 Internal Server Error in 54ms
ArgumentError (wrong number of arguments (3 for 2)):
app/controllers/application_controller.rb:37:in `customize_by_subdomain'```
The most popular answer seemed to be that sqlite3 needed to be updated, but I did bundle update sqlite3 and I still have the same problem.
Here is the full trace: https://gist.github.com/2050530
The method that it is complaining about looks like this:
35 def customize_by_subdomain
36 subdomain = (request.subdomain.present? && request.subdomain != 'www' && request.subdomain) || 'launch'
37 #current_org = Organization.find_by_subdomain(subdomain) || Organization.find_by_subdomain('launch')
38 end
I have looked at the multitude of similar questions and I not found anything that solves my problem. The closest was question to mine was: wrong number of arguments (3 for 1) after upgrading rails from 3.1.1 to 3.1.3 but I am using authlogic and the version I am using didn't change after upgrading rails.
The only other interesting thing is my entire test suite passes, except for one request/integration spec which goes through the process of creating a new user. It seems strange that my request specs work fine when I can't even access a page in development.
Any ideas on what I can do to get to the bottom of this?
It looks like your New Relic plugin may need to be updated to a new version. In your stacktrace, the first line is from the New Relic code in your plugins folder. From their site, it looks like they released new Rails 3.1-specific code:
http://blog.newrelic.com/2011/07/29/for-the-active-record-new-relic-support-for-rails-3-1-is-here/
In the blog post, they talk about changes to the way ActiveRecord does logging, and your exception was triggered on the log_with_instrumentation method.
It looks like now you should install it as a gem rather than a plugin:
https://github.com/newrelic/rpm
Hope this helps.

Resources