Module: HammerCLIKatello::ContentImport::ContentImportCommon

Included in:
LibraryCommand, VersionCommand
Defined in:
lib/hammer_cli_katello/content_import.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/hammer_cli_katello/content_import.rb', line 7

def self.included(base)
  base.option "--metadata-file",
          "METADATA_FILE", _("Location of the metadata.json file. "\
                             "This is not required if the metadata.json file"\
                             " is already in the archive directory."),
           :attribute_name => :option_metadata_file,
           :required => false

  base.build_options do |o|
    o.expand(:all).including(:organizations).except(:metadata)
  end

  base.validate_options do
    option(:option_path).required

     = option(:option_metadata_file).value ||
                    File.join(option(:option_path).value, "metadata.json")
    unless File.exist?()
      msg = _("Unable to find '#{}'. "\
               "If the metadata.json file is at a different location "\
               "provide it to the --metadata-file option ")
      raise HammerCLI::Options::Validators::ValidationError, msg
    end
  end
  base.success_message _("Archive is being imported in task %{id}.")
  base.failure_message _("Could not import the archive.")
end

Instance Method Details

#request_paramsObject



35
36
37
38
39
40
# File 'lib/hammer_cli_katello/content_import.rb', line 35

def request_params
  super.tap do |opts|
     =  || File.join(option_path, "metadata.json")
    opts["metadata"] = JSON.parse(File.read())
  end
end