ruby-terraform 0.1.0 → 0.2.0

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
  SHA1:
3
- metadata.gz: dc8424908176ccb7bd856aee7f96847c101ff2d7
4
- data.tar.gz: 43fd0e8f0ef7b326e227a8b29e7cf34dc9e47c96
3
+ metadata.gz: d6e2038484a3afb9ae5f1892067030bc70bdb330
4
+ data.tar.gz: 83a93936beb7d16c96891577ab5cd42536867e8d
5
5
  SHA512:
6
- metadata.gz: 644b5d8d0879f38a46c0fdaaa1e800364df8383e0748fd1a2f985df6be5900538443d688f560311035556ba62bc72528f1cd2e940c4947386885fcdc6fabb163
7
- data.tar.gz: 5d76cc8141f9bd8737ccfa607fb630bfe603054b56c7699dce615ab67c7ee6707ccbb6fb9b78b346113ce7fb3c52d48284a2329d5e7e7005eb0b7ef4d9dee84a
6
+ metadata.gz: 688080b50d97d4624e5dd7bd05d4cee95132cc2221d1dcd5b95f03f9614ee6699af63689d472c0ce7d7abe441c4ca8d69c7409bc37f160b4753555d3d9a27bf5
7
+ data.tar.gz: b8d9bf122ad7d199042acb9beefa5c08d2f45a2db4b3f52592f5bd87cfdca196991b2d6ad72f9422c1b7833aa64f3a1e53b5225fb97463961b353c7fb03c22d0
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-terraform (0.1.0)
4
+ ruby-terraform (0.2.0)
5
5
  lino (~> 1.1)
6
6
 
7
7
  GEM
data/TODO.md ADDED
@@ -0,0 +1 @@
1
+ * Error early when required options are missing.
@@ -1,6 +1,9 @@
1
1
  require_relative 'commands/clean'
2
2
  require_relative 'commands/get'
3
3
  require_relative 'commands/apply'
4
+ require_relative 'commands/destroy'
5
+ require_relative 'commands/output'
6
+ require_relative 'commands/remote_config'
4
7
 
5
8
  module RubyTerraform
6
9
  module Commands
@@ -9,17 +9,45 @@ module RubyTerraform
9
9
  @binary = binary || RubyTerraform.configuration.binary
10
10
  end
11
11
 
12
- def execute(opts)
13
- builder = Lino::CommandLineBuilder
14
- .for_command(binary)
15
- .with_option_separator('=')
12
+ def stdin
13
+ ''
14
+ end
15
+
16
+ def stdout
17
+ STDOUT
18
+ end
19
+
20
+ def stderr
21
+ STDERR
22
+ end
23
+
24
+ def execute(opts = {})
25
+ builder = instantiate_builder
26
+
27
+ do_before(opts)
16
28
  configure_command(builder, opts)
17
29
  .build
18
- .execute
30
+ .execute(
31
+ stdin: stdin,
32
+ stdout: stdout,
33
+ stderr: stderr)
34
+ do_after(opts)
35
+ end
36
+
37
+ def instantiate_builder
38
+ Lino::CommandLineBuilder
39
+ .for_command(binary)
40
+ .with_option_separator('=')
41
+ end
42
+
43
+ def do_before(opts)
19
44
  end
20
45
 
21
46
  def configure_command(builder, opts)
22
47
  end
48
+
49
+ def do_after(opts)
50
+ end
23
51
  end
24
52
  end
25
53
  end
@@ -0,0 +1,31 @@
1
+ require 'lino'
2
+ require_relative 'base'
3
+
4
+ module RubyTerraform
5
+ module Commands
6
+ class Destroy < Base
7
+ def configure_command(builder, opts)
8
+ directory = opts[:directory]
9
+ vars = opts[:vars] || {}
10
+ state = opts[:state]
11
+ force = opts[:force]
12
+ no_backup = opts[:no_backup]
13
+ backup = no_backup ? '-' : opts[:backup]
14
+ no_color = opts[:no_color]
15
+
16
+ builder
17
+ .with_subcommand('destroy') do |sub|
18
+ vars.each do |key, value|
19
+ sub = sub.with_option('-var', "'#{key}=#{value}'", separator: ' ')
20
+ end
21
+ sub = sub.with_option('-state', state) if state
22
+ sub = sub.with_option('-backup', backup) if backup
23
+ sub = sub.with_flag('-no-color') if no_color
24
+ sub = sub.with_flag('-force') if force
25
+ sub
26
+ end
27
+ .with_argument(directory)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,32 @@
1
+ require 'lino'
2
+ require_relative 'base'
3
+
4
+ module RubyTerraform
5
+ module Commands
6
+ class Output < Base
7
+ def stdout
8
+ @stdout ||= StringIO.new
9
+ end
10
+
11
+ def configure_command(builder, opts)
12
+ name = opts[:name]
13
+ state = opts[:state]
14
+ no_color = opts[:no_color]
15
+
16
+ builder = builder
17
+ .with_subcommand('output') do |sub|
18
+ sub = sub.with_flag('-no-color') if no_color
19
+ sub = sub.with_option('-state', state) if state
20
+ sub
21
+ end
22
+ builder = builder.with_argument(name) if name
23
+ builder
24
+ end
25
+
26
+ def do_after(opts)
27
+ result = stdout.string
28
+ opts[:name] ? result.chomp : result
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,26 @@
1
+ require 'lino'
2
+ require_relative 'base'
3
+
4
+ module RubyTerraform
5
+ module Commands
6
+ class RemoteConfig < Base
7
+ def configure_command(builder, opts)
8
+ backend = opts[:backend]
9
+ no_color = opts[:no_color]
10
+ backend_config = opts[:backend_config] || {}
11
+
12
+ builder
13
+ .with_subcommand('remote')
14
+ .with_subcommand('config') do |sub|
15
+ sub = sub.with_option('-backend', backend) if backend
16
+ backend_config.each do |key, value|
17
+ sub = sub.with_option('-backend-config', "'#{key}=#{value}'", separator: ' ')
18
+ end
19
+
20
+ sub = sub.with_flag('-no-color') if no_color
21
+ sub
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module RubyTerraform
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-terraform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toby Clemson
@@ -97,6 +97,7 @@ files:
97
97
  - LICENSE.txt
98
98
  - README.md
99
99
  - Rakefile
100
+ - TODO.md
100
101
  - bin/console
101
102
  - bin/setup
102
103
  - lib/ruby_terraform.rb
@@ -104,7 +105,10 @@ files:
104
105
  - lib/ruby_terraform/commands/apply.rb
105
106
  - lib/ruby_terraform/commands/base.rb
106
107
  - lib/ruby_terraform/commands/clean.rb
108
+ - lib/ruby_terraform/commands/destroy.rb
107
109
  - lib/ruby_terraform/commands/get.rb
110
+ - lib/ruby_terraform/commands/output.rb
111
+ - lib/ruby_terraform/commands/remote_config.rb
108
112
  - lib/ruby_terraform/version.rb
109
113
  - ruby_terraform.gemspec
110
114
  homepage: https://github.com/tobyclemson/ruby_terraform