terraspace_plugin_google 0.3.1 → 0.3.5

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: 628fdc35ca018bb08c245ade973b52cb1791ae4cae8858dac9cc787312c81be6
4
- data.tar.gz: 73c858a9d4452668896b68c58aa51f0b23f6dcbb5d2f07cce9c3df1b4273cebb
3
+ metadata.gz: 8d49aa4dec651de8b67872942c9f237b38e123263985f6d6d18151b46ffe14b5
4
+ data.tar.gz: '04508bd3f5f2336e0d2bf3cb99943809961e0d5807eef3afbdbf311e769540ee'
5
5
  SHA512:
6
- metadata.gz: a157213a221b74251896316d3bd879496e25a68dced1d44a294958e51c0ba3e830959fe07cd869f115cd73ea220660a20128484349c3328eadd87bbd2ca2ed5e
7
- data.tar.gz: 24297c26f98c24ad85f689fc82c1e14acf64583e909da9b566524bd263b0e48cdb8fd6281753702dbc5595f010fddb47578f8432530e91af78ec30fa1324a1c7
6
+ metadata.gz: 5fb9e68077f452fdbb96d00ebdcaac6b67bed251752c4c388be97cfb9e48568f48d73b4a02ee7d1293e3872bbbbc7d4e400bbfa2135c88a5b54f3b9a90eb6c99
7
+ data.tar.gz: da5a5b2f44d20182d9ea0916f144f8b0703b2f4d774bbc9658af8078ccf802cd0251eaf4f7515b46c4f3974af1eb4b297135ff5b671171769996e36e1d52ca3b
data/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
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.5] - 2022-01-11
7
+ - [#11](https://github.com/boltops-tools/terraspace_provider_google/pull/11) set GOOGLE_CLOUD_PROJECT while keeping backwards compatibility
8
+
9
+ ## [0.3.4] - 2022-01-11
10
+ - [#10](https://github.com/boltops-tools/terraspace_provider_google/pull/10) set GOOGLE_CLOUD_PROJECT while keeping backwards compatibility
11
+
12
+ ## [0.3.3] - 2022-01-04
13
+ - [#9](https://github.com/boltops-tools/terraspace_provider_google/pull/9) google_secret support expansion automatically
14
+
15
+ ## [0.3.2] - 2021-11-25
16
+ - [#8](https://github.com/boltops-tools/terraspace_provider_google/pull/8) update example templates to include bucket location which is now required
17
+
6
18
  ## [0.3.1] - 2021-11-13
7
19
  - [#7](https://github.com/boltops-tools/terraspace_provider_google/pull/7) get google project number via api
8
20
 
@@ -1,4 +1,5 @@
1
1
  resource "google_storage_bucket" "this" {
2
2
  name = var.name
3
3
  uniform_bucket_level_access = var.uniform_bucket_level_access
4
+ location = var.location
4
5
  }
@@ -8,3 +8,9 @@ variable "uniform_bucket_level_access" {
8
8
  type = bool
9
9
  default = false
10
10
  }
11
+
12
+ variable "location" {
13
+ description = "location"
14
+ type = string
15
+ default = "US"
16
+ }
@@ -7,4 +7,5 @@ module "bucket" {
7
7
 
8
8
  name = "bucket-${random_pet.this.id}"
9
9
  uniform_bucket_level_access = var.uniform_bucket_level_access
10
+ location = var.location
10
11
  }
@@ -3,3 +3,9 @@ variable "uniform_bucket_level_access" {
3
3
  type = bool
4
4
  default = false
5
5
  }
6
+
7
+ variable "location" {
8
+ description = "location"
9
+ type = string
10
+ default = "US"
11
+ }
@@ -6,6 +6,17 @@ module TerraspacePluginGoogle
6
6
  module Clients
7
7
  extend Memoist
8
8
 
9
+ def initialize(*)
10
+ # So google sdk newer versions use GOOGLE_CLOUD_PROJECT instead of GOOGLE_PROJECT
11
+ # Found out between google-cloud-storage-1.35.0 and google-cloud-storage-1.28.0
12
+ # Though it seems like an library underneath that with the change.
13
+ # Keeping backwards compatibility to not create breakage users who already have GOOGLE_PROJECT
14
+ # But then setting GOOGLE_CLOUD_PROJECT so it works with the SDK.
15
+ # For users, who set GOOGLE_CLOUD_PROJECT that will work also.
16
+ ENV['GOOGLE_CLOUD_PROJECT'] ||= ENV['GOOGLE_PROJECT']
17
+ super
18
+ end
19
+
9
20
  def secret_manager_service
10
21
  Google::Cloud::SecretManager.secret_manager_service
11
22
  end
@@ -4,11 +4,19 @@ 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
- @project_id = options[:google_project] || ENV['GOOGLE_PROJECT'] || raise("GOOGLE_PROJECT env variable is not set. It's required.")
12
+ @project_id = options[:google_project] || ENV['GOOGLE_CLOUD_PROJECT'] || ENV['GOOGLE_PROJECT'] || raise("GOOGLE_PROJECT env variable is not set. It's required.")
13
+ # So google sdk newer versions use GOOGLE_CLOUD_PROJECT instead of GOOGLE_PROJECT
14
+ # Found out between google-cloud-storage-1.35.0 and google-cloud-storage-1.28.0
15
+ # Though it seems like an library underneath that with the change.
16
+ # Keeping backwards compatibility to not create breakage users who already have GOOGLE_PROJECT
17
+ # But then setting GOOGLE_CLOUD_PROJECT so it works with the SDK.
18
+ # For users, who set GOOGLE_CLOUD_PROJECT that will work also.
19
+ ENV['GOOGLE_CLOUD_PROJECT'] ||= @project_id
12
20
  end
13
21
 
14
22
  def fetch(short_name, version: "latest")
@@ -18,6 +26,7 @@ module TerraspacePluginGoogle::Interfaces::Helper
18
26
  end
19
27
 
20
28
  def fetch_value(short_name, version="latest")
29
+ short_name = expansion(short_name) if expand?
21
30
  name = "projects/#{project_number}/secrets/#{short_name}/versions/#{version}"
22
31
  version = secret_manager_service.access_secret_version(name: name)
23
32
  version.payload.data
@@ -25,6 +34,10 @@ module TerraspacePluginGoogle::Interfaces::Helper
25
34
  logger.info "WARN: secret #{name} not found".color(:yellow)
26
35
  logger.info e.message
27
36
  "NOT FOUND #{name}" # simple string so Kubernetes YAML is valid
37
+ rescue Google::Cloud::InvalidArgumentError => e
38
+ logger.info "WARN: secret #{name} not found".color(:yellow)
39
+ logger.info e.message
40
+ "NOT FOUND #{name}" # simple string so Kubernetes YAML is valid
28
41
  end
29
42
 
30
43
  private
@@ -34,5 +47,15 @@ module TerraspacePluginGoogle::Interfaces::Helper
34
47
  project = resource_manager.project(@project_id)
35
48
  @@project_number = project.project_number
36
49
  end
50
+
51
+ delegate :expansion, to: :expander
52
+ def expander
53
+ TerraspacePluginGoogle::Interfaces::Expander.new(@mod)
54
+ end
55
+ memoize :expander
56
+
57
+ def expand?
58
+ !(@options[:expansion] == false || @options[:expand] == false)
59
+ end
37
60
  end
38
61
  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.1"
2
+ VERSION = "0.3.5"
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.1
4
+ version: 0.3.5
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-13 00:00:00.000000000 Z
11
+ date: 2022-01-11 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