class Bcome::Terraform::Output
Constants
- OUTPUT_COMMAND
Public Class Methods
new(namespace)
click to toggle source
# File lib/objects/terraform/output.rb, line 9 def initialize(namespace) @namespace = namespace end
Public Instance Methods
output()
click to toggle source
# File lib/objects/terraform/output.rb, line 13 def output @output ||= get_output end
Private Instance Methods
do_get_output()
click to toggle source
# File lib/objects/terraform/output.rb, line 41 def do_get_output ::Bcome::Command::Local.run(get_output_command) end
get_output()
click to toggle source
# File lib/objects/terraform/output.rb, line 23 def get_output get_output_result = do_get_output # Until this feature is officially featured, failure to get terraform data will fail silently # One thing not decided upon yet is how to indicate that we wish to load terraform data or not. if get_output_result.failed? raise "Received authorisation error retrieving metadata from Terraform outputs for namespace #{@namespace}. Command was '#{get_output_command}'. Are you authorised to access the TFstate?" if get_output_result.stderr =~ /HTTP response code 401/ return {} end JSON.parse(get_output_result.stdout) end
get_output_command()
click to toggle source
# File lib/objects/terraform/output.rb, line 37 def get_output_command "cd #{terraform_installation_path} ; #{OUTPUT_COMMAND}" end
terraform_installation_path()
click to toggle source
# File lib/objects/terraform/output.rb, line 19 def terraform_installation_path @terraform_installation_path ||= "terraform/environments/#{@namespace.gsub(':', '_')}" end