Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to ruby 2.7 #634

Merged
merged 3 commits into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export RELEASE_DIR=$PWD
export SRC_DIR=$PWD/src/bosh_azure_cpi
export PROJECT_RUBY_VERSION=2.4.4
export PROJECT_RUBY_VERSION=2.7.3
8 changes: 4 additions & 4 deletions src/bosh_azure_cpi/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

source 'https://rubygems.org'

gem 'azure-storage', '0.12.3.preview'
gem 'azure-storage', '~> 0.15.0.preview'
gem 'bosh_common', '1.3262.24.0'
gem 'bosh_cpi', '2.5.0'
gem 'concurrent-ruby', '1.0.5'
gem 'jwt', '1.5.6'
gem 'deep_merge', '~> 1.0', '>= 1.0.1'
gem 'concurrent-ruby', '~> 1.1', '>= 1.1.8'
gem 'jwt', '~> 2.2', '>= 2.2.2'
gem 'deep_merge', '~> 1.2', '>= 1.2.1'

group :development, :test do
gem 'rake', '~>12.0'
Expand Down
87 changes: 45 additions & 42 deletions src/bosh_azure_cpi/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,55 +1,58 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
ast (2.4.0)
azure-core (0.1.14)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
ast (2.4.2)
azure-core (0.1.15)
faraday (~> 0.9)
faraday_middleware (~> 0.10)
nokogiri (~> 1.6)
azure-storage (0.12.3.preview)
azure-storage (0.15.0.preview)
azure-core (~> 0.1)
faraday (~> 0.9)
faraday_middleware (~> 0.10)
nokogiri (~> 1.6, >= 1.6.8)
bosh_common (1.3262.24.0)
logging (~> 1.8.2)
semi_semantic (~> 1.2.0)
bosh_cpi (2.5.0)
httpclient (~> 2.8.3)
membrane (~> 1.1.0)
concurrent-ruby (1.0.5)
crack (0.4.3)
safe_yaml (~> 1.0.0)
concurrent-ruby (1.1.8)
crack (0.4.5)
rexml
deep_merge (1.2.1)
diff-lcs (1.3)
docile (1.1.5)
faraday (0.14.0)
diff-lcs (1.4.4)
docile (1.3.5)
faraday (0.17.4)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.12.2)
faraday_middleware (0.14.0)
faraday (>= 0.7.4, < 1.0)
hashdiff (0.3.6)
hashdiff (1.0.1)
httpclient (2.8.3)
jaro_winkler (1.5.1)
json (2.1.0)
jwt (1.5.6)
jaro_winkler (1.5.4)
jwt (2.2.2)
little-plugger (1.1.4)
logging (1.8.2)
little-plugger (>= 1.1.3)
multi_json (>= 1.8.4)
membrane (1.1.0)
mini_portile2 (2.3.0)
multi_json (1.12.1)
multipart-post (2.0.0)
nokogiri (1.8.2)
mini_portile2 (~> 2.3.0)
parallel (1.12.1)
parser (2.5.1.2)
ast (~> 2.4.0)
powerpack (0.1.2)
public_suffix (3.0.0)
mini_portile2 (2.5.0)
multi_json (1.15.0)
multipart-post (2.1.1)
nokogiri (1.11.3)
mini_portile2 (~> 2.5.0)
racc (~> 1.4)
parallel (1.20.1)
parser (3.0.1.0)
ast (~> 2.4.1)
powerpack (0.1.3)
public_suffix (4.0.6)
racc (1.5.2)
rainbow (3.0.0)
rake (12.0.0)
rake (12.3.3)
rexml (3.2.5)
rspec (3.5.0)
rspec-core (~> 3.5.0)
rspec-expectations (~> 3.5.0)
Expand All @@ -71,35 +74,35 @@ GEM
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.4.0)
ruby-progressbar (1.10.0)
safe_yaml (1.0.4)
ruby-progressbar (1.11.0)
semi_semantic (1.2.0)
simplecov (0.15.0)
docile (~> 1.1.0)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
unicode-display_width (1.4.0)
webmock (3.0.1)
simplecov (0.21.2)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.2)
unicode-display_width (1.4.1)
webmock (3.12.2)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
hashdiff (>= 0.4.0, < 2.0.0)

PLATFORMS
ruby

DEPENDENCIES
azure-storage (= 0.12.3.preview)
azure-storage (~> 0.15.0.preview)
bosh_common (= 1.3262.24.0)
bosh_cpi (= 2.5.0)
concurrent-ruby (= 1.0.5)
deep_merge (~> 1.0, >= 1.0.1)
jwt (= 1.5.6)
concurrent-ruby (~> 1.1, >= 1.1.8)
deep_merge (~> 1.2, >= 1.2.1)
jwt (~> 2.2, >= 2.2.2)
rake (~> 12.0)
rspec (~> 3.5.0)
rubocop (~> 0.60.0)
simplecov
webmock

BUNDLED WITH
1.17.1
2.1.4
26 changes: 13 additions & 13 deletions src/bosh_azure_cpi/lib/cloud/azure/restapi/azure_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ def initialize(azure_config, logger)

# Common
def rest_api_url(resource_provider, resource_type, resource_group_name: nil, name: nil, others: nil)
url = "/subscriptions/#{URI.escape(@azure_config.subscription_id)}"
url = "/subscriptions/#{uri_escape(@azure_config.subscription_id)}"
resource_group_name = @azure_config.resource_group_name if resource_group_name.nil?
url += "/resourceGroups/#{URI.escape(resource_group_name)}"
url += "/resourceGroups/#{uri_escape(resource_group_name)}"
url += "/providers/#{resource_provider}"
url += "/#{resource_type}"
url += "/#{URI.escape(name)}" unless name.nil?
url += "/#{URI.escape(others)}" unless others.nil?
url += "/#{uri_escape(name)}" unless name.nil?
url += "/#{uri_escape(others)}" unless others.nil?
url
end

Expand All @@ -130,7 +130,7 @@ def get_resource_by_id(url, params = {})
begin
uri = http_url(url, params)
response = http_get(uri)
result = JSON.parse(response.body) unless response.body.nil?
result = JSON.parse(response.body) unless response.body.nil? || response.body == ''
rescue AzureNotFoundError => e
@logger.debug("Resource not found for url #{url} with parms #{params}")
result = nil
Expand Down Expand Up @@ -181,8 +181,8 @@ def get_resources_by_url(url, params = {})
# @See https://docs.microsoft.com/en-us/rest/api/resources/resourcegroups#ResourceGroups_CreateOrUpdate
#
def create_resource_group(resource_group_name, location)
url = "/subscriptions/#{URI.escape(@azure_config.subscription_id)}"
url += "/resourceGroups/#{URI.escape(resource_group_name)}"
url = "/subscriptions/#{uri_escape(@azure_config.subscription_id)}"
url += "/resourceGroups/#{uri_escape(resource_group_name)}"

resource_group = {
'name' => resource_group_name,
Expand All @@ -202,8 +202,8 @@ def create_resource_group(resource_group_name, location)
def get_resource_group(resource_group_name)
resource_group = nil

url = "/subscriptions/#{URI.escape(@azure_config.subscription_id)}"
url += "/resourceGroups/#{URI.escape(resource_group_name)}"
url = "/subscriptions/#{uri_escape(@azure_config.subscription_id)}"
url += "/resourceGroups/#{uri_escape(resource_group_name)}"
result = get_resource_by_id(url)

unless result.nil?
Expand Down Expand Up @@ -453,7 +453,7 @@ def create_virtual_machine(resource_group_name, vm_params, network_interfaces, a
#
def list_available_virtual_machine_sizes_by_location(location)
vm_sizes = []
url = "/subscriptions/#{URI.escape(@azure_config.subscription_id)}"
url = "/subscriptions/#{uri_escape(@azure_config.subscription_id)}"
url += "/providers/#{REST_API_PROVIDER_COMPUTE}"
url += "/locations/#{location}"
url += "/#{REST_API_VM_SIZES}"
Expand Down Expand Up @@ -1217,7 +1217,7 @@ def delete_managed_snapshot(resource_group_name, name)
#
def list_platform_image_versions(location, publisher, offer, sku)
images = []
url = "/subscriptions/#{URI.escape(@azure_config.subscription_id)}"
url = "/subscriptions/#{uri_escape(@azure_config.subscription_id)}"
url += "/providers/#{REST_API_PROVIDER_COMPUTE}"
url += "/locations/#{location}"
url += "/publishers/#{publisher}"
Expand Down Expand Up @@ -1831,7 +1831,7 @@ def create_storage_account(name, location, sku, kind, tags)
# https://github.com/Azure/azure-rest-api-specs/blob/master/specification/storage/resource-manager/Microsoft.Storage/stable/2016-01-01/storage.json
#
def check_storage_account_name_availability(name)
url = "/subscriptions/#{URI.escape(@azure_config.subscription_id)}"
url = "/subscriptions/#{uri_escape(@azure_config.subscription_id)}"
url += "/providers/#{REST_API_PROVIDER_STORAGE}"
url += '/checkNameAvailability'
storage_account = {
Expand Down Expand Up @@ -2427,7 +2427,7 @@ def check_completion(response, options)
status_code = response.code.to_i
raise AzureAsynchronousError.new, "check_completion - http code: #{response.code}. Error message: #{response.body}" if status_code != HTTP_CODE_OK && status_code != HTTP_CODE_ACCEPTED

raise AzureAsynchronousError.new, 'The body of the asynchronous response is empty' if response.body.nil?
raise AzureAsynchronousError.new, 'The body of the asynchronous response is empty' if response.body.nil? || response.body == ''

result = JSON(response.body)
raise AzureAsynchronousError.new, "The body of the asynchronous response does not contain 'status'. Response: #{response.body}" if result['status'].nil?
Expand Down
4 changes: 4 additions & 0 deletions src/bosh_azure_cpi/lib/cloud/azure/utils/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -634,5 +634,9 @@ def validate_idle_timeout(idle_timeout_in_minutes)
cloud_error('Minimum idle_timeout_in_minutes is 4 minutes') if idle_timeout_in_minutes < 4
cloud_error('Maximum idle_timeout_in_minutes is 30 minutes') if idle_timeout_in_minutes > 30
end

def uri_escape(raw_uri)
CGI.escape(raw_uri).sub("%2F", "/")
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@

it 'encodes the password with special characters in the registry URL' do
registry_uri = URI(subject['cloud']['properties']['registry']['endpoint'])
expect(URI.decode(registry_uri.password)).to eq(special_chars_password)
expect(URI.decode_www_form_component(registry_uri.password)).to eq(special_chars_password)
end
end

Expand Down