kitchen-azurerm 0.17.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 79955d1437d49030459425fce323174e40d3a437c75dbe52393d9d5cc85df4b3
4
- data.tar.gz: b08a9f9715e9f04fadb5965565604ce95d71a3fc2b38cb836a99b16c1f883df4
3
+ metadata.gz: 1bddd20bd82c0fb19e06a74cd69a93e1ee640eb07f791253fe9a15851f1b6130
4
+ data.tar.gz: ed27bd9192b4ec9ebc0b4e57f1ec0dbe4bf846b0d92364e0b61ec4e74f2e1331
5
5
  SHA512:
6
- metadata.gz: a8e2a9e7905a2c670e295d912a995c657021f4171d0e902d77c4c62d780ab1ebfe29365ed943a57224af53d87e0257f261065e3189f986bde8462975745943e0
7
- data.tar.gz: 1857240fc7bf3642dd91e3f8f3be067b4d88e53754afd1ee61b9c9ce1ef730a10a71edc1f145e6e7ec64a8e8e51a07b8e93ff2ac5022ee90f326b16e5bd8c91a
6
+ metadata.gz: 69f357bfd30b8c5b53cde84ce691f2193a2d00fb0baa133d6150d85b6d4f0ee40525bdac780cac9cb66a241ce2be59ad3e73aec78c01b451da3a80cd0d50e13e
7
+ data.tar.gz: aa96b2f9d5a80515971e46999614224a2b674be6789255eb59b10980636a8f17c8535fab61dd738e13571224a21fe3847dd08313c23a058a09ac853473824257
@@ -1,4 +1,5 @@
1
1
  require "inifile"
2
+ require "kitchen/logging"
2
3
 
3
4
  module Kitchen
4
5
  module Driver
@@ -6,6 +7,8 @@ module Kitchen
6
7
  # AzureCredentials
7
8
  #
8
9
  class AzureCredentials
10
+ include Kitchen::Logging
11
+
9
12
  CONFIG_PATH = "#{ENV["HOME"]}/.azure/credentials".freeze
10
13
 
11
14
  #
@@ -24,12 +27,6 @@ module Kitchen
24
27
  def initialize(subscription_id:, environment: "Azure")
25
28
  @subscription_id = subscription_id
26
29
  @environment = environment
27
- config_file = ENV["AZURE_CONFIG_FILE"] || File.expand_path(CONFIG_PATH)
28
- if File.file?(config_file)
29
- @credentials = IniFile.load(File.expand_path(config_file))
30
- else
31
- warn "#{CONFIG_PATH} was not found or not accessible. Will use environment variables or MSI."
32
- end
33
30
  end
34
31
 
35
32
  #
@@ -50,8 +47,23 @@ module Kitchen
50
47
 
51
48
  private
52
49
 
50
+ def logger
51
+ Kitchen.logger
52
+ end
53
+
54
+ def config_path
55
+ @config_path ||= File.expand_path(ENV["AZURE_CONFIG_FILE"] || CONFIG_PATH)
56
+ end
57
+
53
58
  def credentials
54
- @credentials ||= {}
59
+ @credentials ||= begin
60
+ if File.file?(config_path)
61
+ IniFile.load(config_path)
62
+ else
63
+ warn "#{config_path} was not found or not accessible. Will attempt to use Managed Identity."
64
+ {}
65
+ end
66
+ end
55
67
  end
56
68
 
57
69
  def credentials_property(property)
@@ -59,7 +71,7 @@ module Kitchen
59
71
  end
60
72
 
61
73
  def tenant_id!
62
- tenant_id || raise("Must provide tenant id. Use AZURE_TENANT_ID environment variable or set it in credentials file")
74
+ tenant_id || raise("Must provide tenant id. Use AZURE_TENANT_ID environment variable or set it in credentials file (#{config_path})")
63
75
  end
64
76
 
65
77
  def tenant_id
@@ -214,7 +214,7 @@ module Kitchen
214
214
  dnsNameForPublicIP: "kitchen-#{state[:uuid]}",
215
215
  vmName: state[:vm_name],
216
216
  systemAssignedIdentity: config[:system_assigned_identity],
217
- userAssignedIdentities: config[:user_assigned_identities],
217
+ userAssignedIdentities: config[:user_assigned_identities].map { |identity| [identity, {}] }.to_h,
218
218
  secretUrl: config[:secret_url],
219
219
  vaultName: config[:vault_name],
220
220
  vaultResourceGroup: config[:vault_resource_group],
@@ -178,10 +178,10 @@
178
178
  }
179
179
  },
180
180
  "userAssignedIdentities": {
181
- "type": "array",
182
- "defaultValue": [],
181
+ "type": "object",
182
+ "defaultValue": {},
183
183
  "metadata": {
184
- "description": "A list of resource IDs for user identities to associate with the Virtual Machine, or empty to disable user assigned identities."
184
+ "description": "An object whose keys are resource IDs for user identities to associate with the Virtual Machine and whose values are empty objects, or empty to disable user assigned identities."
185
185
  }
186
186
  },
187
187
  "bootDiagnosticsEnabled": {
@@ -415,7 +415,7 @@
415
415
  <%- end -%>
416
416
  "identity": {
417
417
  "type": "[variables('vmIdentityType')]",
418
- "identityIds": "[if(empty(parameters('userAssignedIdentities')), json('null'), parameters('userAssignedIdentities'))]"
418
+ "userAssignedIdentities": "[if(empty(parameters('userAssignedIdentities')), json('null'), parameters('userAssignedIdentities'))]"
419
419
  },
420
420
  "tags": {
421
421
  <%= vm_tags unless vm_tags.empty? %>
@@ -178,10 +178,10 @@
178
178
  }
179
179
  },
180
180
  "userAssignedIdentities": {
181
- "type": "array",
182
- "defaultValue": [],
181
+ "type": "object",
182
+ "defaultValue": {},
183
183
  "metadata": {
184
- "description": "A list of resource IDs for user identities to associate with the Virtual Machine, or empty to disable user assigned identities."
184
+ "description": "An object whose keys are resource IDs for user identities to associate with the Virtual Machine and whose values are empty objects, or empty to disable user assigned identities."
185
185
  }
186
186
  },
187
187
  "bootDiagnosticsEnabled": {
@@ -434,7 +434,7 @@
434
434
  <%- end -%>
435
435
  "identity": {
436
436
  "type": "[variables('vmIdentityType')]",
437
- "identityIds": "[if(empty(parameters('userAssignedIdentities')), json('null'), parameters('userAssignedIdentities'))]"
437
+ "userAssignedIdentities": "[if(empty(parameters('userAssignedIdentities')), json('null'), parameters('userAssignedIdentities'))]"
438
438
  },
439
439
  "tags": {
440
440
  <%= vm_tags unless vm_tags.empty? %>
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.17.0
4
+ version: 1.0.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-23 00:00:00.000000000 Z
11
+ date: 2020-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: azure_mgmt_network