Exception: Machinery::Errors::MissingExtractedFiles

Inherits:
SystemDescriptionError show all
Defined in:
lib/exceptions.rb

Instance Method Summary collapse

Constructor Details

#initialize(description, scopes) ⇒ MissingExtractedFiles

Returns a new instance of MissingExtractedFiles.



68
69
70
71
# File 'lib/exceptions.rb', line 68

def initialize(description, scopes)
  @description = description
  @scopes = scopes
end

Instance Method Details

#to_sObject



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
# File 'lib/exceptions.rb', line 73

def to_s
  hostname = @scopes.map do |s|
    @description[s].meta.hostname if @description[s].meta
  end.compact.first || "<HOSTNAME>"
  formatted_scopes = Machinery::Ui.internal_scope_list_to_string(@scopes)

  if @description["environment"]["system_type"] == "docker"
    inspect_cmd = "inspect-container"
  else
    inspect_cmd = "inspect"
  end

  cmd = "#{Ui::Hint.program_name} #{inspect_cmd} --extract-files " \
    "--scope=#{formatted_scopes.delete(" ")}"
  cmd += " --name='#{@description.name}'" if hostname != @description.name
  cmd += " #{hostname}"

  if @scopes.count > 1
    output = "The following scopes '#{formatted_scopes}' are part of the system description"
  else
    output = "The scope '#{formatted_scopes}' is part of the system description"
  end
  output += " but the corresponding files weren't extracted during inspection.\n" \
  "The files are required to continue with this command." \
  " Run `#{cmd}` to extract them."
end