terraspace_plugin_google 0.3.2 → 0.3.3

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: b1969fbb36af32fab94f9351578d4807c893066757463883a59782c431a5a56f
4
- data.tar.gz: d1cdf9f00fc64526cf1e935d74b201eb24a71bd1204f0a1a0e6b3c7cef05257d
3
+ metadata.gz: 0a0b80fe04a11716e39db70f0b64264f2eccecd150a4095307c0d108ef1b6f2b
4
+ data.tar.gz: b04f6e945ece9bf18bcd4956844d47675e460f23c35c52132813e43195da4fbf
5
5
  SHA512:
6
- metadata.gz: 18e36296b55e061e6a093b2726006a4b860f0815630d5401a95ced5b5054825db13b014638795df4963c8ae797b81d8933f1958b71296883967279c43e1a39ab
7
- data.tar.gz: 5e04f12177cd156b327ff86fbb7b0df7887043616b96d544c8412e2a44f66c2de6fe45e80f8603a758eaaebaef733315e3d357ae6c2d966cca3e6db41f93ef37
6
+ metadata.gz: a94bac4d8de2cfc1b661368bed8edb2f90ebb3f8ccf7f285018535112d8d0da3d06a43d75af73bbd8c3840e6e583b9708a94fd0ddd157c1873e7e206d627e989
7
+ data.tar.gz: fa4e9afe18caae22b987a84b87626a46529fd27eb12e64b3d4cebc269efa10090c7e14a45f6a640292d1320aac1fc9217ef4a8759b2bbd345e5648b7d11006ef
data/CHANGELOG.md CHANGED
@@ -3,6 +3,9 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## [0.3.3] - 2022-01-04
7
+ - [#9](https://github.com/boltops-tools/terraspace_provider_google/pull/9) google_secret support expansion automatically
8
+
6
9
  ## [0.3.2] - 2021-11-25
7
10
  - [#8](https://github.com/boltops-tools/terraspace_provider_google/pull/8) update example templates to include bucket location which is now required
8
11
 
@@ -4,9 +4,10 @@ module TerraspacePluginGoogle::Interfaces::Helper
4
4
  class Secret
5
5
  include TerraspacePluginGoogle::Clients
6
6
  include TerraspacePluginGoogle::Logging
7
+ extend Memoist
7
8
 
8
- def initialize(options={})
9
- @options = options
9
+ def initialize(mod, options={})
10
+ @mod, @options = mod, options
10
11
  @base64 = options[:base64]
11
12
  @project_id = options[:google_project] || ENV['GOOGLE_PROJECT'] || raise("GOOGLE_PROJECT env variable is not set. It's required.")
12
13
  end
@@ -18,6 +19,7 @@ module TerraspacePluginGoogle::Interfaces::Helper
18
19
  end
19
20
 
20
21
  def fetch_value(short_name, version="latest")
22
+ short_name = expansion(short_name) if expand?
21
23
  name = "projects/#{project_number}/secrets/#{short_name}/versions/#{version}"
22
24
  version = secret_manager_service.access_secret_version(name: name)
23
25
  version.payload.data
@@ -25,6 +27,10 @@ module TerraspacePluginGoogle::Interfaces::Helper
25
27
  logger.info "WARN: secret #{name} not found".color(:yellow)
26
28
  logger.info e.message
27
29
  "NOT FOUND #{name}" # simple string so Kubernetes YAML is valid
30
+ rescue Google::Cloud::InvalidArgumentError => e
31
+ logger.info "WARN: secret #{name} not found".color(:yellow)
32
+ logger.info e.message
33
+ "NOT FOUND #{name}" # simple string so Kubernetes YAML is valid
28
34
  end
29
35
 
30
36
  private
@@ -34,5 +40,15 @@ module TerraspacePluginGoogle::Interfaces::Helper
34
40
  project = resource_manager.project(@project_id)
35
41
  @@project_number = project.project_number
36
42
  end
43
+
44
+ delegate :expansion, to: :expander
45
+ def expander
46
+ TerraspacePluginGoogle::Interfaces::Expander.new(@mod)
47
+ end
48
+ memoize :expander
49
+
50
+ def expand?
51
+ !(@options[:expansion] == false || @options[:expand] == false)
52
+ end
37
53
  end
38
54
  end
@@ -3,7 +3,7 @@ module TerraspacePluginGoogle::Interfaces
3
3
  include Terraspace::Plugin::Helper::Interface
4
4
 
5
5
  def google_secret(name, options={})
6
- Secret.new(options).fetch(name)
6
+ Secret.new(@mod, options).fetch(name)
7
7
  end
8
8
  cache_helper :google_secret
9
9
  end
@@ -1,3 +1,3 @@
1
1
  module TerraspacePluginGoogle
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terraspace_plugin_google
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-25 00:00:00.000000000 Z
11
+ date: 2022-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gcp_data
@@ -169,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
169
  - !ruby/object:Gem::Version
170
170
  version: '0'
171
171
  requirements: []
172
- rubygems_version: 3.1.6
172
+ rubygems_version: 3.2.32
173
173
  signing_key:
174
174
  specification_version: 4
175
175
  summary: Terraspace Google Cloud Plugin