kitchen-azurerm 0.16.0 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0297cfb4995954d151ff4470003bda77346f3803c191e6976d203f93d7ac609
4
- data.tar.gz: 413ca9548e641ab00539ac961811b1e165c3ce76a7b67026371e08ed52566ed5
3
+ metadata.gz: 79955d1437d49030459425fce323174e40d3a437c75dbe52393d9d5cc85df4b3
4
+ data.tar.gz: b08a9f9715e9f04fadb5965565604ce95d71a3fc2b38cb836a99b16c1f883df4
5
5
  SHA512:
6
- metadata.gz: eba1be42553a0ae1d7f1fe8ef8b6edb7f023419437a6df07bf60cabce6b7b2c80a5d118cdefe03d8c8bdbddb3dc88b6bc95fd1aa23b6746156ea79ade7bcb86a
7
- data.tar.gz: 8eb3d2395711058767c7606fa9ae96dd486c9ba8a0f0511ff1f2688b569448d9442faf9d043cb6f5ca327c370c281d0994855b80ef449985a23a96df438c4103
6
+ metadata.gz: a8e2a9e7905a2c670e295d912a995c657021f4171d0e902d77c4c62d780ab1ebfe29365ed943a57224af53d87e0257f261065e3189f986bde8462975745943e0
7
+ data.tar.gz: 1857240fc7bf3642dd91e3f8f3be067b4d88e53754afd1ee61b9c9ce1ef730a10a71edc1f145e6e7ec64a8e8e51a07b8e93ff2ac5022ee90f326b16e5bd8c91a
@@ -28,7 +28,7 @@ module Kitchen
28
28
  if File.file?(config_file)
29
29
  @credentials = IniFile.load(File.expand_path(config_file))
30
30
  else
31
- warn "#{CONFIG_PATH} was not found or not accessible."
31
+ warn "#{CONFIG_PATH} was not found or not accessible. Will use environment variables or MSI."
32
32
  end
33
33
  end
34
34
 
@@ -38,33 +38,50 @@ module Kitchen
38
38
  # @return [Object] Object that can be supplied along with all Azure client requests.
39
39
  #
40
40
  def azure_options
41
- options = { tenant_id: tenant_id,
42
- client_id: client_id,
43
- client_secret: client_secret,
41
+ options = { tenant_id: tenant_id!,
44
42
  subscription_id: subscription_id,
45
43
  credentials: ::MsRest::TokenCredentials.new(token_provider),
46
44
  active_directory_settings: ad_settings,
47
45
  base_url: endpoint_settings.resource_manager_endpoint_url }
48
-
46
+ options[:client_id] = client_id if client_id
47
+ options[:client_secret] = client_secret if client_secret
49
48
  options
50
49
  end
51
50
 
52
51
  private
53
52
 
53
+ def credentials
54
+ @credentials ||= {}
55
+ end
56
+
57
+ def credentials_property(property)
58
+ credentials[subscription_id]&.[](property)
59
+ end
60
+
61
+ def tenant_id!
62
+ tenant_id || raise("Must provide tenant id. Use AZURE_TENANT_ID environment variable or set it in credentials file")
63
+ end
64
+
54
65
  def tenant_id
55
- ENV["AZURE_TENANT_ID"] || @credentials[subscription_id]["tenant_id"]
66
+ ENV["AZURE_TENANT_ID"] || credentials_property("tenant_id")
56
67
  end
57
68
 
58
69
  def client_id
59
- ENV["AZURE_CLIENT_ID"] || @credentials[subscription_id]["client_id"]
70
+ ENV["AZURE_CLIENT_ID"] || credentials_property("client_id")
60
71
  end
61
72
 
62
73
  def client_secret
63
- ENV["AZURE_CLIENT_SECRET"] || @credentials[subscription_id]["client_secret"]
74
+ ENV["AZURE_CLIENT_SECRET"] || credentials_property("client_secret")
64
75
  end
65
76
 
66
77
  def token_provider
67
- ::MsRestAzure::ApplicationTokenProvider.new(tenant_id, client_id, client_secret, ad_settings)
78
+ if client_id && client_secret
79
+ ::MsRestAzure::ApplicationTokenProvider.new(tenant_id, client_id, client_secret, ad_settings)
80
+ elsif client_id
81
+ ::MsRestAzure::MSITokenProvider.new(50342, ad_settings, { client_id: client_id })
82
+ else
83
+ ::MsRestAzure::MSITokenProvider.new(50342, ad_settings)
84
+ end
68
85
  end
69
86
 
70
87
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-azurerm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stuart Preston
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-22 00:00:00.000000000 Z
11
+ date: 2020-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: azure_mgmt_network
@@ -110,20 +110,6 @@ dependencies:
110
110
  - - "<"
111
111
  - !ruby/object:Gem::Version
112
112
  version: '3.0'
113
- - !ruby/object:Gem::Dependency
114
- name: bundler
115
- requirement: !ruby/object:Gem::Requirement
116
- requirements:
117
- - - ">="
118
- - !ruby/object:Gem::Version
119
- version: '0'
120
- type: :development
121
- prerelease: false
122
- version_requirements: !ruby/object:Gem::Requirement
123
- requirements:
124
- - - ">="
125
- - !ruby/object:Gem::Version
126
- version: '0'
127
113
  - !ruby/object:Gem::Dependency
128
114
  name: rake
129
115
  requirement: !ruby/object:Gem::Requirement
@@ -194,6 +180,20 @@ dependencies:
194
180
  - - "~>"
195
181
  - !ruby/object:Gem::Version
196
182
  version: '3.5'
183
+ - !ruby/object:Gem::Dependency
184
+ name: rspec-its
185
+ requirement: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - "~>"
188
+ - !ruby/object:Gem::Version
189
+ version: 1.3.0
190
+ type: :development
191
+ prerelease: false
192
+ version_requirements: !ruby/object:Gem::Requirement
193
+ requirements:
194
+ - - "~>"
195
+ - !ruby/object:Gem::Version
196
+ version: 1.3.0
197
197
  description: Test Kitchen driver for the Microsoft Azure Resource Manager (ARM) API
198
198
  email:
199
199
  - stuart@chef.io