Skip to content

Commit

Permalink
Merge branch 'master' into rubocop-fixes-b
Browse files Browse the repository at this point in the history
  • Loading branch information
rkoster authored Feb 4, 2022
2 parents 36c13a9 + 43a3579 commit 2a89a2e
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 19 deletions.
4 changes: 4 additions & 0 deletions .final_builds/jobs/azure_cpi/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ builds:
version: 7505570ee4825fd31871e005157d43a79af7ad4d
blobstore_id: b2044ffb-f21a-42b2-60d0-e93bdb125c74
sha1: 8e1afca62e2702ca1a0846769c93c9cad305e252
75d16e44e84858f146a52e926190da5187400905ebbc9536f3db90f9f20626af:
version: 75d16e44e84858f146a52e926190da5187400905ebbc9536f3db90f9f20626af
blobstore_id: b5648119-1c9b-4916-6ed5-99cbf219b999
sha1: sha256:0ad3b4bbf0201346bfddba6b2a2215b0f9c84f6b47408220ad87fdd0ce325d0d
76930bbfe9adc298391cb0f8bc242e16be37d824466916705b06a119de4c1c4a:
version: 76930bbfe9adc298391cb0f8bc242e16be37d824466916705b06a119de4c1c4a
blobstore_id: 37f20e4b-9e6b-4c2b-5b60-471cb9a70f3e
Expand Down
4 changes: 4 additions & 0 deletions .final_builds/packages/bosh_azure_cpi/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ builds:
version: 7f7074c6a2df2f6967ed59cbbbcc9125941afdf3
blobstore_id: 0307c7d1-2048-4ef5-a5f6-53ede1e980d4
sha1: 21b5de8edbfbe44dfdd1757d5dc048f6fd6c73e0
9a83ad939adb71925a3d03da535a75ac256b7e2ee86f04a6959dc4235c7d2749:
version: 9a83ad939adb71925a3d03da535a75ac256b7e2ee86f04a6959dc4235c7d2749
blobstore_id: 405e94f5-1b7f-47b5-56f5-9fb418c240ff
sha1: sha256:c194f3146ee835915c94b0ca3cbb5f28a17d6ef1366a0382a11026c2cd1cb983
9ee80ffac7d5f183ad2d20d074f67d188948d154:
version: 9ee80ffac7d5f183ad2d20d074f67d188948d154
blobstore_id: 0dc241d2-5edc-4afa-8269-8bb228bcd698
Expand Down
28 changes: 28 additions & 0 deletions releases/bosh-azure-cpi/bosh-azure-cpi-38.0.0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: bosh-azure-cpi
version: 38.0.0
commit_hash: f1f495c
uncommitted_changes: false
jobs:
- name: azure_cpi
version: 75d16e44e84858f146a52e926190da5187400905ebbc9536f3db90f9f20626af
fingerprint: 75d16e44e84858f146a52e926190da5187400905ebbc9536f3db90f9f20626af
sha1: sha256:0ad3b4bbf0201346bfddba6b2a2215b0f9c84f6b47408220ad87fdd0ce325d0d
packages:
- ruby-2.7.3-r0.43.0
- bosh_azure_cpi
packages:
- name: bosh_azure_cpi
version: 9a83ad939adb71925a3d03da535a75ac256b7e2ee86f04a6959dc4235c7d2749
fingerprint: 9a83ad939adb71925a3d03da535a75ac256b7e2ee86f04a6959dc4235c7d2749
sha1: sha256:c194f3146ee835915c94b0ca3cbb5f28a17d6ef1366a0382a11026c2cd1cb983
dependencies:
- ruby-2.7.3-r0.43.0
- name: ruby-2.7.3-r0.43.0
version: 99c4d7fe18ef5287f062b73101b2b697fca340e7eac03b3ee87284b71e1c18d8
fingerprint: 99c4d7fe18ef5287f062b73101b2b697fca340e7eac03b3ee87284b71e1c18d8
sha1: sha256:2507840353929a72a2378481168e6d4ae1f2faa47939dfabb358a4724c1b634e
dependencies: []
license:
version: 6b556bc2340dd2ef930d9fffb160c925cb6edf0f217c620f695c10e127a53d9a
fingerprint: 6b556bc2340dd2ef930d9fffb160c925cb6edf0f217c620f695c10e127a53d9a
sha1: sha256:1e0838be726423eb3d67c119075a1d0ea35d82d8bd66327a139abaa7d6a28a3c
2 changes: 2 additions & 0 deletions releases/bosh-azure-cpi/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ builds:
version: "8"
701c31e9-33e9-46f9-4347-4dbfd6b9f390:
version: "34"
7e847c23-242a-42d3-60ea-c5aa29d8a5d3:
version: 38.0.0
7fb7b095-78f6-42b6-ad4a-cddaa52e4ac0:
version: "6"
80ee34a2-c451-46d8-8b02-7ea46045b50c:
Expand Down
2 changes: 1 addition & 1 deletion src/bosh_azure_cpi/lib/cloud/azure/cloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Cloud < Bosh::Cloud # rubocop:todo Metrics/ClassLength
#
# @param [Hash] options cloud options
def initialize(options, api_version = 1)
cloud_error("Invalid api_version '#{api_version}'") unless [1, 2].include?(api_version)
cloud_error("Invalid api_version '#{api_version}'") unless [1, 2, nil].include?(api_version)

options_dup = options.dup.freeze

Expand Down
16 changes: 8 additions & 8 deletions src/bosh_azure_cpi/spec/integration/azure_cpi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
end

it 'should call Azure management endpoint with a valid access token' do
result = run_cpi('method' => 'has_vm', 'arguments' => [SecureRandom.uuid.to_s], 'context' => { 'director_uuid' => 'abc123' })
result = run_cpi('method' => 'has_vm', 'arguments' => [SecureRandom.uuid.to_s], 'context' => { 'director_uuid' => 'abc123' }, 'api_version' => 2)
expect(result.keys).to eq(%w[result error log])
expect(result['result']).to be_falsey
expect(result['error']).to be_nil
Expand Down Expand Up @@ -93,7 +93,7 @@
end

it 'should call Azure management endpoint with a valid access token' do
result = run_cpi('method' => 'has_vm', 'arguments' => [SecureRandom.uuid.to_s], 'context' => { 'director_uuid' => 'abc123' })
result = run_cpi('method' => 'has_vm', 'arguments' => [SecureRandom.uuid.to_s], 'context' => { 'director_uuid' => 'abc123' }, 'api_version' => 2)
expect(result.keys).to eq(%w[result error log])
expect(result['result']).to be_falsey
expect(result['error']).to be_nil
Expand Down Expand Up @@ -131,7 +131,7 @@
end

it 'will not evaluate anything that causes an exception and will return the proper message to stdout' do
result = run_cpi('method' => 'has_vm', 'arguments' => [SecureRandom.uuid.to_s], 'context' => { 'director_uuid' => 'abc123' })
result = run_cpi('method' => 'has_vm', 'arguments' => [SecureRandom.uuid.to_s], 'context' => { 'director_uuid' => 'abc123' }, 'api_version' => 2)
expect(result.keys).to eq(%w[result error log])
expect(result['result']).to be_nil
expect(result['error']['message']).to match(%r{http code: 400. Azure authentication failed: Bad request. Please assure no typo in values of tenant_id, client_id or client_secret/certificate})
Expand Down Expand Up @@ -170,7 +170,7 @@
end

it 'will not evaluate anything that causes an exception and will return the proper message to stdout' do
result = run_cpi('method' => 'has_vm', 'arguments' => [SecureRandom.uuid.to_s], 'context' => { 'director_uuid' => 'abc123' })
result = run_cpi('method' => 'has_vm', 'arguments' => [SecureRandom.uuid.to_s], 'context' => { 'director_uuid' => 'abc123' }, 'api_version' => 2)
expect(result.keys).to eq(%w[result error log])
expect(result['result']).to be_nil
expect(result['error']['message']).to match(%r{http code: 401. Azure authentication failed: Invalid tenant_id, client_id or client_secret/certificate})
Expand All @@ -185,7 +185,7 @@
let(:cloud_properties) { {} }

it 'will return an appropriate error message when passed an invalid config file' do
result = run_cpi('method' => 'ping', 'arguments' => [], 'context' => { 'director_uuid' => 'abc123' })
result = run_cpi('method' => 'ping', 'arguments' => [], 'context' => { 'director_uuid' => 'abc123' }, 'api_version' => 2)
expect(result.keys).to eq(%w[result error log])
expect(result['result']).to be_nil
expect(result['error']).to eq(
Expand Down Expand Up @@ -232,16 +232,16 @@
end

it 'merges the context into the cloud_properties' do
result = run_cpi('method' => 'has_vm', 'arguments' => [SecureRandom.uuid.to_s], 'context' => context)
result = run_cpi('method' => 'has_vm', 'arguments' => [SecureRandom.uuid.to_s], 'context' => context, 'api_version' => 2)
expect(result.keys).to eq(%w[result error log])
expect(result['result']).not_to be_nil
expect(result['result']).to be_falsey
expect(result['error']).to be_nil
end

it 'returns the api version' do
result = run_cpi('method' => 'info', 'arguments' => [], 'context' => context)
expect(result['result']).not_to be_nil
result = run_cpi('method' => 'info', 'arguments' => [], 'context' => context, 'api_version' => 2)
expect(result['result']).to_not be_nil
expect(result['error']).to be_nil
expect(result['result']['api_version']).to eq(2)
end
Expand Down
10 changes: 0 additions & 10 deletions src/bosh_azure_cpi/spec/unit/cloud/cloud_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,6 @@
end
end

context 'to api version nil' do
let(:api_version) { nil }

it 'raises an exception' do
expect do
mock_cloud(nil, api_version)
end.to raise_error(Bosh::Clouds::CloudError, "Invalid api_version '#{api_version}'")
end
end

context 'to api version 3' do
let(:api_version) { 3 }

Expand Down

0 comments on commit 2a89a2e

Please sign in to comment.