Class: HammerCLIKatello::ContentOverrideBase::ContentOverrideCommand

Inherits:
SingleResourceCommand
  • Object
show all
Defined in:
lib/hammer_cli_katello/content_override.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ResolverCommons

included

Class Method Details

.setupObject



4
5
6
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
34
# File 'lib/hammer_cli_katello/content_override.rb', line 4

def self.setup
  desc _("Override product content defaults")
  command_name "content-override"

  success_message _("Updated content override.")
  failure_message _("Could not update content override")

  option "--content-label", "CONTENT_LABEL", _("Label of the content"),
         :attribute_name => :option_content_label, :required => true

  option "--override-name", "OVERRIDE_NAME", _("Override parameter key or name.\n" \
                             "To enable or disable a repo select 'enabled'.\n" \
                             "Default value: enabled"),
         :attribute_name => :option_override_name, :default => "enabled"

  option "--value", "VALUE", _("Override value. " \
                               "Note for repo enablement you can use a boolean value"),
         :attribute_name => :option_value, :required => false

  option ["--remove"], :flag, _("Remove a content override")

  validate_options do
    any(:option_remove, :option_value).required

    if option(:option_remove).exist?
      option(:option_value).rejected
    elsif option(:option_value).exist?
      option(:option_remove).rejected
    end
  end
end

Instance Method Details

#request_paramsObject



36
37
38
39
40
41
42
43
44
45
# File 'lib/hammer_cli_katello/content_override.rb', line 36

def request_params
  super.tap do |opts|
    opts.delete('content_override')
    override = { 'content_label' =>  }
    override['value'] = option_value if option_value
    override['remove'] = true if option_remove?
    override['name'] = option_override_name
    opts['content_overrides'] = [override]
  end
end