ruby-terraform 0.55.0.pre.1 → 0.59.0.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +6 -6
- data/README.md +74 -0
- data/lib/ruby_terraform.rb +8 -0
- data/lib/ruby_terraform/commands.rb +2 -0
- data/lib/ruby_terraform/commands/fmt.rb +31 -0
- data/lib/ruby_terraform/commands/import.rb +46 -0
- data/lib/ruby_terraform/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31791b88071aedec456f114396f8066b555ddcaddaa3e9d3d4fa100560a92262
|
4
|
+
data.tar.gz: 1d2d327bacc5593010b5dd9bc51e7dd44c729b6f614eb92fc415102973cbcb6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54d68b310141085f68296b7f35cb40d64cfc07398d2679f07e055d07dca8bbbcdde21b611d468a2a0067101b8c39583dc7a5640625ec123ddff50150327e2d91
|
7
|
+
data.tar.gz: b0c44a9823117cc4365a29d22631bb615e4432eb08e0b0d049322565694440d92830b808236923c159e937f7149436cf6edf705bc9f538e1d469b02d65b709ad
|
data/Gemfile.lock
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ruby-terraform (0.
|
4
|
+
ruby-terraform (0.59.0.pre.1)
|
5
5
|
lino (>= 1.1, < 2)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activesupport (6.0.
|
10
|
+
activesupport (6.0.3.1)
|
11
11
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
12
|
i18n (>= 0.7, < 2)
|
13
13
|
minitest (~> 5.1)
|
14
14
|
tzinfo (~> 1.1)
|
15
|
-
zeitwerk (~> 2.2)
|
15
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
16
16
|
addressable (2.7.0)
|
17
17
|
public_suffix (>= 2.0.2, < 5.0)
|
18
18
|
colored2 (3.1.2)
|
@@ -29,13 +29,13 @@ GEM
|
|
29
29
|
lino (1.3.0)
|
30
30
|
hamster (~> 3.0)
|
31
31
|
open4 (~> 1.3)
|
32
|
-
minitest (5.14.
|
32
|
+
minitest (5.14.1)
|
33
33
|
multipart-post (2.1.1)
|
34
34
|
octokit (4.18.0)
|
35
35
|
faraday (>= 0.9)
|
36
36
|
sawyer (~> 0.8.0, >= 0.5.3)
|
37
37
|
open4 (1.3.4)
|
38
|
-
public_suffix (4.0.
|
38
|
+
public_suffix (4.0.5)
|
39
39
|
rake (13.0.1)
|
40
40
|
rake_circle_ci (0.7.0)
|
41
41
|
colored2 (~> 3.1)
|
@@ -60,7 +60,7 @@ GEM
|
|
60
60
|
rspec-mocks (~> 3.9.0)
|
61
61
|
rspec-core (3.9.2)
|
62
62
|
rspec-support (~> 3.9.3)
|
63
|
-
rspec-expectations (3.9.
|
63
|
+
rspec-expectations (3.9.2)
|
64
64
|
diff-lcs (>= 1.2.0, < 2.0)
|
65
65
|
rspec-support (~> 3.9.0)
|
66
66
|
rspec-mocks (3.9.1)
|
data/README.md
CHANGED
@@ -48,7 +48,9 @@ Currently, there is partial support for the following commands:
|
|
48
48
|
* `RubyTerraform::Commands::Destroy`: executes `terraform destroy`
|
49
49
|
* `RubyTerraform::Commands::Output`: executes `terraform output`
|
50
50
|
* `RubyTerraform::Commands::Refresh`: executes `terraform refresh`
|
51
|
+
* `RubyTerraform::Commands::Import`: executes `terraform import`
|
51
52
|
* `RubyTerraform::Commands::RemoteConfig`: executes `terraform remote config`
|
53
|
+
* `RubyTerraform::Commands::FMT`: executes `terraform fmt`
|
52
54
|
* `RubyTerraform::Commands::Validate`: executes `terraform validate`
|
53
55
|
* `RubyTerraform::Commands::Workspace`: executes `terraform workspace`
|
54
56
|
|
@@ -311,6 +313,47 @@ The refresh command supports the following options passed as keyword arguments:
|
|
311
313
|
defaults to `false`.
|
312
314
|
|
313
315
|
|
316
|
+
### RubyTerraform::Commands::Import
|
317
|
+
|
318
|
+
The import command imports existing infrastructure into your terraform state.
|
319
|
+
It can be called in the following ways:
|
320
|
+
|
321
|
+
```ruby
|
322
|
+
RubyTerraform.import(
|
323
|
+
directory: 'infra/networking',
|
324
|
+
address: 'a.resource.address',
|
325
|
+
id: 'a-resource-id',
|
326
|
+
vars: {
|
327
|
+
region: 'eu-central'
|
328
|
+
}))
|
329
|
+
RubyTerraform::Commands::Import.new.execute(
|
330
|
+
directory: 'infra/networking',
|
331
|
+
address: 'a.resource.address',
|
332
|
+
id: 'a-resource-id',
|
333
|
+
vars: {
|
334
|
+
region: 'eu-central'
|
335
|
+
}))
|
336
|
+
```
|
337
|
+
|
338
|
+
The import command supports the following options passed as keyword arguments:
|
339
|
+
* `directory`: the directory containing terraform configuration; required.
|
340
|
+
* `address`: a valid resource address; required.
|
341
|
+
* `id`: id of resource being imported; required.
|
342
|
+
* `vars`: a map of vars to be passed in to the terraform configuration.
|
343
|
+
* `var_file`: the path to a terraform var file; if both `var_file` and
|
344
|
+
`var_files` are provided, all var files will be passed to terraform.
|
345
|
+
* `var_files`: an array of paths to terraform var files; if both `var_file` and
|
346
|
+
`var_files` are provided, all var files will be passed to terraform.
|
347
|
+
* `input`: when `false`, will not ask for input for variables not directly set;
|
348
|
+
defaults to `true`.
|
349
|
+
* `state`: the path to the state file containing the current state; defaults to
|
350
|
+
terraform.tfstate in the working directory or the remote state if configured.
|
351
|
+
* `no_backup`: when `true`, no backup file will be written; defaults to `false`.
|
352
|
+
* `backup`: the path to the backup file in which to store the state backup.
|
353
|
+
* `no_color`: whether or not the output from the command should be in color;
|
354
|
+
defaults to `false`.
|
355
|
+
|
356
|
+
|
314
357
|
### RubyTerraform::Commands::RemoteConfig
|
315
358
|
|
316
359
|
The remote config command configures storage of state using a remote backend. It
|
@@ -342,7 +385,38 @@ arguments:
|
|
342
385
|
* `no_color`: whether or not the output from the command should be in color;
|
343
386
|
defaults to `false`.
|
344
387
|
|
388
|
+
### RubyTerraform::Commands::FMT
|
389
|
+
|
390
|
+
The FMT command formats the terraform directory specified. It can be called in the following ways:
|
345
391
|
|
392
|
+
```ruby
|
393
|
+
RubyTerraform.fmt(
|
394
|
+
directory: 'infra/networking',
|
395
|
+
vars: {
|
396
|
+
region: 'eu-central'
|
397
|
+
})
|
398
|
+
RubyTerraform::Commands::FMT.new.execute(
|
399
|
+
directory: 'infra/networking',
|
400
|
+
vars: {
|
401
|
+
region: 'eu-central'
|
402
|
+
})
|
403
|
+
```
|
404
|
+
|
405
|
+
The fmt command supports the following options passed as keyword arguments:
|
406
|
+
* `directory`: the directory containing terraform configuration to be formatted; required.
|
407
|
+
* `recursive`: Processes files in subdirectories;
|
408
|
+
defaults to `false`.
|
409
|
+
* `list`: Don't list files whose formatting differs;
|
410
|
+
defaults to `false`.
|
411
|
+
* `write`: Don't write to source files;
|
412
|
+
defaults to `false`.
|
413
|
+
* `check`: Checks if the input is formatted, exit status will be 0 if all input is properly formatted and non zero otherwise;
|
414
|
+
defaults to `false`.
|
415
|
+
* `diff`: Displays a diff of the formatting changes;
|
416
|
+
defaults to `false`.
|
417
|
+
* `no_color`: whether or not the output from the command should be in color;
|
418
|
+
defaults to `false`.
|
419
|
+
|
346
420
|
### RubyTerraform::Commands::Validate
|
347
421
|
|
348
422
|
The validate command validates terraform configuration in the provided terraform
|
data/lib/ruby_terraform.rb
CHANGED
@@ -68,6 +68,14 @@ module RubyTerraform
|
|
68
68
|
def workspace(opts = {})
|
69
69
|
Commands::Workspace.new.execute(opts)
|
70
70
|
end
|
71
|
+
|
72
|
+
def import(opts = {})
|
73
|
+
Commands::Import.new.execute(opts)
|
74
|
+
end
|
75
|
+
|
76
|
+
def fmt(opts = {})
|
77
|
+
Commands::FMT.new.execute(opts)
|
78
|
+
end
|
71
79
|
end
|
72
80
|
extend ClassMethods
|
73
81
|
|
@@ -10,6 +10,8 @@ require_relative 'commands/refresh'
|
|
10
10
|
require_relative 'commands/remote_config'
|
11
11
|
require_relative 'commands/show'
|
12
12
|
require_relative 'commands/workspace'
|
13
|
+
require_relative 'commands/import'
|
14
|
+
require_relative 'commands/fmt'
|
13
15
|
|
14
16
|
module RubyTerraform
|
15
17
|
module Commands
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'lino'
|
4
|
+
require_relative 'base'
|
5
|
+
|
6
|
+
module RubyTerraform
|
7
|
+
module Commands
|
8
|
+
class FMT < Base
|
9
|
+
def configure_command(builder, opts)
|
10
|
+
directory = opts[:directory]
|
11
|
+
check = opts[:check]
|
12
|
+
diff = opts[:diff]
|
13
|
+
list = opts[:list]
|
14
|
+
no_color = opts[:no_color]
|
15
|
+
recursive = opts[:recursive]
|
16
|
+
write = opts[:write]
|
17
|
+
|
18
|
+
builder.with_subcommand('fmt') do |sub|
|
19
|
+
sub = sub.with_option('-list', list) if list
|
20
|
+
sub = sub.with_option('-write', write) if write
|
21
|
+
|
22
|
+
sub = sub.with_flag('-check') if check
|
23
|
+
sub = sub.with_flag('-diff') if diff
|
24
|
+
sub = sub.with_flag('-no-color') if no_color
|
25
|
+
sub = sub.with_flag('-recursive') if recursive
|
26
|
+
sub
|
27
|
+
end.with_argument(directory)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'lino'
|
4
|
+
require_relative 'base'
|
5
|
+
|
6
|
+
module RubyTerraform
|
7
|
+
module Commands
|
8
|
+
class Import < Base
|
9
|
+
def configure_command(builder, opts)
|
10
|
+
directory = opts[:directory]
|
11
|
+
vars = opts[:vars] || {}
|
12
|
+
var_file = opts[:var_file]
|
13
|
+
var_files = opts[:var_files] || []
|
14
|
+
no_color = opts[:no_color]
|
15
|
+
no_backup = opts[:no_backup]
|
16
|
+
backup = no_backup ? '-' : opts[:backup]
|
17
|
+
state = opts[:state]
|
18
|
+
input = opts[:input]
|
19
|
+
address = opts[:address]
|
20
|
+
id = opts[:id]
|
21
|
+
|
22
|
+
builder
|
23
|
+
.with_subcommand('import') do |sub|
|
24
|
+
sub = sub.with_option('-config', directory)
|
25
|
+
vars.each do |key, value|
|
26
|
+
var_value = value.is_a?(String) ? value : JSON.generate(value)
|
27
|
+
sub = sub.with_option(
|
28
|
+
'-var', "'#{key}=#{var_value}'", separator: ' '
|
29
|
+
)
|
30
|
+
end
|
31
|
+
sub = sub.with_option('-var-file', var_file) if var_file
|
32
|
+
var_files.each do |file|
|
33
|
+
sub = sub.with_option('-var-file', file)
|
34
|
+
end
|
35
|
+
sub = sub.with_option('-state', state) if state
|
36
|
+
sub = sub.with_option('-input', input) if input
|
37
|
+
sub = sub.with_option('-backup', backup) if backup
|
38
|
+
sub = sub.with_flag('-no-color') if no_color
|
39
|
+
sub
|
40
|
+
end
|
41
|
+
.with_argument(address)
|
42
|
+
.with_argument(id)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
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.
|
4
|
+
version: 0.59.0.pre.1
|
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-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lino
|
@@ -172,7 +172,9 @@ files:
|
|
172
172
|
- lib/ruby_terraform/commands/base.rb
|
173
173
|
- lib/ruby_terraform/commands/clean.rb
|
174
174
|
- lib/ruby_terraform/commands/destroy.rb
|
175
|
+
- lib/ruby_terraform/commands/fmt.rb
|
175
176
|
- lib/ruby_terraform/commands/get.rb
|
177
|
+
- lib/ruby_terraform/commands/import.rb
|
176
178
|
- lib/ruby_terraform/commands/init.rb
|
177
179
|
- lib/ruby_terraform/commands/output.rb
|
178
180
|
- lib/ruby_terraform/commands/plan.rb
|