yle_tf 0.2.1 → 0.3.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 +5 -5
- data/bin/tf +3 -0
- data/lib/yle_tf/action/terraform_init.rb +10 -5
- data/lib/yle_tf/action/verify_tf_env.rb +1 -3
- data/lib/yle_tf/cli.rb +2 -0
- data/lib/yle_tf/plugin/action_hook.rb +2 -6
- data/lib/yle_tf/system/io_handlers.rb +13 -10
- data/lib/yle_tf/version.rb +1 -1
- data/lib/yle_tf_plugins/commands/help/command.rb +1 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 95dbeb71fae7b996332d0392c7e1c0710e8cfce4898be87574817308626ca9cf
|
4
|
+
data.tar.gz: 90b6c63351a1e30f6bee26825274cbca0aaeb8d5cd05d1a256bef8f9d8408c81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a00736661dba53738ab1c44ac48f990264c955c0747c50795a01c893bf9ac1e69da9c82e66a62edbe0a3464d0c42a6ceb84e1f41a40da98e22a15231c7e54cb
|
7
|
+
data.tar.gz: a97abc8c99fb34b8db0881ef3c972f706a03667759aeca420b38dda4f3c549724b0125f3909ff9b77346d1e4119f99ec07e208820a1acfc38cfbe87714cff6ae
|
data/bin/tf
CHANGED
@@ -7,6 +7,13 @@ require 'yle_tf/version_requirement'
|
|
7
7
|
class YleTf
|
8
8
|
module Action
|
9
9
|
class TerraformInit
|
10
|
+
TF_CMD_ARGS = %w[-input=false -no-color].freeze
|
11
|
+
|
12
|
+
TF_CMD_OPTS = {
|
13
|
+
env: { 'TF_IN_AUTOMATION' => 'true' }, # Reduces some output
|
14
|
+
stdout: :debug # Hide the output to the debug level
|
15
|
+
}.freeze
|
16
|
+
|
10
17
|
def initialize(app)
|
11
18
|
@app = app
|
12
19
|
end
|
@@ -30,20 +37,18 @@ class YleTf
|
|
30
37
|
def init_pre_0_9(backend)
|
31
38
|
cli_args = backend.cli_args
|
32
39
|
if cli_args
|
33
|
-
YleTf::System.cmd('terraform', 'remote', 'config',
|
34
|
-
'-no-color', *cli_args,
|
35
|
-
stdout: :debug)
|
40
|
+
YleTf::System.cmd('terraform', 'remote', 'config', *TF_CMD_ARGS, *cli_args, TF_CMD_OPTS)
|
36
41
|
end
|
37
42
|
|
38
43
|
Logger.debug('Fetching Terraform modules')
|
39
|
-
YleTf::System.cmd('terraform', 'get',
|
44
|
+
YleTf::System.cmd('terraform', 'get', *TF_CMD_ARGS, TF_CMD_OPTS)
|
40
45
|
end
|
41
46
|
|
42
47
|
def init(backend)
|
43
48
|
Logger.debug('Generating the backend configuration')
|
44
49
|
backend.generate_config do
|
45
50
|
Logger.debug('Initializing Terraform')
|
46
|
-
YleTf::System.cmd('terraform', 'init',
|
51
|
+
YleTf::System.cmd('terraform', 'init', *TF_CMD_ARGS, TF_CMD_OPTS)
|
47
52
|
end
|
48
53
|
end
|
49
54
|
|
@@ -12,9 +12,7 @@ class YleTf
|
|
12
12
|
config = env[:config]
|
13
13
|
all_envs = VarsFile.list_all_envs(config)
|
14
14
|
|
15
|
-
if all_envs.empty?
|
16
|
-
raise Error, "No Terraform vars files found in '#{VarsFile::ENV_DIR}/'"
|
17
|
-
end
|
15
|
+
raise(Error, "No Terraform vars files found in '#{VarsFile::ENV_DIR}/'") if all_envs.empty?
|
18
16
|
|
19
17
|
if !all_envs.include?(config.tf_env)
|
20
18
|
raise Error, "Terraform vars file not found for the '#{config.tf_env}' " \
|
data/lib/yle_tf/cli.rb
CHANGED
@@ -68,6 +68,8 @@ class YleTf
|
|
68
68
|
self.debug = true if @tf_options[:debug]
|
69
69
|
YleTf::Logger.color = false if @tf_options[:no_color]
|
70
70
|
end
|
71
|
+
# rubocop:enable Metrics/AbcSize, Metrics/BlockLength, Metrics/MethodLength
|
72
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
71
73
|
|
72
74
|
# Returns `Symbol` for the arg, e.g. `"--foo-bar"` -> `:foo_bar`
|
73
75
|
def key(arg)
|
@@ -8,15 +8,11 @@ class YleTf
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def before(existing, new, *args, &block)
|
11
|
-
if actions.include?(existing)
|
12
|
-
actions.insert_before(existing, new, *args, &block)
|
13
|
-
end
|
11
|
+
actions.insert_before(existing, new, *args, &block) if actions.include?(existing)
|
14
12
|
end
|
15
13
|
|
16
14
|
def after(existing, new, *args, &block)
|
17
|
-
if actions.include?(existing)
|
18
|
-
actions.insert_after(existing, new, *args, &block)
|
19
|
-
end
|
15
|
+
actions.insert_after(existing, new, *args, &block) if actions.include?(existing)
|
20
16
|
end
|
21
17
|
end
|
22
18
|
end
|
@@ -78,13 +78,7 @@ class YleTf
|
|
78
78
|
def self.io_input(source)
|
79
79
|
lambda do |target, *|
|
80
80
|
Thread.new do
|
81
|
-
|
82
|
-
while (data = source.readpartial(BLOCK_SIZE))
|
83
|
-
target.write(data)
|
84
|
-
end
|
85
|
-
ensure
|
86
|
-
target.close_write
|
87
|
-
end
|
81
|
+
copy_data(source, target, close_target: true)
|
88
82
|
end
|
89
83
|
end
|
90
84
|
end
|
@@ -94,12 +88,21 @@ class YleTf
|
|
94
88
|
def self.io_output(target)
|
95
89
|
lambda do |source, *|
|
96
90
|
Thread.new do
|
97
|
-
|
98
|
-
target.write(data)
|
99
|
-
end
|
91
|
+
copy_data(source, target)
|
100
92
|
end
|
101
93
|
end
|
102
94
|
end
|
95
|
+
|
96
|
+
# Reads all data from the source IO and writes it to the target IO
|
97
|
+
def self.copy_data(source, target, **opts)
|
98
|
+
while (data = source.readpartial(BLOCK_SIZE))
|
99
|
+
target.write(data)
|
100
|
+
end
|
101
|
+
rescue EOFError # rubocop:disable Lint/HandleExceptions
|
102
|
+
# All read
|
103
|
+
ensure
|
104
|
+
target.close_write if opts[:close_target]
|
105
|
+
end
|
103
106
|
end
|
104
107
|
end
|
105
108
|
end
|
data/lib/yle_tf/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yle_tf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yleisradio
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2018-01-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
version: '0'
|
141
141
|
requirements: []
|
142
142
|
rubyforge_project:
|
143
|
-
rubygems_version: 2.
|
143
|
+
rubygems_version: 2.7.3
|
144
144
|
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: Tooling for Terraform
|