forked from chaosblade-io/chaosblade-exec-cri
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.go
518 lines (445 loc) · 21.7 KB
/
model.go
1
2
3
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
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
/*
* Copyright 1999-2019 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package exec
import (
"fmt"
"github.com/chaosblade-io/chaosblade-exec-os/exec/cpu"
"github.com/chaosblade-io/chaosblade-exec-os/exec/disk"
"github.com/chaosblade-io/chaosblade-exec-os/exec/file"
"github.com/chaosblade-io/chaosblade-exec-os/exec/mem"
"github.com/chaosblade-io/chaosblade-exec-os/exec/network"
"github.com/chaosblade-io/chaosblade-exec-os/exec/network/tc"
"github.com/chaosblade-io/chaosblade-exec-os/exec/process"
"github.com/chaosblade-io/chaosblade-spec-go/spec"
)
type ResourceExpModelSpec interface {
// Scope
Scope() string
// ExpModels returns the map of the experiment name and the model
ExpModels() map[string]spec.ExpModelCommandSpec
// GetExpActionModelSpec returns the action spec
GetExpActionModelSpec(target, action string) spec.ExpActionCommandSpec
}
func newNetworkCommandModelSpecForDocker() spec.ExpModelCommandSpec {
networkCommandModelSpec := network.NewNetworkCommandSpec()
for _, action := range networkCommandModelSpec.Actions() {
v := interface{}(action)
switch v.(type) {
case *tc.DelayActionSpec:
action.SetExample(
`# Access to native 8080 and 8081 ports is delayed by 3 seconds, and the delay time fluctuates by 1 second
blade create cri network delay --time 3000 --offset 1000 --interface eth0 --local-port 8080,8081 --container-id ee54f1e61c08
# Local access to external 14.215.177.39 machine (ping www.baidu.com obtained IP) port 80 delay of 3 seconds
blade create cri network delay --time 3000 --interface eth0 --remote-port 80 --destination-ip 14.215.177.39 --container-id ee54f1e61c08
# Do a 5 second delay for the entire network card eth0, excluding ports 22 and 8000 to 8080
blade create cri network delay --time 5000 --interface eth0 --exclude-port 22,8000-8080 --container-id ee54f1e61c08`)
case *network.DropActionSpec:
action.SetExample(
`# Block incoming connection from the port 80
blade create cri network drop --source-port 80 --network-traffic in --container-id ee54f1e61c08`)
case *network.DnsActionSpec:
action.SetExample(
`# The domain name www.baidu.com is not accessible
blade create cri network dns --domain www.baidu.com --ip 10.0.0.0 --container-id ee54f1e61c08`)
case *tc.LossActionSpec:
action.SetExample(`# Access to native 8080 and 8081 ports lost 70% of packets
blade create cri network loss --percent 70 --interface eth0 --local-port 8080,8081 --container-id ee54f1e61c08
# The machine accesses external 14.215.177.39 machine (ping www.baidu.com) 80 port packet loss rate 100%
blade create cri network loss --percent 100 --interface eth0 --remote-port 80 --destination-ip 14.215.177.39 --container-id ee54f1e61c08
# Do 60% packet loss for the entire network card Eth0, excluding ports 22 and 8000 to 8080
blade create cri network loss --percent 60 --interface eth0 --exclude-port 22,8000-8080 --container-id ee54f1e61c08
# Realize the whole network card is not accessible, not accessible time 20 seconds. After executing the following command, the current network is disconnected and restored in 20 seconds. Remember!! Don't forget -timeout parameter
blade create cri network loss --percent 100 --interface eth0 --timeout 20 --container-id ee54f1e61c08`)
case *tc.DuplicateActionSpec:
action.SetExample(`# Specify the network card eth0 and repeat the packet by 10%
blade create cri network duplicate --percent=10 --interface=eth0 --container-id ee54f1e61c08`)
case *tc.CorruptActionSpec:
action.SetExample(`# Access to the specified IP request packet is corrupted, 80% of the time
blade create cri network corrupt --percent 80 --destination-ip 180.101.49.12 --interface eth0 --container-id ee54f1e61c08`)
case *tc.ReorderActionSpec:
action.SetExample(`# Access the specified IP request packet disorder
blade create cri network reorder --correlation 80 --percent 50 --gap 2 --time 500 --interface eth0 --destination-ip 180.101.49.12 --container-id ee54f1e61c08`)
case *network.OccupyActionSpec:
action.SetExample(`#Specify port 8080 occupancy
blade create cri network occupy --port 8080 --force --container-id ee54f1e61c08
# The machine accesses external 14.215.177.39 machine (ping www.baidu.com) 80 port packet loss rate 100%
blade create cri network loss --percent 100 --interface eth0 --remote-port 80 --destination-ip 14.215.177.39 --container-id ee54f1e61c08`)
}
}
return networkCommandModelSpec
}
func newFileCommandSpecForDocker() spec.ExpModelCommandSpec {
fileCommandSpec := file.NewFileCommandSpec()
for _, action := range fileCommandSpec.Actions() {
v := interface{}(action)
switch v.(type) {
case *file.FileAppendActionSpec:
action.SetLongDesc("The file append experiment scenario in container")
action.SetExample(
`# Appends the content "HELLO WORLD" to the /home/logs/nginx.log file
blade create cri file append --filepath=/home/logs/nginx.log --content="HELL WORLD" --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
# Appends the content "HELLO WORLD" to the /home/logs/nginx.log file, interval 10 seconds
blade create cri file append --filepath=/home/logs/nginx.log --content="HELL WORLD" --interval 10 --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
# Appends the content "HELLO WORLD" to the /home/logs/nginx.log file, enable base64 encoding
blade create cri file append --filepath=/home/logs/nginx.log --content=SEVMTE8gV09STEQ= --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
# mock interface timeout exception
blade create cri file append --filepath=/home/logs/nginx.log --content="@{DATE:+%Y-%m-%d %H:%M:%S} ERROR invoke getUser timeout [@{RANDOM:100-200}]ms abc mock exception" --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
`)
case *file.FileAddActionSpec:
action.SetLongDesc("The file add experiment scenario in container")
action.SetExample(
`# Create a file named nginx.log in the /home directory
blade create cri file add --filepath /home/nginx.log --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
# Create a file named nginx.log in the /home directory with the contents of HELLO WORLD
blade create cri file add --filepath /home/nginx.log --content "HELLO WORLD" --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
# Create a file named nginx.log in the /temp directory and automatically create directories that don't exist
blade create cri file add --filepath /temp/nginx.log --auto-create-dir --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
# Create a directory named /nginx in the /temp directory and automatically create directories that don't exist
blade create cri file add --directory --filepath /temp/nginx --auto-create-dir --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
`)
case *file.FileChmodActionSpec:
action.SetLongDesc("The file permission modification scenario in container")
action.SetExample(`# Modify /home/logs/nginx.log file permissions to 777
blade create cri file chmod --filepath /home/logs/nginx.log --mark=777 --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
`)
case *file.FileDeleteActionSpec:
action.SetLongDesc("The file delete scenario in container")
action.SetExample(
`# Delete the file /home/logs/nginx.log
blade create cri file delete --filepath /home/logs/nginx.log --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
# Force delete the file /home/logs/nginx.log unrecoverable
blade create cri file delete --filepath /home/logs/nginx.log --force --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
`)
case *file.FileMoveActionSpec:
action.SetExample("The file move scenario in container")
action.SetExample(`# Move the file /home/logs/nginx.log to /tmp
blade create cri file delete --filepath /home/logs/nginx.log --target /tmp --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
# Force Move the file /home/logs/nginx.log to /temp
blade create cri file delete --filepath /home/logs/nginx.log --target /tmp --force --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
# Move the file /home/logs/nginx.log to /temp/ and automatically create directories that don't exist
blade create cri file delete --filepath /home/logs/nginx.log --target /temp --auto-create-dir --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
`)
}
}
return fileCommandSpec
}
func newMemCommandModelSpecForDocker() spec.ExpModelCommandSpec {
memCommandModelSpec := mem.NewMemCommandModelSpec()
for _, action := range memCommandModelSpec.Actions() {
v := interface{}(action)
switch v.(type) {
case *mem.MemLoadActionCommand:
action.SetLongDesc("The memory fill experiment scenario in container")
action.SetExample(
`# The execution memory footprint is 50%
blade create cri mem load --mode ram --mem-percent 50 --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
# The execution memory footprint is 50%, cache model
blade create cri mem load --mode cache --mem-percent 50 --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
# The execution memory footprint is 50%, usage contains buffer/cache
blade create cri mem load --mode ram --mem-percent 50 --include-buffer-cache --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
# The execution memory footprint is 50% for 200 seconds
blade create cri mem load --mode ram --mem-percent 50 --timeout 200 --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
# 200M memory is reserved
blade create cri mem load --mode ram --reserve 200 --rate 100 --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08`)
}
}
return memCommandModelSpec
}
func newDiskFillCommandSpecForDocker() spec.ExpModelCommandSpec {
commandSpec := disk.NewDiskCommandSpec()
for _, action := range commandSpec.Actions() {
v := interface{}(action)
switch v.(type) {
case *disk.FillActionSpec:
action.SetLongDesc("The disk fill scenario experiment in the container")
action.SetExample(
`
# Fill the /home directory with 40G of disk space in the container
blade create cri disk fill --path /home --size 40000 --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
# Fill the /home directory with 80% of the disk space in the container and retains the file handle that populates the disk
blade create cri disk fill --path /home --percent 80 --retain-handle --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
# Perform a fixed-size experimental scenario in the container
blade c cri disk fill --path /home --reserve 1024 --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
`)
case *disk.BurnActionSpec:
action.SetLongDesc("Disk read and write IO load experiment in the container")
action.SetExample(
`# The data of rkB/s, wkB/s and % Util were mainly observed. Perform disk read IO high-load scenarios
blade create cri disk burn --read --path /home --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
# Perform disk write IO high-load scenarios
blade create cri disk burn --write --path /home --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
# Read and write IO load scenarios are performed at the same time. Path is not specified. The default is /
blade create cri disk burn --read --write --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08`)
}
}
return commandSpec
}
func newDiskCommandSpecForDocker() spec.ExpModelCommandSpec {
commandSpec := disk.NewDiskCommandSpec()
for _, action := range commandSpec.Actions() {
v := interface{}(action)
switch v.(type) {
case *disk.FillActionSpec:
action.SetLongDesc("The disk fill scenario experiment in the container")
action.SetExample(
`
# Fill the /home directory with 40G of disk space in the container
blade create cri disk fill --path /home --size 40000 --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
# Fill the /home directory with 80% of the disk space in the container and retains the file handle that populates the disk
blade create cri disk fill --path /home --percent 80 --retain-handle --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
# Perform a fixed-size experimental scenario in the container
blade c cri disk fill --path /home --reserve 1024 --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
`)
case *disk.BurnActionSpec:
action.SetLongDesc("Disk read and write IO load experiment in the container")
action.SetExample(
`# The data of rkB/s, wkB/s and % Util were mainly observed. Perform disk read IO high-load scenarios
blade create cri disk burn --read --path /home --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
# Perform disk write IO high-load scenarios
blade create cri disk burn --write --path /home --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
# Read and write IO load scenarios are performed at the same time. Path is not specified. The default is /
blade create cri disk burn --read --write --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08`)
}
}
return commandSpec
}
func newCpuCommandModelSpecForDocker() spec.ExpModelCommandSpec {
cpuCommandModelSpec := cpu.NewCpuCommandModelSpec()
for _, action := range cpuCommandModelSpec.Actions() {
v := interface{}(action)
switch v.(type) {
case *cpu.FullLoadActionCommand:
action.SetLongDesc("The CPU load experiment scenario in container is the same as the CPU scenario of basic resources")
action.SetExample(
`# Create a CPU full load experiment in the container
blade create cri cpu load --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
#Specifies two random kernel's full load in the container
blade create cri cpu load --cpu-percent 60 --cpu-count 2 --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
# Specifies that the kernel is full load with index 0, 3, and that the kernel's index starts at 0
blade create cri cpu load --cpu-list 0,3 --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
# Specify the kernel full load of indexes 1-3
blade create cri cpu load --cpu-list 1-3 --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
# Specified percentage load in the container
blade create cri cpu load --cpu-percent 60 --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08`)
}
}
return cpuCommandModelSpec
}
func newProcessCommandModelSpecForDocker() spec.ExpModelCommandSpec {
commandModelSpec := process.NewProcessCommandModelSpec()
for _, action := range commandModelSpec.Actions() {
v := interface{}(action)
switch v.(type) {
case *process.KillProcessActionCommandSpec:
action.SetLongDesc("The process scenario in container is the same as the basic resource process scenario")
action.SetExample(
`# Kill the nginx process in the container
blade create cri process kill --process nginx --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
# Specifies the signal and local port to kill the process in the container
blade create cri process kill --local-port 8080 --signal 15 --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08`)
case *process.StopProcessActionCommandSpec:
action.SetLongDesc("The process scenario in container is the same as the basic resource process scenario")
action.SetExample(
`# Pause the process that contains the "nginx" keyword in the container
blade create cri process stop --process nginx --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08
# Pause the Java process in the container
blade create cri process stop --process-cmd java --chaosblade-release /root/chaosblade-0.6.0.tar.gz --container-id ee54f1e61c08`)
}
}
return commandModelSpec
}
type DockerExpModelSpec struct {
ScopeName string
ExpModelSpecs map[string]spec.ExpModelCommandSpec
}
func (b *DockerExpModelSpec) Scope() string {
return b.ScopeName
}
func (b *DockerExpModelSpec) ExpModels() map[string]spec.ExpModelCommandSpec {
return b.ExpModelSpecs
}
func (b *DockerExpModelSpec) GetExpActionModelSpec(target, actionName string) spec.ExpActionCommandSpec {
commandSpec := b.ExpModelSpecs[target]
if commandSpec == nil {
return nil
}
actions := commandSpec.Actions()
if actions == nil {
return nil
}
for _, action := range actions {
if action.Name() == actionName {
return action
}
for _, alias := range action.Aliases() {
if alias == actionName {
return action
}
}
}
return nil
}
func (b *DockerExpModelSpec) addExpModels(expModel ...spec.ExpModelCommandSpec) {
for _, model := range expModel {
b.ExpModelSpecs[model.Name()] = model
}
}
func GetAllExecutors() map[string]spec.Executor {
executors := make(map[string]spec.Executor, 0)
dockerModelSpecs := NewCriExpModelSpec()
for _, expModel := range dockerModelSpecs.ExpModels() {
executorMap := extractExecutorFromExpModel(expModel)
for key, value := range executorMap {
executors[key] = value
}
}
return executors
}
func extractExecutorFromExpModel(expModel spec.ExpModelCommandSpec) map[string]spec.Executor {
executors := make(map[string]spec.Executor)
for _, actionModel := range expModel.Actions() {
executors[GetExecutorKey(expModel.Name(), actionModel.Name())] = actionModel.Executor()
}
return executors
}
var ContainerIdFlag = &spec.ExpFlag{
Name: "container-id",
Desc: "Container id, when used with container-name, container-id is preferred",
NoArgs: false,
Required: false,
RequiredWhenDestroyed: false,
}
var ContainerNameFlag = &spec.ExpFlag{
Name: "container-name",
Desc: "Container name, when used with container-id, container-id is preferred",
NoArgs: false,
Required: false,
RequiredWhenDestroyed: false,
}
var ContainerLabelSelectorFlag = &spec.ExpFlag{
Name: "container-label-selector",
Desc: "Container label selector, when used with container-id or container-name, container-id or container-name is preferred",
NoArgs: false,
Required: false,
RequiredWhenDestroyed: false,
}
var ImageRepoFlag = &spec.ExpFlag{
Name: "image-repo",
Desc: "Image repository of the chaosblade-tool",
NoArgs: false,
Required: false,
}
var ImageVersionFlag = &spec.ExpFlag{
Name: "image-version",
Desc: "Image version of the chaosblade-tool",
NoArgs: false,
Required: false,
}
var EndpointFlag = &spec.ExpFlag{
Name: "cri-endpoint",
Desc: "Cri container socket endpoint",
NoArgs: false,
Required: false,
}
var ChaosBladeReleaseFlag = &spec.ExpFlag{
Name: "chaosblade-release",
Desc: "The pull path of the chaosblade tar package, for example, --chaosblade-release /opt/chaosblade-0.4.0.tar.gz",
}
var ChaosBladeOverrideFlag = &spec.ExpFlag{
Name: "chaosblade-override",
Desc: "Override the exists chaosblade tool in the target container or not, default value is false",
NoArgs: true,
}
var ContainerRuntime = &spec.ExpFlag{
Name: "container-runtime",
Desc: "container runtime, support cri and containerd, default value is docker",
NoArgs: false,
Required: false,
}
var ContainerNamespace = &spec.ExpFlag{
Name: "container-namespace",
Desc: "container namespace, If container-runtime is containerd it will be used, default value is k8s.io",
NoArgs: false,
Required: false,
}
func GetContainerSelfFlags() []spec.ExpFlagSpec {
return []spec.ExpFlagSpec{
ContainerIdFlag,
ContainerNameFlag,
EndpointFlag,
ContainerRuntime,
ContainerNamespace,
}
}
func GetExecSidecarFlags() []spec.ExpFlagSpec {
return []spec.ExpFlagSpec{
ContainerIdFlag,
ContainerNameFlag,
ImageRepoFlag,
ImageVersionFlag,
EndpointFlag,
ContainerRuntime,
ContainerNamespace,
}
}
func GetExecInContainerFlags() []spec.ExpFlagSpec {
return []spec.ExpFlagSpec{
ContainerIdFlag,
ContainerNameFlag,
ImageRepoFlag,
ImageVersionFlag,
EndpointFlag,
ChaosBladeReleaseFlag,
ChaosBladeOverrideFlag,
ContainerRuntime,
ContainerNamespace,
}
}
func GetNSExecFlags() []spec.ExpFlagSpec {
return []spec.ExpFlagSpec{
ContainerIdFlag,
ContainerNameFlag,
EndpointFlag,
ContainerRuntime,
ContainerNamespace,
ContainerLabelSelectorFlag,
}
}
func getAllDockerFlags() []spec.ExpFlagSpec {
allFlags := make([]spec.ExpFlagSpec, 0)
allFlags = append(allFlags, GetContainerSelfFlags()...)
allFlags = append(allFlags, GetExecSidecarFlags()...)
allFlags = append(allFlags, GetExecInContainerFlags()...)
set := make(map[spec.ExpFlagSpec]bool, 0)
flags := make([]spec.ExpFlagSpec, 0)
for i := range allFlags {
if !set[allFlags[i]] {
flags = append(flags, allFlags[i])
set[allFlags[i]] = true
}
}
return flags
}
func GetAllDockerFlagNames() map[string]spec.Empty {
flagNames := make(map[string]spec.Empty, 0)
for _, flag := range getAllDockerFlags() {
flagNames[flag.FlagName()] = spec.Empty{}
}
return flagNames
}
func GetExecutorKey(target, action string) string {
return fmt.Sprintf("%s-%s", target, action)
}