terraspace_plugin_google 0.2.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/lib/templates/hcl/module/main.tf +1 -0
- data/lib/templates/hcl/module/variables.tf +6 -0
- data/lib/templates/hcl/project/config/terraform/backend.tf.tt +2 -2
- 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 +12 -0
- data/lib/terraspace_plugin_google/interfaces/helper/secret.rb +54 -0
- data/lib/terraspace_plugin_google/interfaces/helper.rb +10 -0
- data/lib/terraspace_plugin_google/logging.rb +7 -0
- data/lib/terraspace_plugin_google/version.rb +1 -1
- data/lib/terraspace_plugin_google.rb +10 -0
- data/terraspace_plugin_google.gemspec +2 -0
- metadata +34 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a0b80fe04a11716e39db70f0b64264f2eccecd150a4095307c0d108ef1b6f2b
|
4
|
+
data.tar.gz: b04f6e945ece9bf18bcd4956844d47675e460f23c35c52132813e43195da4fbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a94bac4d8de2cfc1b661368bed8edb2f90ebb3f8ccf7f285018535112d8d0da3d06a43d75af73bbd8c3840e6e583b9708a94fd0ddd157c1873e7e206d627e989
|
7
|
+
data.tar.gz: fa4e9afe18caae22b987a84b87626a46529fd27eb12e64b3d4cebc269efa10090c7e14a45f6a640292d1320aac1fc9217ef4a8759b2bbd345e5648b7d11006ef
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,19 @@
|
|
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
|
+
|
9
|
+
## [0.3.2] - 2021-11-25
|
10
|
+
- [#8](https://github.com/boltops-tools/terraspace_provider_google/pull/8) update example templates to include bucket location which is now required
|
11
|
+
|
12
|
+
## [0.3.1] - 2021-11-13
|
13
|
+
- [#7](https://github.com/boltops-tools/terraspace_provider_google/pull/7) get google project number via api
|
14
|
+
|
15
|
+
## [0.3.0] - 2020-11-15
|
16
|
+
- [#5](https://github.com/boltops-tools/terraspace_provider_google/pull/5) helper and secrets support
|
17
|
+
- google secret
|
18
|
+
|
6
19
|
## [0.2.2]
|
7
20
|
- #4 fix test template: folder rename to stacks
|
8
21
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
terraform {
|
2
2
|
backend "gcs" {
|
3
|
-
bucket = "<%%= expansion('terraform-state-:PROJECT-:REGION-:ENV') %>"
|
4
|
-
prefix = "<%%= expansion(':REGION/:ENV/:BUILD_DIR') %>"
|
3
|
+
bucket = "<%%= expansion('terraform-state-:PROJECT-:REGION-:ENV') %>"
|
4
|
+
prefix = "<%%= expansion(':REGION/:ENV/:BUILD_DIR') %>"
|
5
5
|
}
|
6
6
|
}
|
@@ -1,12 +1,24 @@
|
|
1
|
+
require "google-cloud-resource_manager"
|
2
|
+
require "google-cloud-secret_manager"
|
1
3
|
require "google/cloud/storage"
|
2
4
|
|
3
5
|
module TerraspacePluginGoogle
|
4
6
|
module Clients
|
5
7
|
extend Memoist
|
6
8
|
|
9
|
+
def secret_manager_service
|
10
|
+
Google::Cloud::SecretManager.secret_manager_service
|
11
|
+
end
|
12
|
+
memoize :secret_manager_service
|
13
|
+
|
7
14
|
def storage
|
8
15
|
Google::Cloud::Storage.new
|
9
16
|
end
|
10
17
|
memoize :storage
|
18
|
+
|
19
|
+
def resource_manager
|
20
|
+
Google::Cloud.new.resource_manager
|
21
|
+
end
|
22
|
+
memoize :resource_manager
|
11
23
|
end
|
12
24
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require "base64"
|
2
|
+
|
3
|
+
module TerraspacePluginGoogle::Interfaces::Helper
|
4
|
+
class Secret
|
5
|
+
include TerraspacePluginGoogle::Clients
|
6
|
+
include TerraspacePluginGoogle::Logging
|
7
|
+
extend Memoist
|
8
|
+
|
9
|
+
def initialize(mod, options={})
|
10
|
+
@mod, @options = mod, options
|
11
|
+
@base64 = options[:base64]
|
12
|
+
@project_id = options[:google_project] || ENV['GOOGLE_PROJECT'] || raise("GOOGLE_PROJECT env variable is not set. It's required.")
|
13
|
+
end
|
14
|
+
|
15
|
+
def fetch(short_name, version: "latest")
|
16
|
+
value = fetch_value(short_name, version)
|
17
|
+
value = Base64.strict_encode64(value).strip if @base64
|
18
|
+
value
|
19
|
+
end
|
20
|
+
|
21
|
+
def fetch_value(short_name, version="latest")
|
22
|
+
short_name = expansion(short_name) if expand?
|
23
|
+
name = "projects/#{project_number}/secrets/#{short_name}/versions/#{version}"
|
24
|
+
version = secret_manager_service.access_secret_version(name: name)
|
25
|
+
version.payload.data
|
26
|
+
rescue Google::Cloud::NotFoundError => e
|
27
|
+
logger.info "WARN: secret #{name} not found".color(:yellow)
|
28
|
+
logger.info e.message
|
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
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
@@project_number = nil
|
38
|
+
def project_number
|
39
|
+
return @@project_number if @@project_number
|
40
|
+
project = resource_manager.project(@project_id)
|
41
|
+
@@project_number = project.project_number
|
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
|
53
|
+
end
|
54
|
+
end
|
@@ -22,12 +22,22 @@ module TerraspacePluginGoogle
|
|
22
22
|
Interfaces::Config.instance.config
|
23
23
|
end
|
24
24
|
|
25
|
+
@@logger = nil
|
26
|
+
def logger
|
27
|
+
@@logger ||= Terraspace.logger
|
28
|
+
end
|
29
|
+
|
30
|
+
def logger=(v)
|
31
|
+
@@logger = v
|
32
|
+
end
|
33
|
+
|
25
34
|
extend self
|
26
35
|
end
|
27
36
|
|
28
37
|
Terraspace::Plugin.register("google",
|
29
38
|
backend: "gcs",
|
30
39
|
config_class: TerraspacePluginGoogle::Interfaces::Config,
|
40
|
+
helper_class: TerraspacePluginGoogle::Interfaces::Helper,
|
31
41
|
layer_class: TerraspacePluginGoogle::Interfaces::Layer,
|
32
42
|
root: File.dirname(__dir__),
|
33
43
|
)
|
@@ -24,6 +24,8 @@ 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"
|
28
|
+
spec.add_dependency "google-cloud-secret_manager"
|
27
29
|
spec.add_dependency "memoist"
|
28
30
|
spec.add_dependency "zeitwerk"
|
29
31
|
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.
|
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:
|
11
|
+
date: 2022-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gcp_data
|
@@ -38,6 +38,34 @@ 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'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: google-cloud-secret_manager
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: memoist
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,8 +142,11 @@ files:
|
|
114
142
|
- lib/terraspace_plugin_google/interfaces/backend.rb
|
115
143
|
- lib/terraspace_plugin_google/interfaces/config.rb
|
116
144
|
- lib/terraspace_plugin_google/interfaces/expander.rb
|
145
|
+
- lib/terraspace_plugin_google/interfaces/helper.rb
|
146
|
+
- lib/terraspace_plugin_google/interfaces/helper/secret.rb
|
117
147
|
- lib/terraspace_plugin_google/interfaces/layer.rb
|
118
148
|
- lib/terraspace_plugin_google/interfaces/summary.rb
|
149
|
+
- lib/terraspace_plugin_google/logging.rb
|
119
150
|
- lib/terraspace_plugin_google/version.rb
|
120
151
|
- terraspace_plugin_google.gemspec
|
121
152
|
homepage: https://github.com/boltops-tools/terraspace_plugin_google
|
@@ -138,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
169
|
- !ruby/object:Gem::Version
|
139
170
|
version: '0'
|
140
171
|
requirements: []
|
141
|
-
rubygems_version: 3.
|
172
|
+
rubygems_version: 3.2.32
|
142
173
|
signing_key:
|
143
174
|
specification_version: 4
|
144
175
|
summary: Terraspace Google Cloud Plugin
|