wdi_tf 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wdi_tf/cli.rb +14 -1
- data/lib/wdi_tf/main.rb +21 -1
- data/lib/wdi_tf/version.rb +1 -1
- data/wdi_tf.gemspec +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b643dd4f299853cd8f802fd08a04464ed5f925e
|
4
|
+
data.tar.gz: 8726fca6bb0b7ba1040518ad7f300f9007a4a537
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 085449d1484b833f287ade7a3179c149278da1528969bb0754c822e6419eb3a95fad36e928ec3854451e4ca58af8f029d71d240e5fdc888833f612f926f500f7
|
7
|
+
data.tar.gz: 4b68c769667f743f34c1654c0d4cacf58da66950003eb82b2b1af8eff259b327afdf1853ca23b89fd0db589dfdb284dc5c1df06033927a8797502e7efeea2149
|
data/lib/wdi_tf/cli.rb
CHANGED
@@ -9,8 +9,9 @@ module WdiTf
|
|
9
9
|
module Cli
|
10
10
|
module_function
|
11
11
|
|
12
|
-
@@project_file
|
12
|
+
@@project_file = 'Terraform.tfproj'
|
13
13
|
@@variables_file = 'Terraform.tfvars'
|
14
|
+
@@allowed_cmds = ['clean', 'plan', 'apply', 'destroy']
|
14
15
|
|
15
16
|
def load_opts(args: ARGV)
|
16
17
|
Trollop.options(args) do
|
@@ -19,6 +20,14 @@ module WdiTf
|
|
19
20
|
|
20
21
|
Usage:
|
21
22
|
tf [options] COMMAND
|
23
|
+
|
24
|
+
Commands:
|
25
|
+
clean - cleans the workspace and returns it back to the original state.
|
26
|
+
plan - runs 'terraform plan' on the workspace. (default)
|
27
|
+
apply - runs 'terraform apply' on the workspace.
|
28
|
+
destroy - runs 'teraform destroy' on the workspace.
|
29
|
+
|
30
|
+
Options:
|
22
31
|
EOS
|
23
32
|
|
24
33
|
opt :debug, 'Puts the wrapper into debug mode', type: TrueClass, default: nil
|
@@ -34,6 +43,10 @@ module WdiTf
|
|
34
43
|
cmd = ARGV.shift
|
35
44
|
cmd ||= "plan"
|
36
45
|
|
46
|
+
if not @@allowed_cmds.include?(cmd)
|
47
|
+
error(msg: "Unknown command '#{ cmd }'. Accepted commands: #{ @@allowed_cmds.join(', ') }")
|
48
|
+
end
|
49
|
+
|
37
50
|
return cmd
|
38
51
|
end
|
39
52
|
|
data/lib/wdi_tf/main.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'open3'
|
1
2
|
require 'wdi_tf/main'
|
2
3
|
|
3
4
|
module WdiTf
|
@@ -40,13 +41,32 @@ module WdiTf
|
|
40
41
|
def run_terraform(command:, variables:)
|
41
42
|
info("Running Terraform command.")
|
42
43
|
|
43
|
-
cmd = "terraform #{ command }"
|
44
|
+
cmd = "terraform init && terraform #{ command }"
|
44
45
|
|
45
46
|
if File.exists?(variables)
|
46
47
|
cmd = "#{ cmd } -var-file=#{ variables }"
|
47
48
|
end
|
48
49
|
|
50
|
+
if command == 'apply'
|
51
|
+
cmd = "#{ cmd } -auto-approve"
|
52
|
+
end
|
53
|
+
|
54
|
+
if command == 'destroy'
|
55
|
+
cmd = "#{ cmd } -force"
|
56
|
+
end
|
57
|
+
|
49
58
|
info(" #{ cmd }")
|
59
|
+
Open3.popen2e(cmd) do |stdin, stdout_err, wait_thr|
|
60
|
+
while line = stdout_err.gets
|
61
|
+
puts line
|
62
|
+
end
|
63
|
+
|
64
|
+
exit_status = wait_thr.value
|
65
|
+
|
66
|
+
unless exit_status.success?
|
67
|
+
abort "FAILED !!! #{cmd}"
|
68
|
+
end
|
69
|
+
end
|
50
70
|
end
|
51
71
|
end
|
52
72
|
end
|
data/lib/wdi_tf/version.rb
CHANGED
data/wdi_tf.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Anthony Kirby"]
|
10
10
|
spec.email = 'anthony.kirby@winedirect.com'
|
11
11
|
|
12
|
-
spec.description = "Terraform wrapper"
|
12
|
+
spec.description = "Terraform wrapper to simply working with TF by introducing Terraform projects."
|
13
13
|
spec.summary = spec.description
|
14
14
|
spec.homepage = 'http://rubygems.org/gems/wdi_tf'
|
15
15
|
spec.license = 'Apache-2.0'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wdi_tf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Kirby
|
@@ -52,7 +52,8 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.4'
|
55
|
-
description: Terraform wrapper
|
55
|
+
description: Terraform wrapper to simply working with TF by introducing Terraform
|
56
|
+
projects.
|
56
57
|
email: anthony.kirby@winedirect.com
|
57
58
|
executables:
|
58
59
|
- wdi-tf
|
@@ -91,5 +92,5 @@ rubyforge_project:
|
|
91
92
|
rubygems_version: 2.6.12
|
92
93
|
signing_key:
|
93
94
|
specification_version: 4
|
94
|
-
summary: Terraform wrapper
|
95
|
+
summary: Terraform wrapper to simply working with TF by introducing Terraform projects.
|
95
96
|
test_files: []
|