terraspace_plugin_google 0.3.0 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/templates/hcl/module/main.tf +1 -0
- data/lib/templates/hcl/module/variables.tf +6 -0
- data/lib/templates/hcl/stack/main.tf +1 -0
- data/lib/templates/hcl/stack/variables.tf +6 -0
- data/lib/terraspace_plugin_google/clients.rb +6 -0
- data/lib/terraspace_plugin_google/interfaces/helper/secret.rb +28 -10
- data/lib/terraspace_plugin_google/interfaces/helper.rb +1 -1
- data/lib/terraspace_plugin_google/version.rb +1 -1
- data/terraspace_plugin_google.gemspec +1 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f70f3d2b05883b51424fcf33c4054ec87245a6194907501ece79d203d4004752
|
4
|
+
data.tar.gz: d98024a5205b2385d16761193ea367d302ba1cc2c57fef710f647cd3d49d2e54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11ec0a19248922068b38c68990477de03c8fcdd1c6bdc7eb9b8b583deb35a0a46a0f36c0319d7feb2fcf2913536b1e468d5c57c985c92cdfca7aba5379b6e16a
|
7
|
+
data.tar.gz: 30ea996f68cdd59da9902fd57dec0b89a643e272c5c04c7d9db407a9439aa5ef0c4ef89ae577ac0b9163b3aedb04df0d35debf3a7b43f4be63c719a69f09ede8
|
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.4] - 2022-01-11
|
7
|
+
- [#10](https://github.com/boltops-tools/terraspace_provider_google/pull/10) set GOOGLE_CLOUD_PROJECT while keeping backwards compatibility
|
8
|
+
|
9
|
+
## [0.3.3] - 2022-01-04
|
10
|
+
- [#9](https://github.com/boltops-tools/terraspace_provider_google/pull/9) google_secret support expansion automatically
|
11
|
+
|
12
|
+
## [0.3.2] - 2021-11-25
|
13
|
+
- [#8](https://github.com/boltops-tools/terraspace_provider_google/pull/8) update example templates to include bucket location which is now required
|
14
|
+
|
15
|
+
## [0.3.1] - 2021-11-13
|
16
|
+
- [#7](https://github.com/boltops-tools/terraspace_provider_google/pull/7) get google project number via api
|
17
|
+
|
6
18
|
## [0.3.0] - 2020-11-15
|
7
19
|
- [#5](https://github.com/boltops-tools/terraspace_provider_google/pull/5) helper and secrets support
|
8
20
|
- google secret
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "google-cloud-resource_manager"
|
1
2
|
require "google-cloud-secret_manager"
|
2
3
|
require "google/cloud/storage"
|
3
4
|
|
@@ -14,5 +15,10 @@ module TerraspacePluginGoogle
|
|
14
15
|
Google::Cloud::Storage.new
|
15
16
|
end
|
16
17
|
memoize :storage
|
18
|
+
|
19
|
+
def resource_manager
|
20
|
+
Google::Cloud.new.resource_manager
|
21
|
+
end
|
22
|
+
memoize :resource_manager
|
17
23
|
end
|
18
24
|
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,19 +34,28 @@ 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
|
-
|
31
|
-
# If someone knows, let me know.
|
32
|
-
# Right now grabbing the first secret to then be able to get the google project number
|
43
|
+
private
|
33
44
|
@@project_number = nil
|
34
45
|
def project_number
|
35
46
|
return @@project_number if @@project_number
|
47
|
+
project = resource_manager.project(@project_id)
|
48
|
+
@@project_number = project.project_number
|
49
|
+
end
|
50
|
+
|
51
|
+
delegate :expansion, to: :expander
|
52
|
+
def expander
|
53
|
+
TerraspacePluginGoogle::Interfaces::Expander.new(@mod)
|
54
|
+
end
|
55
|
+
memoize :expander
|
36
56
|
|
37
|
-
|
38
|
-
|
39
|
-
name = resp.first.name # IE: projects/111111111111/secrets/demo-dev-db_host
|
40
|
-
@@project_number = name.split('/')[1]
|
57
|
+
def expand?
|
58
|
+
!(@options[:expansion] == false || @options[:expand] == false)
|
41
59
|
end
|
42
60
|
end
|
43
61
|
end
|
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
|
25
25
|
spec.add_dependency "gcp_data"
|
26
26
|
spec.add_dependency "google-cloud-storage"
|
27
|
+
spec.add_dependency "google-cloud-resource_manager"
|
27
28
|
spec.add_dependency "google-cloud-secret_manager"
|
28
29
|
spec.add_dependency "memoist"
|
29
30
|
spec.add_dependency "zeitwerk"
|
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.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gcp_data
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: google-cloud-resource_manager
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: google-cloud-secret_manager
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -155,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
169
|
- !ruby/object:Gem::Version
|
156
170
|
version: '0'
|
157
171
|
requirements: []
|
158
|
-
rubygems_version: 3.
|
172
|
+
rubygems_version: 3.2.32
|
159
173
|
signing_key:
|
160
174
|
specification_version: 4
|
161
175
|
summary: Terraspace Google Cloud Plugin
|