yle_tf 1.0.0 → 1.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/tf +1 -0
- data/lib/yle_tf/action/builder.rb +2 -0
- data/lib/yle_tf/action/command.rb +4 -2
- data/lib/yle_tf/action/copy_root_module.rb +2 -0
- data/lib/yle_tf/action/generate_vars_file.rb +2 -0
- data/lib/yle_tf/action/load_config.rb +9 -1
- data/lib/yle_tf/action/terraform_init.rb +14 -36
- data/lib/yle_tf/action/tf_hooks.rb +2 -0
- data/lib/yle_tf/action/tmpdir.rb +3 -1
- data/lib/yle_tf/action/verify_terraform_version.rb +19 -6
- data/lib/yle_tf/action/verify_tf_env.rb +2 -0
- data/lib/yle_tf/action/write_terraformrc_defaults.rb +4 -2
- data/lib/yle_tf/action.rb +2 -0
- data/lib/yle_tf/backend.rb +42 -0
- data/lib/yle_tf/cli.rb +2 -0
- data/lib/yle_tf/config/defaults.rb +19 -11
- data/lib/yle_tf/config/erb.rb +2 -0
- data/lib/yle_tf/config/file.rb +2 -0
- data/lib/yle_tf/config/loader.rb +89 -59
- data/lib/yle_tf/config/migration.rb +110 -0
- data/lib/yle_tf/config.rb +25 -9
- data/lib/yle_tf/error.rb +2 -0
- data/lib/yle_tf/helpers/hash.rb +22 -0
- data/lib/yle_tf/logger/colorize.rb +2 -0
- data/lib/yle_tf/logger.rb +2 -0
- data/lib/yle_tf/plugin/action_hook.rb +2 -0
- data/lib/yle_tf/plugin/loader.rb +8 -1
- data/lib/yle_tf/plugin/manager.rb +3 -0
- data/lib/yle_tf/plugin.rb +6 -2
- data/lib/yle_tf/system/io_handlers.rb +4 -0
- data/lib/yle_tf/system/output_logger.rb +2 -0
- data/lib/yle_tf/system/tf_hook_output_logger.rb +2 -0
- data/lib/yle_tf/system.rb +3 -1
- data/lib/yle_tf/tf_hook/runner.rb +2 -0
- data/lib/yle_tf/tf_hook.rb +11 -9
- data/lib/yle_tf/vars_file.rb +16 -3
- data/lib/yle_tf/version.rb +3 -1
- data/lib/yle_tf/version_requirement.rb +2 -5
- data/lib/yle_tf.rb +4 -0
- data/lib/yle_tf_plugins/backends/{s3 → __default}/plugin.rb +6 -4
- data/lib/yle_tf_plugins/backends/file/{command.rb → backend.rb} +12 -13
- data/lib/yle_tf_plugins/backends/file/plugin.rb +4 -2
- data/lib/yle_tf_plugins/commands/__default/command.rb +2 -0
- data/lib/yle_tf_plugins/commands/__default/plugin.rb +2 -0
- data/lib/yle_tf_plugins/commands/_config/command.rb +2 -0
- data/lib/yle_tf_plugins/commands/_config/plugin.rb +2 -0
- data/lib/yle_tf_plugins/commands/_shell/command.rb +2 -0
- data/lib/yle_tf_plugins/commands/_shell/plugin.rb +2 -0
- data/lib/yle_tf_plugins/commands/help/command.rb +2 -0
- data/lib/yle_tf_plugins/commands/help/plugin.rb +2 -0
- data/lib/yle_tf_plugins/commands/version/command.rb +2 -0
- data/lib/yle_tf_plugins/commands/version/plugin.rb +2 -0
- metadata +41 -16
- data/lib/yle_tf/backend_config.rb +0 -41
- data/lib/yle_tf_plugins/backends/file/config.rb +0 -17
- data/lib/yle_tf_plugins/backends/s3/command.rb +0 -19
- data/lib/yle_tf_plugins/backends/swift/command.rb +0 -18
- data/lib/yle_tf_plugins/backends/swift/plugin.rb +0 -16
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
class YleTf
|
4
|
-
class BackendConfig
|
5
|
-
BACKEND_CONFIG_FILE = '_backend.tf.json'.freeze
|
6
|
-
|
7
|
-
attr_reader :type, :config
|
8
|
-
|
9
|
-
def initialize(type, config)
|
10
|
-
@type = type
|
11
|
-
@config = config
|
12
|
-
end
|
13
|
-
|
14
|
-
# Returns an `Array` of CLI args for Terraform pre 0.9 `init` command
|
15
|
-
def cli_args
|
16
|
-
args = ["-backend=#{type}"]
|
17
|
-
config.each do |key, value|
|
18
|
-
args << "-backend-config=#{key}=#{value}"
|
19
|
-
end
|
20
|
-
args
|
21
|
-
end
|
22
|
-
|
23
|
-
# Generate backend configuration file for Terraform v0.9+
|
24
|
-
def generate_config
|
25
|
-
data = {
|
26
|
-
terraform: [{
|
27
|
-
backend: [to_h]
|
28
|
-
}]
|
29
|
-
}
|
30
|
-
File.write(BACKEND_CONFIG_FILE, JSON.pretty_generate(data))
|
31
|
-
yield if block_given?
|
32
|
-
end
|
33
|
-
|
34
|
-
# Returns the backend configuration as a `Hash` for Terraform v0.9+
|
35
|
-
def to_h
|
36
|
-
{ type => config }
|
37
|
-
end
|
38
|
-
|
39
|
-
alias to_s to_h
|
40
|
-
end
|
41
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'yle_tf/backend_config'
|
2
|
-
|
3
|
-
module YleTfPlugins
|
4
|
-
module Backends
|
5
|
-
module S3
|
6
|
-
class Command
|
7
|
-
def backend_config(config)
|
8
|
-
YleTf::BackendConfig.new(
|
9
|
-
's3',
|
10
|
-
'region' => config.fetch('backend', 'region'),
|
11
|
-
'bucket' => config.fetch('backend', 'bucket'),
|
12
|
-
'key' => config.fetch('backend', 'file'),
|
13
|
-
'encrypt' => config.fetch('backend', 'encrypt')
|
14
|
-
)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'yle_tf/backend_config'
|
2
|
-
|
3
|
-
module YleTfPlugins
|
4
|
-
module Backends
|
5
|
-
module Swift
|
6
|
-
class Command
|
7
|
-
def backend_config(config)
|
8
|
-
YleTf::BackendConfig.new(
|
9
|
-
'swift',
|
10
|
-
'region_name' => config.fetch('backend', 'region'),
|
11
|
-
'container' => config.fetch('backend', 'container'),
|
12
|
-
'archive_container' => config.fetch('backend', 'archive_container') { nil }
|
13
|
-
)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|