kitchen-azurerm 1.1.0 → 1.2.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: c53c5b50e83af16c56722ecbc2baa30b5a28621cc17f4edde82a59b22420812f
4
- data.tar.gz: cd39338fdf0d29d39780e93b6a9fc8c27cd955daf59b6fc79f3be56801c7d891
3
+ metadata.gz: 8615b3c50c7c88dc0167c2b0daebd1c66c1fec9bd05d1c169223c30fc00a7cc2
4
+ data.tar.gz: 769a0df10ad7af7a1215066955eba46717e16358f83ad176df6954d4f2e43d49
5
5
  SHA512:
6
- metadata.gz: d62cae11a2fa2a679657fc9c81e6b03547802cd7773f6b801b644388beb09b6fe44de2f0d5f2e9a1601cf3eee92b7a2d86e1f29e7dd86b09e3e6445fdceaebd5
7
- data.tar.gz: 8bbccc8d27fef365420257f9a11d89cd8b326cf6e60c97e737c1fe304b14f28ee543793c314e9e638096b606c6ccc64986e7d4db94345d53463981b84eadc931
6
+ metadata.gz: 48a2d37a873c8d2b842dc20e0c2e40cc9b349faed29d0c1f9bbc12ccb53097e0df0a06884f29c840b2e2f72a3deef6a0ab2244ef037a9c1aa24397524f756747
7
+ data.tar.gz: b3538aa314c217566e22a359655aee67eedb88cff3d2ea2f35e17445db4fe5821b57d5beb183f8ec77ac077ed58f88f275fd011fbdaa162a3b17def168c2c99e
data/README.md CHANGED
@@ -674,6 +674,8 @@ info: vm image list command OK
674
674
 
675
675
  * The ```destroy_resource_group_contents``` (default: "false") parameter can be used when you want to destroy the resources within a resource group without destroying the resource group itself. For example, the following configuration options used in combination would use an existing resource group (or create one if it doesn't exist) and will destroy the contents of the resource group in the ```kitchen destroy``` phase.
676
676
 
677
+ * The ```destroy_explicit_resource_group_tags``` (default: "true") parameter can be used when you want to remove tags associated with an explicit resource group. The default setting is set to `true` to remain consistent with previous behavior. This should be used in combination with an explicitly named resource group and will be honored during the ```kitchen destroy``` phase.
678
+
677
679
  ```yaml
678
680
  ---
679
681
  driver:
@@ -1,15 +1,15 @@
1
1
  require "kitchen"
2
2
  require_relative "azure_credentials"
3
- require "securerandom"
3
+ require "securerandom" unless defined?(SecureRandom)
4
4
  require "azure_mgmt_resources"
5
5
  require "azure_mgmt_network"
6
- require "base64"
6
+ require "base64" unless defined?(Base64)
7
7
  require "sshkey"
8
- require "fileutils"
9
- require "erb"
10
- require "ostruct"
11
- require "json"
12
- require "faraday"
8
+ require "fileutils" unless defined?(FileUtils)
9
+ require "erb" unless defined?(Erb)
10
+ require "ostruct" unless defined?(OpenStruct)
11
+ require "json" unless defined?(JSON)
12
+ require "faraday" unless defined?(Faraday)
13
13
 
14
14
  module Kitchen
15
15
  module Driver
@@ -174,6 +174,10 @@ module Kitchen
174
174
  true
175
175
  end
176
176
 
177
+ default_config(:destroy_explicit_resource_group_tags) do |_config|
178
+ true
179
+ end
180
+
177
181
  default_config(:destroy_resource_group_contents) do |_config|
178
182
  false
179
183
  end
@@ -277,12 +281,9 @@ module Kitchen
277
281
  @resource_management_client = ::Azure::Resources::Profiles::Latest::Mgmt::Client.new(options)
278
282
 
279
283
  # Create Resource Group
280
- resource_group = ::Azure::Resources::Profiles::Latest::Mgmt::Models::ResourceGroup.new
281
- resource_group.location = config[:location]
282
- resource_group.tags = config[:resource_group_tags]
283
284
  begin
284
285
  info "Creating Resource Group: #{state[:azure_resource_group_name]}"
285
- create_resource_group(state[:azure_resource_group_name], resource_group)
286
+ create_resource_group(state[:azure_resource_group_name], get_resource_group)
286
287
  rescue ::MsRestAzure::AzureOperationError => operation_error
287
288
  error operation_error.body
288
289
  raise operation_error
@@ -534,6 +535,35 @@ module Kitchen
534
535
  info "Creating deployment: #{empty_deployment_name}"
535
536
  create_deployment_async(state[:azure_resource_group_name], empty_deployment_name, empty_deployment).value!
536
537
  follow_deployment_until_end_state(state[:azure_resource_group_name], empty_deployment_name)
538
+
539
+ # Maintain tags on the resource group
540
+ if config[:destroy_explicit_resource_group_tags] == false
541
+ warn 'The "destroy_explicit_resource_group_tags" setting value is set to "false". The tags on the resource group will NOT be removed.'
542
+ # NOTE: We are using the internal wrapper function create_resource_group() which wraps the API
543
+ # method of create_or_update().
544
+ begin
545
+ create_resource_group(state[:azure_resource_group_name], get_resource_group)
546
+ rescue ::MsRestAzure::AzureOperationError => operation_error
547
+ error operation_error.body
548
+ raise operation_error
549
+ end
550
+ end
551
+
552
+ # Corner case where we want to use kitchen to remove the tags
553
+ if config[:destroy_explicit_resource_group_tags] == true
554
+ warn 'The "destroy_explicit_resource_group_tags" setting value is set to "true". The tags on the resource group will be removed.'
555
+ # NOTE: We are using the internal wrapper function create_resource_group() which wraps the API
556
+ # method of create_or_update().
557
+ resource_group = get_resource_group
558
+ resource_group.tags = {}
559
+ begin
560
+ create_resource_group(state[:azure_resource_group_name], resource_group)
561
+ rescue ::MsRestAzure::AzureOperationError => operation_error
562
+ error operation_error.body
563
+ raise operation_error
564
+ end
565
+ end
566
+
537
567
  rescue ::MsRestAzure::AzureOperationError => operation_error
538
568
  error operation_error.body
539
569
  raise operation_error
@@ -706,6 +736,16 @@ module Kitchen
706
736
  # Wrapper methods for the Azure API calls to retry the calls when getting timeouts.
707
737
  #
708
738
 
739
+ # Create a new resource group object and set the location and tags attributes then return it.
740
+ #
741
+ # @return [::Azure::Resources::Profiles::Latest::Mgmt::Models::ResourceGroup] A new resource group object.
742
+ def get_resource_group
743
+ resource_group = ::Azure::Resources::Profiles::Latest::Mgmt::Models::ResourceGroup.new
744
+ resource_group.location = config[:location]
745
+ resource_group.tags = config[:resource_group_tags]
746
+ resource_group
747
+ end
748
+
709
749
  def create_resource_group(resource_group_name, resource_group)
710
750
  retries = config[:azure_api_retries]
711
751
  begin
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-azurerm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stuart Preston
@@ -128,16 +128,16 @@ dependencies:
128
128
  name: chefstyle
129
129
  requirement: !ruby/object:Gem::Requirement
130
130
  requirements:
131
- - - ">="
131
+ - - '='
132
132
  - !ruby/object:Gem::Version
133
- version: '0'
133
+ version: 1.2.1
134
134
  type: :development
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
137
137
  requirements:
138
- - - ">="
138
+ - - '='
139
139
  - !ruby/object:Gem::Version
140
- version: '0'
140
+ version: 1.2.1
141
141
  - !ruby/object:Gem::Dependency
142
142
  name: rspec
143
143
  requirement: !ruby/object:Gem::Requirement