ruby-terraform 0.51.0.pre.2 → 0.51.0.pre.3
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 +4 -4
- data/.circleci/config.yml +6 -6
- data/.ruby-version +1 -1
- data/Gemfile.lock +40 -9
- data/README.md +21 -20
- data/Rakefile +45 -116
- data/config/secrets/ci/ssh.private +49 -49
- data/config/secrets/ci/ssh.public +1 -14
- data/config/secrets/circle_ci/config.yaml +0 -2
- data/config/secrets/github/config.yaml +0 -1
- data/lib/ruby_terraform/commands/validate.rb +2 -0
- data/lib/ruby_terraform/version.rb +1 -1
- data/ruby_terraform.gemspec +4 -4
- metadata +16 -17
- data/rake/circleci.rb +0 -114
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b32c2fed8d63ca562c5ad4cbe2c18b00bbf19db4c4d5262bea6a290584772148
|
|
4
|
+
data.tar.gz: 11c94a94582af564921061abd45b3ec1c6f822e8b7bbb9be557866fa40cce1cc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 121d8804c41fa72ea5e183dda506a0474c4d168bd219e527a0489fd1ba8a2ff7e689865b46eb55eecbe41f96a07958fa2e27d932659661cd28974ebb2a1ca12e
|
|
7
|
+
data.tar.gz: de0297b0602f436d247aa9d48969bebc9d27c73119ad3699b8c58813976044c227d26a836f9feb57cd6c257f3c884e6efd476a4d0884c83b85462e90a37078b5
|
data/.circleci/config.yml
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
version: 2.1
|
|
2
2
|
jobs:
|
|
3
3
|
test:
|
|
4
|
-
working_directory: ~/
|
|
4
|
+
working_directory: ~/source
|
|
5
5
|
docker:
|
|
6
|
-
- image: ruby:2.
|
|
6
|
+
- image: ruby:2.6.0
|
|
7
7
|
steps:
|
|
8
8
|
- checkout
|
|
9
9
|
- run: ./scripts/ci/steps/test.sh
|
|
10
10
|
prerelease:
|
|
11
|
-
working_directory: ~/
|
|
11
|
+
working_directory: ~/source
|
|
12
12
|
docker:
|
|
13
|
-
- image: ruby:2.
|
|
13
|
+
- image: ruby:2.6.0
|
|
14
14
|
steps:
|
|
15
15
|
- checkout
|
|
16
16
|
- run: ./scripts/ci/common/install-git-crypt.sh
|
|
@@ -19,9 +19,9 @@ jobs:
|
|
|
19
19
|
- run: ./scripts/ci/common/configure-rubygems.sh
|
|
20
20
|
- run: ./scripts/ci/steps/prerelease.sh
|
|
21
21
|
release:
|
|
22
|
-
working_directory: ~/
|
|
22
|
+
working_directory: ~/source
|
|
23
23
|
docker:
|
|
24
|
-
- image: ruby:2.
|
|
24
|
+
- image: ruby:2.6.0
|
|
25
25
|
steps:
|
|
26
26
|
- checkout
|
|
27
27
|
- run: ./scripts/ci/common/install-git-crypt.sh
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
2.6.0
|
data/Gemfile.lock
CHANGED
|
@@ -1,39 +1,66 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
ruby-terraform (0.51.0.pre.
|
|
4
|
+
ruby-terraform (0.51.0.pre.3)
|
|
5
5
|
lino (~> 1.1)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
|
+
activesupport (6.0.2.2)
|
|
11
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
12
|
+
i18n (>= 0.7, < 2)
|
|
13
|
+
minitest (~> 5.1)
|
|
14
|
+
tzinfo (~> 1.1)
|
|
15
|
+
zeitwerk (~> 2.2)
|
|
10
16
|
addressable (2.7.0)
|
|
11
17
|
public_suffix (>= 2.0.2, < 5.0)
|
|
18
|
+
colored2 (3.1.2)
|
|
12
19
|
concurrent-ruby (1.1.6)
|
|
13
20
|
diff-lcs (1.3)
|
|
14
|
-
excon (0.
|
|
15
|
-
faraday (1.0.
|
|
21
|
+
excon (0.73.0)
|
|
22
|
+
faraday (1.0.1)
|
|
16
23
|
multipart-post (>= 1.2, < 3)
|
|
17
24
|
gem-release (2.1.1)
|
|
18
25
|
hamster (3.0.0)
|
|
19
26
|
concurrent-ruby (~> 1.0)
|
|
27
|
+
i18n (1.8.2)
|
|
28
|
+
concurrent-ruby (~> 1.0)
|
|
20
29
|
lino (1.1.0)
|
|
21
30
|
hamster (~> 3.0)
|
|
22
31
|
open4 (~> 1.3)
|
|
32
|
+
minitest (5.14.0)
|
|
23
33
|
multipart-post (2.1.1)
|
|
24
|
-
octokit (4.
|
|
34
|
+
octokit (4.18.0)
|
|
25
35
|
faraday (>= 0.9)
|
|
26
36
|
sawyer (~> 0.8.0, >= 0.5.3)
|
|
27
37
|
open4 (1.3.4)
|
|
28
|
-
public_suffix (4.0.
|
|
38
|
+
public_suffix (4.0.4)
|
|
29
39
|
rake (13.0.1)
|
|
40
|
+
rake_circle_ci (0.7.0)
|
|
41
|
+
colored2 (~> 3.1)
|
|
42
|
+
excon (~> 0.72)
|
|
43
|
+
rake_factory (~> 0.23)
|
|
44
|
+
sshkey (~> 2.0)
|
|
45
|
+
rake_factory (0.27.0)
|
|
46
|
+
activesupport (>= 4)
|
|
47
|
+
rake (~> 13.0)
|
|
48
|
+
rake_github (0.5.0)
|
|
49
|
+
colored2 (~> 3.1)
|
|
50
|
+
octokit (~> 4.16)
|
|
51
|
+
rake_factory (~> 0.23)
|
|
52
|
+
sshkey (~> 2.0)
|
|
53
|
+
rake_ssh (0.4.0)
|
|
54
|
+
colored2 (~> 3.1)
|
|
55
|
+
rake_factory (~> 0.23)
|
|
56
|
+
sshkey (~> 2.0)
|
|
30
57
|
rspec (3.9.0)
|
|
31
58
|
rspec-core (~> 3.9.0)
|
|
32
59
|
rspec-expectations (~> 3.9.0)
|
|
33
60
|
rspec-mocks (~> 3.9.0)
|
|
34
61
|
rspec-core (3.9.1)
|
|
35
62
|
rspec-support (~> 3.9.1)
|
|
36
|
-
rspec-expectations (3.9.
|
|
63
|
+
rspec-expectations (3.9.1)
|
|
37
64
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
38
65
|
rspec-support (~> 3.9.0)
|
|
39
66
|
rspec-mocks (3.9.1)
|
|
@@ -44,19 +71,23 @@ GEM
|
|
|
44
71
|
addressable (>= 2.3.5)
|
|
45
72
|
faraday (> 0.8, < 2.0)
|
|
46
73
|
sshkey (2.0.0)
|
|
74
|
+
thread_safe (0.3.6)
|
|
75
|
+
tzinfo (1.2.7)
|
|
76
|
+
thread_safe (~> 0.1)
|
|
77
|
+
zeitwerk (2.3.0)
|
|
47
78
|
|
|
48
79
|
PLATFORMS
|
|
49
80
|
ruby
|
|
50
81
|
|
|
51
82
|
DEPENDENCIES
|
|
52
83
|
bundler (~> 2.0)
|
|
53
|
-
excon (~> 0.72)
|
|
54
84
|
gem-release (~> 2.1)
|
|
55
|
-
octokit (~> 4.16)
|
|
56
85
|
rake (~> 13.0)
|
|
86
|
+
rake_circle_ci (~> 0.3)
|
|
87
|
+
rake_github (~> 0.3)
|
|
88
|
+
rake_ssh (~> 0.2)
|
|
57
89
|
rspec (~> 3.9)
|
|
58
90
|
ruby-terraform!
|
|
59
|
-
sshkey (~> 2.0)
|
|
60
91
|
|
|
61
92
|
BUNDLED WITH
|
|
62
93
|
2.1.4
|
data/README.md
CHANGED
|
@@ -78,12 +78,12 @@ RubyTerraform.init
|
|
|
78
78
|
RubyTerraform.init(from_module: 'some/module/path', path: 'infra/module')
|
|
79
79
|
RubyTerraform::Commands::Init.new.execute
|
|
80
80
|
RubyTerraform::Commands::Init.new.execute(
|
|
81
|
-
from_module: 'some/module/path',
|
|
81
|
+
from_module: 'some/module/path',
|
|
82
82
|
path: 'infra/module')
|
|
83
83
|
```
|
|
84
84
|
|
|
85
85
|
The init command supports the following options passed as keyword arguments:
|
|
86
|
-
* `from_module`: the source module to use to initialise; required if `path` is
|
|
86
|
+
* `from_module`: the source module to use to initialise; required if `path` is
|
|
87
87
|
specified
|
|
88
88
|
* `path`: the path to initialise.
|
|
89
89
|
* `backend`: `true`/`false`, whether or not to configure the backend.
|
|
@@ -145,7 +145,7 @@ The plan command supports the following options passed as keyword arguments:
|
|
|
145
145
|
* `state`: the path to the state file in which to store state; defaults to
|
|
146
146
|
terraform.tfstate in the working directory or the remote state if configured.
|
|
147
147
|
* `plan`: the name of the file in which to save the generated plan.
|
|
148
|
-
* `input`: when `false`, will not ask for input for variables not directly set;
|
|
148
|
+
* `input`: when `false`, will not ask for input for variables not directly set;
|
|
149
149
|
defaults to `true`.
|
|
150
150
|
* `destroy`: when `true`, a plan will be generated to destroy all resources
|
|
151
151
|
managed by the given configuration and state; defaults to `false`.
|
|
@@ -185,18 +185,18 @@ The apply command supports the following options passed as keyword arguments:
|
|
|
185
185
|
* `state`: the path to the state file in which to store state; defaults to
|
|
186
186
|
terraform.tfstate in the working directory or the remote state if configured.
|
|
187
187
|
* `backup`: the path to the backup file in which to store the state backup.
|
|
188
|
-
* `input`: when `false`, will not ask for input for variables not directly set;
|
|
188
|
+
* `input`: when `false`, will not ask for input for variables not directly set;
|
|
189
189
|
defaults to `true`.
|
|
190
190
|
* `no_backup`: when `true`, no backup file will be written; defaults to `false`.
|
|
191
191
|
* `no_color`: whether or not the output from the command should be in color;
|
|
192
192
|
defaults to `false`.
|
|
193
|
-
* `auto_approve`: if `true`, the command applys without prompting the user to
|
|
193
|
+
* `auto_approve`: if `true`, the command applys without prompting the user to
|
|
194
194
|
confirm the changes; defaults to `false`.
|
|
195
195
|
|
|
196
196
|
|
|
197
197
|
### RubyTerraform::Commands::Show
|
|
198
198
|
|
|
199
|
-
The show command produces human-readable output from a state file or a plan
|
|
199
|
+
The show command produces human-readable output from a state file or a plan
|
|
200
200
|
file. It can be called in the following ways:
|
|
201
201
|
|
|
202
202
|
```ruby
|
|
@@ -210,7 +210,7 @@ The show command supports the following options passed as keyword arguments:
|
|
|
210
210
|
* `path`: the path to a state or plan file; required.
|
|
211
211
|
* `no_color`: whether or not the output from the command should be in color;
|
|
212
212
|
defaults to `false`.
|
|
213
|
-
* `module_depth`: the depth of modules to show in the output; defaults to
|
|
213
|
+
* `module_depth`: the depth of modules to show in the output; defaults to
|
|
214
214
|
showing all modules.
|
|
215
215
|
* `json`: whether or not the output from the command should be in json format;
|
|
216
216
|
defaults to `false`.
|
|
@@ -305,7 +305,7 @@ The refresh command supports the following options passed as keyword arguments:
|
|
|
305
305
|
`targets` are provided, all targets will be passed to terraform.
|
|
306
306
|
* `state`: the path to the state file in which to store state; defaults to
|
|
307
307
|
terraform.tfstate in the working directory or the remote state if configured.
|
|
308
|
-
* `input`: when `false`, will not ask for input for variables not directly set;
|
|
308
|
+
* `input`: when `false`, will not ask for input for variables not directly set;
|
|
309
309
|
defaults to `true`.
|
|
310
310
|
* `no_color`: whether or not the output from the command should be in color;
|
|
311
311
|
defaults to `false`.
|
|
@@ -314,7 +314,7 @@ The refresh command supports the following options passed as keyword arguments:
|
|
|
314
314
|
### RubyTerraform::Commands::RemoteConfig
|
|
315
315
|
|
|
316
316
|
The remote config command configures storage of state using a remote backend. It
|
|
317
|
-
has been deprecated and since removed from terraform but is retained in this
|
|
317
|
+
has been deprecated and since removed from terraform but is retained in this
|
|
318
318
|
library for backwards compatibility. It can be called in the following ways:
|
|
319
319
|
|
|
320
320
|
```ruby
|
|
@@ -372,12 +372,13 @@ The validate command supports the following options passed as keyword arguments:
|
|
|
372
372
|
defaults to `false`.
|
|
373
373
|
* `check_variables`: if `true`, the command checks whether all variables have
|
|
374
374
|
been provided; defaults to `true`.
|
|
375
|
-
|
|
375
|
+
* `json`: whether or not the output from the command should be in json format;
|
|
376
|
+
defaults to `false`.
|
|
376
377
|
|
|
377
378
|
### RubyTerraform::Commands::Workspace
|
|
378
379
|
|
|
379
|
-
The `workspace` command configures
|
|
380
|
-
[Terraform Workspaces](https://www.terraform.io/docs/state/workspaces.html#using-workspaces).
|
|
380
|
+
The `workspace` command configures
|
|
381
|
+
[Terraform Workspaces](https://www.terraform.io/docs/state/workspaces.html#using-workspaces).
|
|
381
382
|
It can be used as follows:
|
|
382
383
|
|
|
383
384
|
```ruby
|
|
@@ -390,7 +391,7 @@ RubyTerraform.workspace(operation: 'delete', workspace: 'staging')
|
|
|
390
391
|
```
|
|
391
392
|
|
|
392
393
|
arguments:
|
|
393
|
-
* `directory`: the directory containing terraform configuration, the default is
|
|
394
|
+
* `directory`: the directory containing terraform configuration, the default is
|
|
394
395
|
the current path.
|
|
395
396
|
* `operation`: `list`, `select`, `new` or `delete`. default `list`.
|
|
396
397
|
* `workspace`: Workspace name.
|
|
@@ -398,10 +399,10 @@ arguments:
|
|
|
398
399
|
|
|
399
400
|
## Configuration
|
|
400
401
|
|
|
401
|
-
In addition to configuring the location of the terraform binary, RubyTerraform
|
|
402
|
+
In addition to configuring the location of the terraform binary, RubyTerraform
|
|
402
403
|
offers configuration of logging and standard streams. By default standard
|
|
403
|
-
streams map to `$stdin`, `$stdout` and `$stderr` and all logging goes to
|
|
404
|
-
`$stdout`.
|
|
404
|
+
streams map to `$stdin`, `$stdout` and `$stderr` and all logging goes to
|
|
405
|
+
`$stdout`.
|
|
405
406
|
|
|
406
407
|
### Logging
|
|
407
408
|
|
|
@@ -420,7 +421,7 @@ RubyTerraform.configure do |config|
|
|
|
420
421
|
end
|
|
421
422
|
```
|
|
422
423
|
|
|
423
|
-
RubyTerraform supports logging to multiple different outputs at once,
|
|
424
|
+
RubyTerraform supports logging to multiple different outputs at once,
|
|
424
425
|
for example:
|
|
425
426
|
|
|
426
427
|
``` ruby
|
|
@@ -436,7 +437,7 @@ RubyTerraform.configure do |config|
|
|
|
436
437
|
end
|
|
437
438
|
```
|
|
438
439
|
|
|
439
|
-
Configured in this way, any logging performed by RubyTerraform will log to both
|
|
440
|
+
Configured in this way, any logging performed by RubyTerraform will log to both
|
|
440
441
|
`STDOUT` and the provided `log_file`.
|
|
441
442
|
|
|
442
443
|
### Standard Streams
|
|
@@ -466,9 +467,9 @@ input = StringIO.new("user\ninput\n")
|
|
|
466
467
|
RubyTerraform.configure do |config|
|
|
467
468
|
config.stdin = input
|
|
468
469
|
end
|
|
469
|
-
```
|
|
470
|
+
```
|
|
470
471
|
|
|
471
|
-
In this way, terraform can be driven by input from somewhere other than
|
|
472
|
+
In this way, terraform can be driven by input from somewhere other than
|
|
472
473
|
interactive input from the terminal.
|
|
473
474
|
|
|
474
475
|
|
data/Rakefile
CHANGED
|
@@ -1,132 +1,61 @@
|
|
|
1
|
-
require '
|
|
2
|
-
require '
|
|
1
|
+
require 'yaml'
|
|
2
|
+
require 'rake_circle_ci'
|
|
3
|
+
require 'rake_github'
|
|
4
|
+
require 'rake_ssh'
|
|
3
5
|
require 'rspec/core/rake_task'
|
|
4
6
|
|
|
5
|
-
require_relative 'rake/circleci'
|
|
6
|
-
|
|
7
|
-
RSpec::Core::RakeTask.new(:spec)
|
|
8
|
-
|
|
9
7
|
task :default => :spec
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
desc "Generate a new SSH key for CI"
|
|
13
|
-
task :generate do
|
|
14
|
-
print "Generating a new SSH key... "
|
|
15
|
-
key = SSHKey.generate(
|
|
16
|
-
type: "RSA",
|
|
17
|
-
bits: 4096,
|
|
18
|
-
comment: "maintainers@infrablocks.io")
|
|
19
|
-
File.write('config/secrets/ci/ssh.private', key.private_key)
|
|
20
|
-
File.write('config/secrets/ci/ssh.public', key.public_key)
|
|
21
|
-
puts "Done."
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
namespace :circle_ci do
|
|
26
|
-
circle_ci_config_path = 'config/secrets/circle_ci/config.yaml'
|
|
27
|
-
|
|
28
|
-
namespace :env_vars do
|
|
29
|
-
desc "Destroy all environment variables from the CircleCI pipeline"
|
|
30
|
-
task :destroy do
|
|
31
|
-
print "Deleting all environment variables from pipeline... "
|
|
32
|
-
circle_ci = CircleCI.new(circle_ci_config_path)
|
|
33
|
-
circle_ci.delete_env_vars
|
|
34
|
-
puts "Done."
|
|
35
|
-
end
|
|
9
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
36
10
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
11
|
+
RakeSSH.define_key_tasks(
|
|
12
|
+
namespace: :deploy_key,
|
|
13
|
+
path: 'config/secrets/ci/',
|
|
14
|
+
comment: 'maintainers@infrablocks.io'
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
RakeCircleCI.define_project_tasks(
|
|
18
|
+
namespace: :circle_ci,
|
|
19
|
+
project_slug: 'github/infrablocks/ruby_terraform'
|
|
20
|
+
) do |t|
|
|
21
|
+
circle_ci_config =
|
|
22
|
+
YAML.load_file('config/secrets/circle_ci/config.yaml')
|
|
23
|
+
|
|
24
|
+
t.api_token = circle_ci_config["circle_ci_api_token"]
|
|
25
|
+
t.environment_variables = {
|
|
26
|
+
ENCRYPTION_PASSPHRASE:
|
|
27
|
+
File.read('config/secrets/ci/encryption.passphrase')
|
|
28
|
+
.chomp
|
|
29
|
+
}
|
|
30
|
+
t.ssh_keys = [
|
|
31
|
+
{
|
|
32
|
+
hostname: "github.com",
|
|
33
|
+
private_key: File.read('config/secrets/ci/ssh.private')
|
|
43
34
|
}
|
|
44
|
-
|
|
45
|
-
circle_ci = CircleCI.new(circle_ci_config_path)
|
|
46
|
-
env_vars.each do |name, value|
|
|
47
|
-
print "Creating environment variable: #{name}... "
|
|
48
|
-
circle_ci.create_env_var(name, value)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
puts "Done."
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
desc "Ensure all environment variables are configured on the CircleCI " +
|
|
55
|
-
"pipeline"
|
|
56
|
-
task :ensure => [:'destroy', :'provision']
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
namespace :ssh_key do
|
|
60
|
-
desc "Destroy SSH key from the CircleCI pipeline"
|
|
61
|
-
task :destroy do
|
|
62
|
-
print "Destroying SSH key in the pipeline... "
|
|
63
|
-
circle_ci = CircleCI.new(circle_ci_config_path)
|
|
64
|
-
circle_ci.delete_ssh_keys
|
|
65
|
-
puts "Done."
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
desc "Provision SSH key to the CircleCI pipeline"
|
|
69
|
-
task :provision do
|
|
70
|
-
print "Creating SSH key in the pipeline... "
|
|
71
|
-
circle_ci = CircleCI.new(circle_ci_config_path)
|
|
72
|
-
circle_ci.create_ssh_key(
|
|
73
|
-
SSHKey.new(
|
|
74
|
-
File.read('config/secrets/ci/ssh.private'),
|
|
75
|
-
comment: 'github.com'))
|
|
76
|
-
puts "Done."
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
desc "Ensure SSH key is configured on the CircleCI pipeline"
|
|
80
|
-
task :ensure => [:'destroy', :'provision']
|
|
81
|
-
end
|
|
35
|
+
]
|
|
82
36
|
end
|
|
83
37
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
end
|
|
99
|
-
puts "Done."
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
desc "Add deploy key to the Github repository"
|
|
103
|
-
task :provision do
|
|
104
|
-
print "Adding deploy key to the Github repository... "
|
|
105
|
-
config = YAML.load_file('config/secrets/github/config.yaml')
|
|
106
|
-
access_token = config["github_personal_access_token"]
|
|
107
|
-
repo = config["github_repository"]
|
|
108
|
-
client = Octokit::Client.new(access_token: access_token)
|
|
109
|
-
|
|
110
|
-
ssh_key = SSHKey.new(
|
|
111
|
-
File.read('config/secrets/ci/ssh.private'),
|
|
112
|
-
comment: 'CircleCI')
|
|
113
|
-
client.add_deploy_key(repo,
|
|
114
|
-
ssh_key.comment,
|
|
115
|
-
ssh_key.ssh_public_key,
|
|
116
|
-
read_only: false)
|
|
117
|
-
puts "Done."
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
desc "Ensure deploy key is configured on the Github repository"
|
|
121
|
-
task :ensure => [:'destroy', :'provision']
|
|
122
|
-
end
|
|
38
|
+
RakeGithub.define_repository_tasks(
|
|
39
|
+
namespace: :github,
|
|
40
|
+
repository: 'infrablocks/ruby_terraform',
|
|
41
|
+
) do |t|
|
|
42
|
+
github_config =
|
|
43
|
+
YAML.load_file('config/secrets/github/config.yaml')
|
|
44
|
+
|
|
45
|
+
t.access_token = github_config["github_personal_access_token"]
|
|
46
|
+
t.deploy_keys = [
|
|
47
|
+
{
|
|
48
|
+
title: 'CircleCI',
|
|
49
|
+
public_key: File.read('config/secrets/ci/ssh.public')
|
|
50
|
+
}
|
|
51
|
+
]
|
|
123
52
|
end
|
|
124
53
|
|
|
125
54
|
namespace :pipeline do
|
|
126
55
|
task :prepare => [
|
|
127
56
|
:'circle_ci:env_vars:ensure',
|
|
128
|
-
:'circle_ci:
|
|
129
|
-
:'github:
|
|
57
|
+
:'circle_ci:ssh_keys:ensure',
|
|
58
|
+
:'github:deploy_keys:ensure'
|
|
130
59
|
]
|
|
131
60
|
end
|
|
132
61
|
|
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
-----BEGIN RSA PRIVATE KEY-----
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
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J0l71oyRSPjWqhmvYc4doQduJidoLqrLjUWglwkDfwnJ96daHGF3eNsbRHglDcn7AGdCgCxNcrOx+gqeJSTdWEOYiQ0taffoSidZZKcVjIJhtd4V8fxNZUalcsA17yjiVZujMIs0Wj+LUrj+96yO7BSHXrBV7p33dMzALnvgVHdPT6nFLiRqTBUuCZ8tUR/MIeVi9jJlHFNJxSWhOi7PtztVrrR78W8YgUrl4PvM5Efc5MqoR1oJef339w== maintainers@infrablocks.io
|
|
@@ -12,6 +12,7 @@ module RubyTerraform
|
|
|
12
12
|
state = opts[:state]
|
|
13
13
|
check_variables = opts[:check_variables]
|
|
14
14
|
no_color = opts[:no_color]
|
|
15
|
+
json_format = opts[:json]
|
|
15
16
|
|
|
16
17
|
builder
|
|
17
18
|
.with_subcommand('validate') do |sub|
|
|
@@ -28,6 +29,7 @@ module RubyTerraform
|
|
|
28
29
|
sub = sub.with_option('-check-variables', check_variables) unless
|
|
29
30
|
check_variables.nil?
|
|
30
31
|
sub = sub.with_flag('-no-color') if no_color
|
|
32
|
+
sub = sub.with_flag('-json') if json_format
|
|
31
33
|
sub
|
|
32
34
|
end
|
|
33
35
|
.with_argument(directory)
|
data/ruby_terraform.gemspec
CHANGED
|
@@ -23,15 +23,15 @@ Gem::Specification.new do |spec|
|
|
|
23
23
|
spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f)}
|
|
24
24
|
spec.require_paths = ['lib']
|
|
25
25
|
|
|
26
|
-
spec.required_ruby_version = '>= 2.
|
|
26
|
+
spec.required_ruby_version = '>= 2.6'
|
|
27
27
|
|
|
28
28
|
spec.add_dependency 'lino', '~> 1.1'
|
|
29
29
|
|
|
30
30
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
|
31
31
|
spec.add_development_dependency 'rake', '~> 13.0'
|
|
32
|
+
spec.add_development_dependency 'rake_circle_ci', '~> 0.3'
|
|
33
|
+
spec.add_development_dependency 'rake_github', '~> 0.3'
|
|
34
|
+
spec.add_development_dependency 'rake_ssh', '~> 0.2'
|
|
32
35
|
spec.add_development_dependency 'rspec', '~> 3.9'
|
|
33
|
-
spec.add_development_dependency 'excon', '~> 0.72'
|
|
34
|
-
spec.add_development_dependency 'sshkey', '~> 2.0'
|
|
35
|
-
spec.add_development_dependency 'octokit', '~> 4.16'
|
|
36
36
|
spec.add_development_dependency 'gem-release', '~> 2.1'
|
|
37
37
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby-terraform
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.51.0.pre.
|
|
4
|
+
version: 0.51.0.pre.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Toby Clemson
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-04-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: lino
|
|
@@ -53,61 +53,61 @@ dependencies:
|
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '13.0'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
56
|
+
name: rake_circle_ci
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '3
|
|
61
|
+
version: '0.3'
|
|
62
62
|
type: :development
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '3
|
|
68
|
+
version: '0.3'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
70
|
+
name: rake_github
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
73
|
- - "~>"
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '0.
|
|
75
|
+
version: '0.3'
|
|
76
76
|
type: :development
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
80
|
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '0.
|
|
82
|
+
version: '0.3'
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
|
-
name:
|
|
84
|
+
name: rake_ssh
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
86
86
|
requirements:
|
|
87
87
|
- - "~>"
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: '2
|
|
89
|
+
version: '0.2'
|
|
90
90
|
type: :development
|
|
91
91
|
prerelease: false
|
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
93
|
requirements:
|
|
94
94
|
- - "~>"
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: '2
|
|
96
|
+
version: '0.2'
|
|
97
97
|
- !ruby/object:Gem::Dependency
|
|
98
|
-
name:
|
|
98
|
+
name: rspec
|
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
|
100
100
|
requirements:
|
|
101
101
|
- - "~>"
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: '
|
|
103
|
+
version: '3.9'
|
|
104
104
|
type: :development
|
|
105
105
|
prerelease: false
|
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
|
108
108
|
- - "~>"
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: '
|
|
110
|
+
version: '3.9'
|
|
111
111
|
- !ruby/object:Gem::Dependency
|
|
112
112
|
name: gem-release
|
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -178,7 +178,6 @@ files:
|
|
|
178
178
|
- lib/ruby_terraform/errors.rb
|
|
179
179
|
- lib/ruby_terraform/errors/execution_error.rb
|
|
180
180
|
- lib/ruby_terraform/version.rb
|
|
181
|
-
- rake/circleci.rb
|
|
182
181
|
- ruby_terraform.gemspec
|
|
183
182
|
- scripts/ci/common/configure-git.sh
|
|
184
183
|
- scripts/ci/common/configure-rubygems.sh
|
|
@@ -199,14 +198,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
199
198
|
requirements:
|
|
200
199
|
- - ">="
|
|
201
200
|
- !ruby/object:Gem::Version
|
|
202
|
-
version: 2.
|
|
201
|
+
version: '2.6'
|
|
203
202
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
204
203
|
requirements:
|
|
205
204
|
- - ">"
|
|
206
205
|
- !ruby/object:Gem::Version
|
|
207
206
|
version: 1.3.1
|
|
208
207
|
requirements: []
|
|
209
|
-
rubygems_version: 3.0.
|
|
208
|
+
rubygems_version: 3.0.1
|
|
210
209
|
signing_key:
|
|
211
210
|
specification_version: 4
|
|
212
211
|
summary: A simple Ruby wrapper for invoking Terraform commands.
|
data/rake/circleci.rb
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
require 'rubygems'
|
|
2
|
-
require 'excon'
|
|
3
|
-
require 'yaml'
|
|
4
|
-
require 'json'
|
|
5
|
-
|
|
6
|
-
class CircleCI
|
|
7
|
-
def initialize(config_path)
|
|
8
|
-
config = YAML.load_file(config_path)
|
|
9
|
-
|
|
10
|
-
@api_token = config["circle_ci_api_token"]
|
|
11
|
-
@base_url = config["circle_ci_base_url"]
|
|
12
|
-
@project_slug = config["circle_ci_project_slug"]
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def find_env_vars
|
|
16
|
-
response = assert_successful(Excon.get(env_vars_url, headers: headers))
|
|
17
|
-
body = JSON.parse(response.body)
|
|
18
|
-
env_vars = body["items"].map { |item| item["name"] }
|
|
19
|
-
|
|
20
|
-
env_vars
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def delete_env_var(name)
|
|
24
|
-
assert_successful(Excon.delete(env_var_url(name), headers: headers))
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def delete_env_vars
|
|
28
|
-
env_vars = find_env_vars
|
|
29
|
-
env_vars.each do |env_var|
|
|
30
|
-
delete_env_var(env_var)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def create_env_var(name, value)
|
|
35
|
-
body = JSON.dump(name: name, value: value)
|
|
36
|
-
assert_successful(
|
|
37
|
-
Excon.post(env_vars_url, body: body, headers: headers))
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def find_ssh_keys
|
|
41
|
-
response = assert_successful(Excon.get(settings_url, headers: headers))
|
|
42
|
-
body = JSON.parse(response.body)
|
|
43
|
-
ssh_keys = body["ssh_keys"].map do |ssh_key|
|
|
44
|
-
{
|
|
45
|
-
fingerprint: ssh_key["fingerprint"],
|
|
46
|
-
hostname: ssh_key["hostname"]
|
|
47
|
-
}
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
ssh_keys
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def delete_ssh_key(ssh_key_identifier)
|
|
54
|
-
assert_successful(
|
|
55
|
-
Excon.delete(ssh_keys_url,
|
|
56
|
-
body: JSON.dump(ssh_key_identifier),
|
|
57
|
-
headers: headers))
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def delete_ssh_keys
|
|
61
|
-
ssh_keys = find_ssh_keys
|
|
62
|
-
ssh_keys.each do |ssh_key|
|
|
63
|
-
delete_ssh_key(ssh_key)
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def create_ssh_key(ssh_key)
|
|
68
|
-
body = JSON.dump({
|
|
69
|
-
fingerprint: ssh_key.sha1_fingerprint,
|
|
70
|
-
hostname: ssh_key.comment,
|
|
71
|
-
private_key: ssh_key.private_key
|
|
72
|
-
})
|
|
73
|
-
assert_successful(
|
|
74
|
-
Excon.post(ssh_keys_url, body: body, headers: headers))
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
private
|
|
78
|
-
|
|
79
|
-
def headers
|
|
80
|
-
{
|
|
81
|
-
"Circle-Token": @api_token,
|
|
82
|
-
"Content-Type": "application/json",
|
|
83
|
-
"Accept": "application/json"
|
|
84
|
-
}
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def assert_successful(response)
|
|
88
|
-
unless response.status >= 200 && response.status < 300
|
|
89
|
-
host = response.data[:host]
|
|
90
|
-
path = response.data[:path]
|
|
91
|
-
status = response.status
|
|
92
|
-
reason = response.data[:reason_phrase]
|
|
93
|
-
raise "Unsuccessful request: #{host}#{path} #{status} #{reason}"
|
|
94
|
-
end
|
|
95
|
-
response
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def env_vars_url
|
|
99
|
-
"#{@base_url}/v2/project/#{@project_slug}/envvar"
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
def env_var_url(name)
|
|
103
|
-
"#{@base_url}/v2/project/#{@project_slug}/envvar/#{name}"
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
def settings_url
|
|
107
|
-
"#{@base_url}/v1.1/project/#{@project_slug}/settings"
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
def ssh_keys_url
|
|
111
|
-
"#{@base_url}/v1.1/project/#{@project_slug}/ssh-key?" +
|
|
112
|
-
"circle-token=#{@api_token}"
|
|
113
|
-
end
|
|
114
|
-
end
|