Class: OsCtl::Cli::Repository
Constant Summary
collapse
- FIELDS =
%i[pool name url enabled].freeze
- IMAGE_FIELDS =
%i[vendor variant arch distribution version tags cached].freeze
- IMAGE_FILTERS =
%i[vendor variant arch distribution version tag cached].freeze
Instance Method Summary
collapse
Methods included from Attributes
#do_set_attr, #do_unset_attr
Methods included from Assets
#print_assets
Methods inherited from Command
#cli_opt, #format_output, #osctld_call, #osctld_fmt, #osctld_open, #osctld_resp, run
Instance Method Details
#add ⇒ Object
58
59
60
61
|
# File 'lib/osctl/cli/repository.rb', line 58
def add
require_args!('name', 'url')
osctld_fmt(:repo_add, cmd_opts: { pool: gopts[:pool], name: args[0], url: args[1] })
end
|
#assets ⇒ Object
102
103
104
105
|
# File 'lib/osctl/cli/repository.rb', line 102
def assets
require_args!('name')
print_assets(:repo_assets, name: args[0], pool: gopts[:pool])
end
|
#delete ⇒ Object
63
64
65
66
|
# File 'lib/osctl/cli/repository.rb', line 63
def delete
require_args!('name')
osctld_fmt(:repo_delete, cmd_opts: { pool: gopts[:pool], name: args[0] })
end
|
#disable ⇒ Object
73
74
75
76
|
# File 'lib/osctl/cli/repository.rb', line 73
def disable
require_args!('name')
osctld_fmt(:repo_disable, cmd_opts: { pool: gopts[:pool], name: args[0] })
end
|
#enable ⇒ Object
68
69
70
71
|
# File 'lib/osctl/cli/repository.rb', line 68
def enable
require_args!('name')
osctld_fmt(:repo_enable, cmd_opts: { pool: gopts[:pool], name: args[0] })
end
|
#image_list ⇒ Object
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
# File 'lib/osctl/cli/repository.rb', line 107
def image_list
param_selector = OsCtl::Lib::Cli::ParameterSelector.new(
all_params: IMAGE_FIELDS
)
if opts[:list]
puts param_selector
return
end
require_args!('name')
cmd_opts = { pool: gopts[:pool], name: args[0] }
IMAGE_FILTERS.each do |v|
cmd_opts[v] = opts[v] if opts[v]
end
cmd_opts[:cached] = true if opts[:cached]
cmd_opts[:cached] = false if opts[:uncached]
fmt_opts = {
layout: :columns,
cols: param_selector.parse_option(opts[:output]),
sort: opts[:sort] && param_selector.parse_option(opts[:sort]),
opts: {
tags: {
label: 'TAGS',
align: 'left',
display: proc { |values| values.join(',') }
}
}
}
fmt_opts[:header] = false if opts['hide-header']
osctld_fmt(:repo_image_list, cmd_opts:, fmt_opts:)
end
|
#list ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/osctl/cli/repository.rb', line 12
def list
param_selector = OsCtl::Lib::Cli::ParameterSelector.new(
all_params: FIELDS
)
if opts[:list]
puts param_selector
return
end
cmd_opts = { pool: gopts[:pool] }
fmt_opts = {
layout: :columns,
cols: param_selector.parse_option(opts[:output])
}
cmd_opts[:names] = args if args.count > 0
fmt_opts[:header] = false if opts['hide-header']
osctld_fmt(:repo_list, cmd_opts:, fmt_opts:)
end
|
#set_attr ⇒ Object
83
84
85
86
87
88
89
90
91
|
# File 'lib/osctl/cli/repository.rb', line 83
def set_attr
require_args!('name', 'attribute', 'value')
do_set_attr(
:repo_set,
{ name: args[0], pool: gopts[:pool] },
args[1],
args[2]
)
end
|
#set_url ⇒ Object
78
79
80
81
|
# File 'lib/osctl/cli/repository.rb', line 78
def set_url
require_args!('name', 'url')
osctld_fmt(:repo_set, cmd_opts: { name: args[0], pool: gopts[:pool], url: args[1] })
end
|
#show ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/osctl/cli/repository.rb', line 35
def show
param_selector = OsCtl::Lib::Cli::ParameterSelector.new(
all_params: FIELDS
)
if opts[:list]
puts param_selector
return
end
require_args!('name')
cmd_opts = { name: args[0], pool: gopts[:pool] }
fmt_opts = {
layout: :rows,
cols: param_selector.parse_option(opts[:output])
}
fmt_opts[:header] = false if opts['hide-header']
osctld_fmt(:repo_show, cmd_opts:, fmt_opts:)
end
|
#unset_attr ⇒ Object
93
94
95
96
97
98
99
100
|
# File 'lib/osctl/cli/repository.rb', line 93
def unset_attr
require_args!('name', 'attribute')
do_unset_attr(
:repo_unset,
{ name: args[0], pool: gopts[:pool] },
args[1]
)
end
|