yle_tf 0.4.0 → 1.3.0

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 +2 -1
  3. data/lib/yle_tf.rb +4 -0
  4. data/lib/yle_tf/action.rb +4 -0
  5. data/lib/yle_tf/action/builder.rb +2 -0
  6. data/lib/yle_tf/action/command.rb +4 -2
  7. data/lib/yle_tf/action/copy_root_module.rb +2 -0
  8. data/lib/yle_tf/action/generate_vars_file.rb +2 -0
  9. data/lib/yle_tf/action/load_config.rb +9 -1
  10. data/lib/yle_tf/action/terraform_init.rb +31 -33
  11. data/lib/yle_tf/action/tf_hooks.rb +9 -5
  12. data/lib/yle_tf/action/tmpdir.rb +3 -1
  13. data/lib/yle_tf/action/verify_terraform_version.rb +19 -6
  14. data/lib/yle_tf/action/verify_tf_env.rb +2 -0
  15. data/lib/yle_tf/action/verify_yle_tf_version.rb +36 -0
  16. data/lib/yle_tf/action/write_terraformrc_defaults.rb +4 -2
  17. data/lib/yle_tf/backend.rb +42 -0
  18. data/lib/yle_tf/cli.rb +3 -1
  19. data/lib/yle_tf/config.rb +25 -9
  20. data/lib/yle_tf/config/defaults.rb +22 -11
  21. data/lib/yle_tf/config/erb.rb +2 -0
  22. data/lib/yle_tf/config/file.rb +2 -0
  23. data/lib/yle_tf/config/loader.rb +89 -59
  24. data/lib/yle_tf/config/migration.rb +117 -0
  25. data/lib/yle_tf/error.rb +2 -0
  26. data/lib/yle_tf/helpers/hash.rb +22 -0
  27. data/lib/yle_tf/logger.rb +2 -10
  28. data/lib/yle_tf/logger/colorize.rb +2 -0
  29. data/lib/yle_tf/plugin.rb +6 -2
  30. data/lib/yle_tf/plugin/action_hook.rb +2 -0
  31. data/lib/yle_tf/plugin/loader.rb +9 -2
  32. data/lib/yle_tf/plugin/manager.rb +3 -0
  33. data/lib/yle_tf/system.rb +5 -2
  34. data/lib/yle_tf/system/io_handlers.rb +5 -1
  35. data/lib/yle_tf/system/output_logger.rb +2 -0
  36. data/lib/yle_tf/system/tf_hook_output_logger.rb +2 -0
  37. data/lib/yle_tf/tf_hook.rb +11 -9
  38. data/lib/yle_tf/tf_hook/runner.rb +2 -0
  39. data/lib/yle_tf/vars_file.rb +16 -3
  40. data/lib/yle_tf/version.rb +3 -1
  41. data/lib/yle_tf/version_requirement.rb +2 -5
  42. data/lib/yle_tf_plugins/backends/{s3 → __default}/plugin.rb +6 -4
  43. data/lib/yle_tf_plugins/backends/file/{command.rb → backend.rb} +12 -13
  44. data/lib/yle_tf_plugins/backends/file/plugin.rb +4 -2
  45. data/lib/yle_tf_plugins/commands/__default/command.rb +2 -0
  46. data/lib/yle_tf_plugins/commands/__default/plugin.rb +2 -0
  47. data/lib/yle_tf_plugins/commands/_config/command.rb +2 -0
  48. data/lib/yle_tf_plugins/commands/_config/plugin.rb +2 -0
  49. data/lib/yle_tf_plugins/commands/_shell/command.rb +2 -0
  50. data/lib/yle_tf_plugins/commands/_shell/plugin.rb +2 -0
  51. data/lib/yle_tf_plugins/commands/help/command.rb +2 -0
  52. data/lib/yle_tf_plugins/commands/help/plugin.rb +2 -0
  53. data/lib/yle_tf_plugins/commands/version/command.rb +2 -0
  54. data/lib/yle_tf_plugins/commands/version/plugin.rb +2 -0
  55. metadata +61 -20
  56. data/lib/yle_tf/backend_config.rb +0 -41
  57. data/lib/yle_tf_plugins/backends/file/config.rb +0 -17
  58. data/lib/yle_tf_plugins/backends/s3/command.rb +0 -19
  59. data/vendor/logger_level_patch.rb +0 -29
@@ -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,29 +0,0 @@
1
- require 'logger'
2
-
3
- class YleTf
4
- module LoggerLevelPatch
5
- # Taken from Ruby 2.4.1
6
- def level=(severity)
7
- if severity.is_a?(Integer)
8
- @level = severity
9
- else
10
- case severity.to_s.downcase
11
- when 'debug'.freeze
12
- @level = ::Logger::DEBUG
13
- when 'info'.freeze
14
- @level = ::Logger::INFO
15
- when 'warn'.freeze
16
- @level = ::Logger::WARN
17
- when 'error'.freeze
18
- @level = ::Logger::ERROR
19
- when 'fatal'.freeze
20
- @level = ::Logger::FATAL
21
- when 'unknown'.freeze
22
- @level = ::Logger::UNKNOWN
23
- else
24
- raise ArgumentError, "invalid log level: #{severity}"
25
- end
26
- end
27
- end
28
- end
29
- end