class TerraformWrapper::Shared::Binary
Attributes
base[R]
directory[R]
name[RW]
platform[R]
provider[R]
version[R]
Public Class Methods
new(options:, provider:)
click to toggle source
# File lib/terraform-wrapper/shared/binary.rb, line 31 def initialize(options:, provider:) logger.fatal("Binary base path must be a string!") unless options["base"].kind_of?(String) logger.fatal("Binary base path must not be blank!") if options["base"].strip.empty? @base = options["base"] logger.fatal("Binary version must be a string!") unless options["version"].kind_of?(String) logger.fatal("Binary version must not be blank!") if options["version"].strip.empty? @version = options["version"] @platform = platform_detect @directory = File.join(@base, @version, @platform) @provider = provider @name = "terraform" end
Public Instance Methods
check()
click to toggle source
# File lib/terraform-wrapper/shared/binary.rb, line 50 def check() result = false if exists and executable then result = system("\"#{path}\" version") || false end return result end
executable()
click to toggle source
# File lib/terraform-wrapper/shared/binary.rb, line 68 def executable() return File.executable?(path) end
exists()
click to toggle source
# File lib/terraform-wrapper/shared/binary.rb, line 62 def exists() return File.exist?(path) end
path()
click to toggle source
# File lib/terraform-wrapper/shared/binary.rb, line 74 def path() return File.join(@directory, @name) end
Private Instance Methods
platform_detect()
click to toggle source
# File lib/terraform-wrapper/shared/binary.rb, line 84 def platform_detect return "darwin" if platform_is_mac return "linux" if platform_is_linux logger.fatal("Platform is NOT supported: #{RUBY_PLATFORM}") end
platform_is_linux()
click to toggle source
# File lib/terraform-wrapper/shared/binary.rb, line 98 def platform_is_linux RUBY_PLATFORM =~ /linux/ end
platform_is_mac()
click to toggle source
# File lib/terraform-wrapper/shared/binary.rb, line 92 def platform_is_mac RUBY_PLATFORM =~ /darwin/ end