13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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
105
106
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
# File 'lib/osctl/image/cli/app.rb', line 13
def setup
Thread.abort_on_exception = true
program_desc 'Build, test and deploy vpsAdminOS images'
version OsCtl::Image::VERSION
subcommand_option_handling :normal
preserve_argv true
arguments :strict
desc 'Path to directory with image build scripts'
flag 'build-scripts', arg_name: 'dir'
desc 'List available images'
command 'ls' do |c|
c.desc 'Select parameters to output'
c.flag %i[o output], arg_name: 'parameters'
c.desc 'Do not show header'
c.switch %i[H hide-header], negatable: false
c.desc 'List available parameters'
c.switch %i[L list], negatable: false
c.desc 'Sort by parameter(s)'
c.flag %i[s sort], arg_name: 'parameters'
c.action(&Command.run(Image, :list))
end
desc 'Build image'
arg_name '<image>[,image...]'
command 'build' do |c|
c.desc 'Output directory'
c.flag 'output-dir', arg_name: 'dir', default_value: 'output'
c.desc 'Build dataset'
c.flag 'build-dataset', arg_name: 'filesystem', required: true
c.desc 'Vendor name'
c.flag 'vendor', arg_name: 'name'
c.desc 'How many images build in parallel'
c.flag 'jobs', arg_name: 'n', type: Integer, default_value: 1
c.action(&Command.run(Image, :build))
end
desc 'Test image'
arg_name '<image>[,image...] [test[,test...]]'
command 'test' do |c|
c.desc 'Output directory'
c.flag 'output-dir', arg_name: 'dir', default_value: 'output'
c.desc 'Build dataset'
c.flag 'build-dataset', arg_name: 'filesystem', required: true
c.desc 'Vendor name'
c.flag 'vendor', arg_name: 'name'
c.desc 'Force image rebuild'
c.switch 'rebuild'
c.desc 'Keep containers from failed tests'
c.switch 'keep-failed'
c.action(&Command.run(Image, :test))
end
desc 'Build the image and use it in a container'
arg_name '<image>'
command 'instantiate' do |c|
c.desc 'Output directory'
c.flag 'output-dir', arg_name: 'dir', default_value: 'output'
c.desc 'Build dataset'
c.flag 'build-dataset', arg_name: 'filesystem', required: true
c.desc 'Vendor name'
c.flag 'vendor', arg_name: 'name'
c.desc 'Force image rebuild'
c.switch 'rebuild'
c.desc 'Instantiate in an existing container'
c.flag 'container', arg_name: 'ctid'
c.action(&Command.run(Image, :instantiate))
end
desc 'Build image, test it and deploy to repository'
arg_name '<image>[,image...] <repository>'
command 'deploy' do |c|
c.desc 'Output directory'
c.flag 'output-dir', arg_name: 'dir', default_value: 'output'
c.desc 'Build dataset'
c.flag 'build-dataset', arg_name: 'filesystem', required: true
c.desc 'Vendor name'
c.flag 'vendor', arg_name: 'name'
c.desc 'Tags'
c.flag 'tag', multiple: true
c.desc 'How many images build in parallel'
c.flag 'jobs', arg_name: 'n', type: Integer, default_value: 1
c.desc 'Force image rebuild'
c.switch 'rebuild'
c.desc 'Skip tests'
c.switch 'skip-tests'
c.desc 'Keep containers from failed tests'
c.switch 'keep-failed'
c.action(&Command.run(Image, :deploy))
end
desc 'Manage build and test containers'
command 'ct' do |ct|
ct.desc 'List managed containers'
ct.command :ls do |c|
c.desc 'Select parameters to output'
c.flag %i[o output], arg_name: 'parameters'
c.desc 'Do not show header'
c.switch %i[H hide-header], negatable: false
c.desc 'List available parameters'
c.switch %i[L list], negatable: false
c.desc 'Sort by parameter(s)'
c.flag %i[s sort], arg_name: 'parameters'
c.action(&Command.run(Containers, :list))
end
ct.desc 'Delete managed containers'
ct.arg_name '[ctid...]'
ct.command :del do |c|
c.desc 'Delete containers of selected type'
c.flag 'type', must_match: %w[builder test instance]
c.desc 'Do not ask and immediately delete the containers'
c.switch %w[f force]
c.action(&Command.run(Containers, :delete))
end
end
end
|