Method: TFWrapper::RakeTasks#initialize
- Defined in:
- lib/tfwrapper/raketasks.rb
#initialize(tf_dir, opts = {}) ⇒ RakeTasks
Generate Rake tasks for working with Terraform.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/tfwrapper/raketasks.rb', line 95 def initialize(tf_dir, opts = {}) # find the directory that contains the Rakefile rakedir = File.realpath(Rake.application.rakefile) rakedir = File.dirname(rakedir) if File.file?(rakedir) @tf_dir = File.realpath(File.join(rakedir, tf_dir)) @ns_prefix = opts.fetch(:namespace_prefix, nil) @consul_env_vars_prefix = opts.fetch(:consul_env_vars_prefix, nil) @tf_vars_from_env = opts.fetch(:tf_vars_from_env, {}) @allowed_empty_vars = opts.fetch(:allowed_empty_vars, []) @tf_sensitive_vars = opts.fetch(:tf_sensitive_vars, []) @tf_extra_vars = opts.fetch(:tf_extra_vars, {}) @backend_config = opts.fetch(:backend_config, {}) @consul_url = opts.fetch(:consul_url, nil) @disable_landscape = opts.fetch(:disable_landscape, false) @landscape_progress = opts.fetch(:landscape_progress, nil) unless [:dots, :lines, :stream, nil].include?(@landscape_progress) raise( ArgumentError, 'landscape_progress option must be one of: ' \ '[:dots, :lines, :stream, nil]' ) end @before_proc = opts.fetch(:before_proc, nil) if !@before_proc.nil? && !@before_proc.is_a?(Proc) raise( TypeError, 'TFWrapper::RakeTasks.initialize option :before_proc must be a ' \ 'Proc instance, not a ' + @before_proc.class.name ) end @after_proc = opts.fetch(:after_proc, nil) if !@after_proc.nil? && !@after_proc.is_a?(Proc) raise( TypeError, 'TFWrapper::RakeTasks.initialize option :after_proc must be a Proc ' \ 'instance, not a ' + @after_proc.class.name ) end # default to lowest possible version; this is set in the 'init' task @tf_version = Gem::Version.new('0.0.0') # rubocop:disable Style/GuardClause if @consul_url.nil? && !@consul_env_vars_prefix.nil? raise StandardError, 'Cannot set env vars in Consul when consul_url ' \ 'option is nil.' end # rubocop:enable Style/GuardClause end |