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.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/bin/tf +1 -0
  3. data/lib/yle_tf/action/builder.rb +2 -0
  4. data/lib/yle_tf/action/command.rb +4 -2
  5. data/lib/yle_tf/action/copy_root_module.rb +2 -0
  6. data/lib/yle_tf/action/generate_vars_file.rb +2 -0
  7. data/lib/yle_tf/action/load_config.rb +9 -1
  8. data/lib/yle_tf/action/terraform_init.rb +14 -36
  9. data/lib/yle_tf/action/tf_hooks.rb +2 -0
  10. data/lib/yle_tf/action/tmpdir.rb +3 -1
  11. data/lib/yle_tf/action/verify_terraform_version.rb +19 -6
  12. data/lib/yle_tf/action/verify_tf_env.rb +2 -0
  13. data/lib/yle_tf/action/write_terraformrc_defaults.rb +4 -2
  14. data/lib/yle_tf/action.rb +2 -0
  15. data/lib/yle_tf/backend.rb +42 -0
  16. data/lib/yle_tf/cli.rb +2 -0
  17. data/lib/yle_tf/config/defaults.rb +19 -11
  18. data/lib/yle_tf/config/erb.rb +2 -0
  19. data/lib/yle_tf/config/file.rb +2 -0
  20. data/lib/yle_tf/config/loader.rb +89 -59
  21. data/lib/yle_tf/config/migration.rb +110 -0
  22. data/lib/yle_tf/config.rb +25 -9
  23. data/lib/yle_tf/error.rb +2 -0
  24. data/lib/yle_tf/helpers/hash.rb +22 -0
  25. data/lib/yle_tf/logger/colorize.rb +2 -0
  26. data/lib/yle_tf/logger.rb +2 -0
  27. data/lib/yle_tf/plugin/action_hook.rb +2 -0
  28. data/lib/yle_tf/plugin/loader.rb +8 -1
  29. data/lib/yle_tf/plugin/manager.rb +3 -0
  30. data/lib/yle_tf/plugin.rb +6 -2
  31. data/lib/yle_tf/system/io_handlers.rb +4 -0
  32. data/lib/yle_tf/system/output_logger.rb +2 -0
  33. data/lib/yle_tf/system/tf_hook_output_logger.rb +2 -0
  34. data/lib/yle_tf/system.rb +3 -1
  35. data/lib/yle_tf/tf_hook/runner.rb +2 -0
  36. data/lib/yle_tf/tf_hook.rb +11 -9
  37. data/lib/yle_tf/vars_file.rb +16 -3
  38. data/lib/yle_tf/version.rb +3 -1
  39. data/lib/yle_tf/version_requirement.rb +2 -5
  40. data/lib/yle_tf.rb +4 -0
  41. data/lib/yle_tf_plugins/backends/{s3 → __default}/plugin.rb +6 -4
  42. data/lib/yle_tf_plugins/backends/file/{command.rb → backend.rb} +12 -13
  43. data/lib/yle_tf_plugins/backends/file/plugin.rb +4 -2
  44. data/lib/yle_tf_plugins/commands/__default/command.rb +2 -0
  45. data/lib/yle_tf_plugins/commands/__default/plugin.rb +2 -0
  46. data/lib/yle_tf_plugins/commands/_config/command.rb +2 -0
  47. data/lib/yle_tf_plugins/commands/_config/plugin.rb +2 -0
  48. data/lib/yle_tf_plugins/commands/_shell/command.rb +2 -0
  49. data/lib/yle_tf_plugins/commands/_shell/plugin.rb +2 -0
  50. data/lib/yle_tf_plugins/commands/help/command.rb +2 -0
  51. data/lib/yle_tf_plugins/commands/help/plugin.rb +2 -0
  52. data/lib/yle_tf_plugins/commands/version/command.rb +2 -0
  53. data/lib/yle_tf_plugins/commands/version/plugin.rb +2 -0
  54. metadata +41 -16
  55. data/lib/yle_tf/backend_config.rb +0 -41
  56. data/lib/yle_tf_plugins/backends/file/config.rb +0 -17
  57. data/lib/yle_tf_plugins/backends/s3/command.rb +0 -19
  58. data/lib/yle_tf_plugins/backends/swift/command.rb +0 -18
  59. 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,17 +0,0 @@
1
- require 'yle_tf/backend_config'
2
-
3
- module YleTfPlugins
4
- module Backends
5
- module File
6
- class Config < YleTf::BackendConfig
7
- def generate_config
8
- yield if block_given?
9
- end
10
-
11
- def cli_args
12
- nil
13
- end
14
- end
15
- end
16
- end
17
- 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
@@ -1,16 +0,0 @@
1
- require 'yle_tf'
2
-
3
- module YleTfPlugins
4
- module Backends
5
- module Swift
6
- class Plugin < YleTf::Plugin
7
- register
8
-
9
- backend('swift') do
10
- require_relative 'command'
11
- Command
12
- end
13
- end
14
- end
15
- end
16
- end