Class: Mixlib::Install::Cli

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/mixlib/install/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/mixlib/install/cli.rb', line 23

def self.exit_on_failure?
  true
end

Instance Method Details

#download(product_name) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/mixlib/install/cli.rb', line 69

def download(product_name)
  # Set mininum options
  mixlib_install_options = {
    channel: options[:channel].to_sym,
    product_name: product_name,
    product_version: options[:version],
    platform_version_compatibility_mode: options[:platform_version_compat],
    architecture: options[:architecture],
  }.tap do |opt|
    opt[:platform] = options[:platform] if options[:platform]
    opt[:platform_version] = options[:platform_version] if options[:platform_version]
  end

  # auto detect platform options if not configured
  if options[:platform].nil? && options[:platform_version].nil?
    mixlib_install_options.merge!(Mixlib::Install.detect_platform)
  end

  installer = Mixlib::Install.new(mixlib_install_options)

  begin
    artifact = installer.artifact_info
  rescue Mixlib::Install::Backend::ArtifactsNotFound => e
    abort e.message
  end

  if options[:url]
    say artifact.url
  else
    say "Starting download #{artifact.url}"
    file = installer.download_artifact(options[:directory])
    say "Download saved to #{file}"
  end

  say JSON.pretty_generate(artifact.to_hash) if options[:attributes]
end

#install_scriptObject



117
118
119
120
121
122
123
124
125
126
127
# File 'lib/mixlib/install/cli.rb', line 117

def install_script
  context = {}
  context[:base_url] = options[:endpoint] if options[:endpoint]
  script = eval("Mixlib::Install.install_#{options[:type]}(context)")
  if options[:file]
    File.open(options[:file], "w") { |io| io.write(script) }
    say "Script written to #{options[:file]}"
  else
    say script
  end
end

#list_versions(product_name, channel) ⇒ Object



34
35
36
# File 'lib/mixlib/install/cli.rb', line 34

def list_versions(product_name, channel)
  say Mixlib::Install.available_versions(product_name, channel).join("\n")
end

#versionObject



28
29
30
31
# File 'lib/mixlib/install/cli.rb', line 28

def version
  require_relative "version"
  say Mixlib::Install::VERSION
end