tfw 0.1.4 → 0.1.6

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
  SHA256:
3
- metadata.gz: '097a30622dcf4ec29d39fdc178e22705741c64830a539cf43afce73e8fda85c8'
4
- data.tar.gz: de91b7eaa5a5e53afbf46afc5a00ab5ee116ac14c7b07db699879219cd59ee9f
3
+ metadata.gz: '04327592308f84a5cd087ac6d1385678981de535135669eb93d861c3211bb394'
4
+ data.tar.gz: 867076ea55ba99cb609049889394542fb3611e24bc7dd662429838a487058040
5
5
  SHA512:
6
- metadata.gz: 68d2b1d0ede302ac61eb8c225faf739d4e4a6903364082423aec9bc4a66bf76b6710ec01b9544d189e5fbf622d4abd1c3574e8b31d7e801f18c7ae0abb506144
7
- data.tar.gz: 989419b35ca44fdc20463e11b99c6b5356529892ed538bff768eade07f11bf56b5a32fb26ea823de766b838587e07a82131161a73c0a23f4ddd09fedfee3f0ed
6
+ metadata.gz: 5a8a78032dc0de80c686ef3940ee16dec65ffc9d30cdb841adfad91424a5d0a2913c2c10d0ffa1dcd2c2cd9aa134a61e793c1d995c4294c50ac9d53459114ed7
7
+ data.tar.gz: da680333c8a47885df927380a6063322232aea0c10a14f3b6f5cd290ce237384a2100f2e4e390c7f9cba5ab172a37489d9439c492378679a398b97da4a719393
data/.rubocop.yml CHANGED
@@ -1,3 +1,6 @@
1
+ Style/SpecialGlobalVars:
2
+ Enabled: false
3
+
1
4
  Style/ConditionalAssignment:
2
5
  Enabled: false
3
6
 
@@ -0,0 +1,3 @@
1
+ {
2
+ "local": "c6ad4c39c17fa8cae51c9972ad20fda093cbb7b4a5ee7a0334a40fb08b47421f"
3
+ }
data/.tfw/stack.tf ADDED
@@ -0,0 +1,8 @@
1
+ resource "local_file" "foo" {
2
+ content = "foo"
3
+ filename = "/tmp/foo"
4
+ provisioner "local-exec" {
5
+ command = "bash -c \"sleep 60\""
6
+ }
7
+ }
8
+
@@ -0,0 +1,31 @@
1
+ {
2
+ "version": 4,
3
+ "terraform_version": "0.12.19",
4
+ "serial": 4,
5
+ "lineage": "41e2c065-b72a-ec1e-a24f-369255a4afdc",
6
+ "outputs": {},
7
+ "resources": [
8
+ {
9
+ "mode": "managed",
10
+ "type": "local_file",
11
+ "name": "foo",
12
+ "provider": "provider.local",
13
+ "instances": [
14
+ {
15
+ "status": "tainted",
16
+ "schema_version": 0,
17
+ "attributes": {
18
+ "content": "foo",
19
+ "content_base64": null,
20
+ "directory_permission": "0777",
21
+ "file_permission": "0777",
22
+ "filename": "/tmp/foo",
23
+ "id": "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33",
24
+ "sensitive_content": null
25
+ },
26
+ "private": "bnVsbA=="
27
+ }
28
+ ]
29
+ }
30
+ ]
31
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "version": 4,
3
+ "terraform_version": "0.12.19",
4
+ "serial": 3,
5
+ "lineage": "41e2c065-b72a-ec1e-a24f-369255a4afdc",
6
+ "outputs": {},
7
+ "resources": [
8
+ {
9
+ "mode": "managed",
10
+ "type": "local_file",
11
+ "name": "foo",
12
+ "provider": "provider.local",
13
+ "instances": [
14
+ {
15
+ "status": "tainted",
16
+ "schema_version": 0,
17
+ "attributes": {
18
+ "content": "foo",
19
+ "content_base64": null,
20
+ "directory_permission": "0777",
21
+ "file_permission": "0777",
22
+ "filename": "/tmp/foo",
23
+ "id": "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33",
24
+ "sensitive_content": null
25
+ },
26
+ "private": "bnVsbA=="
27
+ }
28
+ ]
29
+ }
30
+ ]
31
+ }
data/1.rb ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ resource 'local_file', 'foo' do
4
+ content 'foo'
5
+ filename '/tmp/foo'
6
+
7
+ provisioner 'local-exec' do
8
+ command 'bash -c "sleep 60"'
9
+ end
10
+ end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tfw (0.1.4)
4
+ tfw (0.1.6)
5
5
  tfdsl (= 0.1.5)
6
6
 
7
7
  GEM
data/exe/tfw CHANGED
@@ -2,4 +2,4 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'tfw'
5
- TFW.cli ARGV
5
+ exit TFW.cli ARGV
data/lib/tfw/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TFW
4
- VERSION = '0.1.4'
4
+ VERSION = '0.1.6'
5
5
  end
data/lib/tfw.rb CHANGED
@@ -30,17 +30,38 @@ module TFW
30
30
  end
31
31
 
32
32
  def cli(args)
33
- stack = TFW.get_stack_for_dir '.'
33
+ build_config
34
+ run_terraform args
35
+ end
34
36
 
37
+ def build_config
38
+ FileUtils.mkdir_p WORKSPACE
39
+ stack = TFW.get_stack_for_dir '.'
35
40
  stack_file = "#{WORKSPACE}/stack.tf"
36
41
  write_stack_file stack_file, stack
42
+ end
37
43
 
44
+ def run_terraform(args)
38
45
  old_dir = Dir.pwd
39
46
  Dir.chdir WORKSPACE
40
47
 
41
48
  cmd = "terraform #{args.join ' '}"
42
- Process.wait(fork { exec cmd })
49
+ pid = fork { exec cmd }
43
50
  Dir.chdir old_dir
51
+ trap_pids [pid]
52
+ Process.wait pid
53
+ $?.exitstatus
54
+ end
55
+
56
+ def trap_pids(pids)
57
+ %w[SIGINT SIGTERM].each do |sig|
58
+ Signal.trap sig do
59
+ pids.each { |pid| Process.kill sig, pid }
60
+ Process.waitall
61
+ puts "ERROR: TFW received and forwarded #{sig} to terraform"
62
+ exit 2
63
+ end
64
+ end
44
65
  end
45
66
 
46
67
  def load_module(stack, &block)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tfw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Lopo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-21 00:00:00.000000000 Z
11
+ date: 2020-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tfdsl
@@ -118,7 +118,13 @@ extra_rdoc_files: []
118
118
  files:
119
119
  - ".gitignore"
120
120
  - ".rubocop.yml"
121
+ - ".tfw/.terraform/plugins/darwin_amd64/lock.json"
122
+ - ".tfw/.terraform/plugins/darwin_amd64/terraform-provider-local_v1.4.0_x4"
123
+ - ".tfw/stack.tf"
124
+ - ".tfw/terraform.tfstate"
125
+ - ".tfw/terraform.tfstate.backup"
121
126
  - ".travis.yml"
127
+ - 1.rb
122
128
  - CODE_OF_CONDUCT.md
123
129
  - Gemfile
124
130
  - Gemfile.lock