-
Notifications
You must be signed in to change notification settings - Fork 3
/
completer.go
646 lines (612 loc) · 25.3 KB
/
completer.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
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
package shell
// Copyright (c) 2018, Arm Limited and affiliates.
// SPDX-License-Identifier: Apache-2.0
//
// 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.
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"path/filepath"
"strings"
prompt "github.com/c-bata/go-prompt"
)
const (
prompt_mode_normal = 0
prompt_mode_ifconfig = 1
)
var prompt_mode = prompt_mode_normal
var commands = []prompt.Suggest{
{Text: "exit", Description: "Exit shell"},
{Text: "alive", Description: "Check if maestro is running & get up time"},
{Text: "debug", Description: "Turn on / off debug print outs"},
{Text: "net", Description: "Query or change network interfaces"},
{Text: "log", Description: "Query or change logging parameters"},
{Text: "jobs", Description: "Query or change job configs"},
{Text: "help", Description: "Print available commands."},
}
var logSubCommands = []prompt.Suggest{
{Text: "get", Description: "Show configurations for all logging targets"},
{Text: "set", Description: "Set configurations for a logging target"},
{Text: "delete", Description: "Delete a configuration for a logging target"},
}
var netSubcommands = []prompt.Suggest{
//{Text: "get-up-interfaces", Description: "Show configuration interfaces which are up."},
//{Text: "get-enabled-interfaces", Description: "Show configuration interfaces which are enabled."},
{Text: "get-interfaces", Description: "Show configurations for all interfaces"},
//{Text: "renew-dhcp", Description: "Renew DHCP lease for a specific interface"},
//{Text: "release-dhcp", Description: "Release DHCP lease for a specific interface"},
//{Text: "ifdown", Description: "Shutdown an interface"},
//{Text: "ifup", Description: "Bring up an interface"},
{Text: "events", Description: "Listen for network events [interval-seconds]"},
{Text: "config-interface", Description: "Enter config for an interface"},
{Text: "get-dns", Description: "Show all domain name servers"},
{Text: "add-dns", Description: "Add a new domain name server"},
{Text: "delete-dns", Description: "Delete an existing domain name server"},
}
func GetCommandsHelpString([]string) (ret string, err error) {
buffer := bytes.NewBufferString("Commands:\n")
for _, cmd := range commands {
buffer.WriteString(fmt.Sprintf("%-15s- %s\n", cmd.Text, cmd.Description))
}
buffer.WriteString("--\n")
ret = string(buffer.Bytes())
return
}
func GetNetSubcommandsHelpString([]string) (ret string, err error) {
buffer := bytes.NewBufferString("Net Subcommands:\n")
for _, cmd := range netSubcommands {
buffer.WriteString(fmt.Sprintf("%-17s- %s\n", cmd.Text, cmd.Description))
}
buffer.WriteString("--\n")
buffer.WriteString("Specify options as <opt>=<arg>, like IfName=eth0")
ret = string(buffer.Bytes())
return
}
func GetLogSubcommandsHelpString([]string) (ret string, err error) {
buffer := bytes.NewBufferString("Log Subcommands:\n")
for _, cmd := range logSubCommands {
buffer.WriteString(fmt.Sprintf("%-17s- %s\n", cmd.Text, cmd.Description))
}
buffer.WriteString("--\n")
buffer.WriteString("Specify options as <opt>=<arg>, like target=id")
ret = string(buffer.Bytes())
return
}
func Completer(d prompt.Document) []prompt.Suggest {
if d.TextBeforeCursor() == "" {
return []prompt.Suggest{}
}
args := strings.Split(d.TextBeforeCursor(), " ")
// w := d.GetWordBeforeCursor()
// If PIPE is in text before the cursor, returns empty suggestions.
for i := range args {
if args[i] == "|" {
return []prompt.Suggest{}
}
}
// If word before the cursor starts with "-", returns CLI flag options.
// if strings.HasPrefix(w, "-") {
// return optionCompleter(args, strings.HasPrefix(w, "--"))
// }
// Return suggestions for option
// if suggests, found := completeOptionArguments(d); found {
// return suggests
// }
return argumentsCompleter(args) // excludeOptions(args))
}
func init() {
fileListCache = map[string][]prompt.Suggest{}
}
func getPreviousOption(d prompt.Document) (cmd, option string, found bool) {
args := strings.Split(d.TextBeforeCursor(), " ")
l := len(args)
if l >= 2 {
option = args[l-2]
}
if strings.HasPrefix(option, "-") {
return args[0], option, true
}
return "", "", false
}
func completeOptionArguments(d prompt.Document) ([]prompt.Suggest, bool) {
cmd, option, found := getPreviousOption(d)
if !found {
return []prompt.Suggest{}, false
}
switch cmd {
case "get", "describe", "create", "delete", "replace", "patch",
"edit", "apply", "expose", "rolling-update", "rollout",
"label", "annotate", "scale", "convert", "autoscale":
switch option {
case "-f", "--filename":
return fileCompleter(d), true
}
}
return []prompt.Suggest{}, false
}
/* file list */
var fileListCache map[string][]prompt.Suggest
func fileCompleter(d prompt.Document) []prompt.Suggest {
path := d.GetWordBeforeCursor()
if strings.HasPrefix(path, "./") {
path = path[2:]
}
dir := filepath.Dir(path)
if cached, ok := fileListCache[dir]; ok {
return cached
}
files, err := ioutil.ReadDir(dir)
if err != nil {
log.Print("[ERROR] catch error " + err.Error())
return []prompt.Suggest{}
}
suggests := make([]prompt.Suggest, 0, len(files))
for _, f := range files {
if !f.IsDir() &&
!strings.HasSuffix(f.Name(), ".yml") &&
!strings.HasSuffix(f.Name(), ".yaml") {
continue
}
suggests = append(suggests, prompt.Suggest{Text: filepath.Join(dir, f.Name())})
}
return prompt.FilterHasPrefix(suggests, path, false)
}
func argumentsCompleter(args []string) []prompt.Suggest {
if len(args) <= 1 {
return prompt.FilterHasPrefix(commands, args[0], true)
}
first := args[0]
second := args[1]
switch first {
case "net":
if len(args) == 2 {
return prompt.FilterHasPrefix(netSubcommands, second, true)
}
if len(args) >= 3 {
last := args[len(args)-1]
switch second {
case "add-dns", "delete-dns":
dns_set_args := []prompt.Suggest{
{Text: "<server>", Description: "Domain name server address"},
}
return prompt.FilterHasPrefix(dns_set_args, last, true)
case "config-interface":
iface_args := []prompt.Suggest{
{Text: "Type", Description: "Interface type, like wifi"},
{Text: "IfName", Description: "Interface name, like eth0"},
{Text: "DhcpV4Enabled", Description: "true or false"},
{Text: "IPv4Addr", Description: "IPv4 Address"},
{Text: "IPv4Mask", Description: "IPv4 Netmask integer (CIDR format)"},
{Text: "IPv4BCast", Description: "IPv4 Broadcast Address"},
//{Text: "AliasAddrV4", Description: "NOT IMPLEMENTED"},
{Text: "IPv6Addr", Description: "IPv6 Address"},
{Text: "HwAddr", Description: "MAC Address or similar"},
//{Text: "IEEE8021x", Description: "NOT IMPLEMENTED"},
{Text: "ReplaceAddress", Description: "Address to delete before setting the new address"},
{Text: "ClearAddresses", Description: "true or false. if true, remove all existing addresses before setting the new address"},
{Text: "WifiSsid", Description: "Wifi SSID"},
{Text: "WifiPassword", Description: "Wifi Password"},
{Text: "Down", Description: "true or false. if true, the interface is disabled"},
{Text: "DefaultGateway", Description: "Default route associated with this interface"},
//{Text: "FallbackDefaultGateway", Description: "NOT IMPLEMENTED"},
{Text: "RoutePriority", Description: "Interface priority as a default route, ranked across all interfaces. range 0-9, 0=first priority, 9=last"},
{Text: "Aux", Description: "true or false"},
{Text: "NameserverOverrides", Description: "Override DNS"},
//{Text: "Routes", Description: "NOT IMPLEMENTED"},
//{Text: "TestHttpsRouteOut", Description: "NOT IMPLEMENTED"},
//{Text: "TestICMPv4EchoOut", Description: "NOT IMPLEMENTED"},
{Text: "DhcpDisableClearAddresses", Description: "Don't allow DHCP to clear all addresses"},
{Text: "DhcpStepTimeout", Description: "Max seconds to wait for DHCP address"},
{Text: "Existing", Description: "override=replace any data in the db, replace=remove any data in the db"},
{Text: "Type", Description: "Type of the connection, such as wifi or lte"},
{Text: "SerialDevice", Description: "Path to the LTE modem serial device"},
{Text: "APN", Description: "LTE modem access point name"},
}
return prompt.FilterHasPrefix(iface_args, last, true)
}
}
case "log":
if len(args) == 2 {
return prompt.FilterHasPrefix(logSubCommands, second, true)
}
if len(args) >= 3 {
last := args[len(args)-1]
switch second {
case "set", "delete":
log_set_args := []prompt.Suggest{
{Text: "target", Description: "Log filter target"},
{Text: "levels", Description: "Log filter level"},
{Text: "tag", Description: "Log filter tag"},
{Text: "pre", Description: "Log pre filter"},
{Text: "post", Description: "Log post filter"},
{Text: "post-fmt-pre-msg", Description: "Log post format pre message"},
}
return prompt.FilterHasPrefix(log_set_args, last, true)
}
}
case "debug":
if len(args) == 2 {
subcommands := []prompt.Suggest{
{Text: "on", Description: "Turn on debugging"},
{Text: "off", Description: "Turn off debugging"},
}
return prompt.FilterHasPrefix(subcommands, second, true)
}
case "jobs":
if len(args) == 2 {
subcommands := []prompt.Suggest{
{Text: "get", Description: "Show all running jobs."},
{Text: "stop", Description: "Stop one or more jobs by unique name"},
{Text: "start", Description: "Start one or more jobs by unique name"},
{Text: "register", Description: "Register (define) a new job using a JSON string"},
}
return prompt.FilterHasPrefix(subcommands, second, true)
}
case "get":
// second := args[1]
// if len(args) == 2 {
// subcommands := []prompt.Suggest{
// {Text: "componentstatuses"},
// {Text: "configmaps"},
// {Text: "daemonsets"},
// {Text: "deployments"},
// {Text: "endpoints"},
// {Text: "events"},
// {Text: "horizontalpodautoscalers"},
// {Text: "ingresses"},
// {Text: "jobs"},
// {Text: "limitranges"},
// {Text: "namespaces"},
// {Text: "networkpolicies"},
// {Text: "nodes"},
// {Text: "persistentvolumeclaims"},
// {Text: "persistentvolumes"},
// {Text: "pod"},
// {Text: "podsecuritypolicies"},
// {Text: "podtemplates"},
// {Text: "replicasets"},
// {Text: "replicationcontrollers"},
// {Text: "resourcequotas"},
// {Text: "secrets"},
// {Text: "serviceaccounts"},
// {Text: "services"},
// {Text: "statefulsets"},
// {Text: "storageclasses"},
// {Text: "thirdpartyresources"},
// // aliases
// {Text: "cs"},
// {Text: "cm"},
// {Text: "ds"},
// {Text: "deploy"},
// {Text: "ep"},
// {Text: "hpa"},
// {Text: "ing"},
// {Text: "limits"},
// {Text: "ns"},
// {Text: "no"},
// {Text: "pvc"},
// {Text: "pv"},
// {Text: "po"},
// {Text: "psp"},
// {Text: "rs"},
// {Text: "rc"},
// {Text: "quota"},
// {Text: "sa"},
// {Text: "svc"},
// }
// return prompt.FilterHasPrefix(subcommands, second, true)
// }
// third := args[2]
// if len(args) == 3 {
// switch second {
// case "componentstatuses", "cs":
// return prompt.FilterContains(getComponentStatusCompletions(), third, true)
// case "configmaps", "cm":
// return prompt.FilterContains(getConfigMapSuggestions(), third, true)
// case "daemonsets", "ds":
// return prompt.FilterContains(getDaemonSetSuggestions(), third, true)
// case "deploy", "deployments":
// return prompt.FilterContains(getDeploymentSuggestions(), third, true)
// case "endpoints", "ep":
// return prompt.FilterContains(getEndpointsSuggestions(), third, true)
// case "ingresses", "ing":
// return prompt.FilterContains(getIngressSuggestions(), third, true)
// case "limitranges", "limits":
// return prompt.FilterContains(getLimitRangeSuggestions(), third, true)
// case "namespaces", "ns":
// return prompt.FilterContains(getNameSpaceSuggestions(), third, true)
// case "no", "nodes":
// return prompt.FilterContains(getNodeSuggestions(), third, true)
// case "po", "pod", "pods":
// return prompt.FilterContains(getPodSuggestions(), third, true)
// case "persistentvolumeclaims", "pvc":
// return prompt.FilterContains(getPersistentVolumeClaimSuggestions(), third, true)
// case "persistentvolumes", "pv":
// return prompt.FilterContains(getPersistentVolumeSuggestions(), third, true)
// case "podsecuritypolicies", "psp":
// return prompt.FilterContains(getPodSecurityPolicySuggestions(), third, true)
// case "podtemplates":
// return prompt.FilterContains(getPodTemplateSuggestions(), third, true)
// case "replicasets", "rs":
// return prompt.FilterContains(getReplicaSetSuggestions(), third, true)
// case "replicationcontrollers", "rc":
// return prompt.FilterContains(getReplicationControllerSuggestions(), third, true)
// case "resourcequotas", "quota":
// return prompt.FilterContains(getResourceQuotasSuggestions(), third, true)
// case "secrets":
// return prompt.FilterContains(getSecretSuggestions(), third, true)
// case "sa", "serviceaccounts":
// return prompt.FilterContains(getServiceAccountSuggestions(), third, true)
// case "svc", "services":
// return prompt.FilterContains(getServiceSuggestions(), third, true)
// }
// }
// case "describe":
// second := args[1]
// if len(args) == 2 {
// return prompt.FilterHasPrefix(resourceTypes, second, true)
// }
// third := args[2]
// if len(args) == 3 {
// switch second {
// case "componentstatuses", "cs":
// return prompt.FilterContains(getComponentStatusCompletions(), third, true)
// case "configmaps", "cm":
// return prompt.FilterContains(getConfigMapSuggestions(), third, true)
// case "daemonsets", "ds":
// return prompt.FilterContains(getDaemonSetSuggestions(), third, true)
// case "deploy", "deployments":
// return prompt.FilterContains(getDeploymentSuggestions(), third, true)
// case "endpoints", "ep":
// return prompt.FilterContains(getEndpointsSuggestions(), third, true)
// case "ingresses", "ing":
// return prompt.FilterContains(getIngressSuggestions(), third, true)
// case "limitranges", "limits":
// return prompt.FilterContains(getLimitRangeSuggestions(), third, true)
// case "namespaces", "ns":
// return prompt.FilterContains(getNameSpaceSuggestions(), third, true)
// case "no", "nodes":
// return prompt.FilterContains(getNodeSuggestions(), third, true)
// case "po", "pod", "pods":
// return prompt.FilterContains(getPodSuggestions(), third, true)
// case "persistentvolumeclaims", "pvc":
// return prompt.FilterContains(getPersistentVolumeClaimSuggestions(), third, true)
// case "persistentvolumes", "pv":
// return prompt.FilterContains(getPersistentVolumeSuggestions(), third, true)
// case "podsecuritypolicies", "psp":
// return prompt.FilterContains(getPodSecurityPolicySuggestions(), third, true)
// case "podtemplates":
// return prompt.FilterContains(getPodTemplateSuggestions(), third, true)
// case "replicasets", "rs":
// return prompt.FilterContains(getReplicaSetSuggestions(), third, true)
// case "replicationcontrollers", "rc":
// return prompt.FilterContains(getReplicationControllerSuggestions(), third, true)
// case "resourcequotas", "quota":
// return prompt.FilterContains(getResourceQuotasSuggestions(), third, true)
// case "secrets":
// return prompt.FilterContains(getSecretSuggestions(), third, true)
// case "sa", "serviceaccounts":
// return prompt.FilterContains(getServiceAccountSuggestions(), third, true)
// case "svc", "services":
// return prompt.FilterContains(getServiceSuggestions(), third, true)
// }
// }
// case "create":
// subcommands := []prompt.Suggest{
// {Text: "configmap", Description: "Create a configmap from a local file, directory or literal value"},
// {Text: "deployment", Description: "Create a deployment with the specified name."},
// {Text: "namespace", Description: "Create a namespace with the specified name"},
// {Text: "quota", Description: "Create a quota with the specified name."},
// {Text: "secret", Description: "Create a secret using specified subcommand"},
// {Text: "service", Description: "Create a service using specified subcommand."},
// {Text: "serviceaccount", Description: "Create a service account with the specified name"},
// }
// if len(args) == 2 {
// return prompt.FilterHasPrefix(subcommands, args[1], true)
// }
// case "delete":
// second := args[1]
// if len(args) == 2 {
// return prompt.FilterHasPrefix(resourceTypes, second, true)
// }
// third := args[2]
// if len(args) == 3 {
// switch second {
// case "componentstatuses", "cs":
// return prompt.FilterContains(getComponentStatusCompletions(), third, true)
// case "configmaps", "cm":
// return prompt.FilterContains(getConfigMapSuggestions(), third, true)
// case "daemonsets", "ds":
// return prompt.FilterContains(getDaemonSetSuggestions(), third, true)
// case "deploy", "deployments":
// return prompt.FilterContains(getDeploymentSuggestions(), third, true)
// case "endpoints", "ep":
// return prompt.FilterContains(getEndpointsSuggestions(), third, true)
// case "ingresses", "ing":
// return prompt.FilterContains(getIngressSuggestions(), third, true)
// case "limitranges", "limits":
// return prompt.FilterContains(getLimitRangeSuggestions(), third, true)
// case "namespaces", "ns":
// return prompt.FilterContains(getNameSpaceSuggestions(), third, true)
// case "no", "nodes":
// return prompt.FilterContains(getNodeSuggestions(), third, true)
// case "po", "pod", "pods":
// return prompt.FilterContains(getPodSuggestions(), third, true)
// case "persistentvolumeclaims", "pvc":
// return prompt.FilterContains(getPersistentVolumeClaimSuggestions(), third, true)
// case "persistentvolumes", "pv":
// return prompt.FilterContains(getPersistentVolumeSuggestions(), third, true)
// case "podsecuritypolicies", "psp":
// return prompt.FilterContains(getPodSecurityPolicySuggestions(), third, true)
// case "podtemplates":
// return prompt.FilterContains(getPodTemplateSuggestions(), third, true)
// case "replicasets", "rs":
// return prompt.FilterContains(getReplicaSetSuggestions(), third, true)
// case "replicationcontrollers", "rc":
// return prompt.FilterContains(getReplicationControllerSuggestions(), third, true)
// case "resourcequotas", "quota":
// return prompt.FilterContains(getResourceQuotasSuggestions(), third, true)
// case "secrets":
// return prompt.FilterContains(getSecretSuggestions(), third, true)
// case "sa", "serviceaccounts":
// return prompt.FilterContains(getServiceAccountSuggestions(), third, true)
// case "svc", "services":
// return prompt.FilterContains(getServiceSuggestions(), third, true)
// }
// }
// case "edit":
// if len(args) == 2 {
// return prompt.FilterHasPrefix(resourceTypes, args[1], true)
// }
// if len(args) == 3 {
// third := args[2]
// switch args[1] {
// case "componentstatuses", "cs":
// return prompt.FilterContains(getComponentStatusCompletions(), third, true)
// case "configmaps", "cm":
// return prompt.FilterContains(getConfigMapSuggestions(), third, true)
// case "daemonsets", "ds":
// return prompt.FilterContains(getDaemonSetSuggestions(), third, true)
// case "deploy", "deployments":
// return prompt.FilterContains(getDeploymentSuggestions(), third, true)
// case "endpoints", "ep":
// return prompt.FilterContains(getEndpointsSuggestions(), third, true)
// case "ingresses", "ing":
// return prompt.FilterContains(getIngressSuggestions(), third, true)
// case "limitranges", "limits":
// return prompt.FilterContains(getLimitRangeSuggestions(), third, true)
// case "namespaces", "ns":
// return prompt.FilterContains(getNameSpaceSuggestions(), third, true)
// case "no", "nodes":
// return prompt.FilterContains(getNodeSuggestions(), third, true)
// case "po", "pod", "pods":
// return prompt.FilterContains(getPodSuggestions(), third, true)
// case "persistentvolumeclaims", "pvc":
// return prompt.FilterContains(getPersistentVolumeClaimSuggestions(), third, true)
// case "persistentvolumes", "pv":
// return prompt.FilterContains(getPersistentVolumeSuggestions(), third, true)
// case "podsecuritypolicies", "psp":
// return prompt.FilterContains(getPodSecurityPolicySuggestions(), third, true)
// case "podtemplates":
// return prompt.FilterContains(getPodTemplateSuggestions(), third, true)
// case "replicasets", "rs":
// return prompt.FilterContains(getReplicaSetSuggestions(), third, true)
// case "replicationcontrollers", "rc":
// return prompt.FilterContains(getReplicationControllerSuggestions(), third, true)
// case "resourcequotas", "quota":
// return prompt.FilterContains(getResourceQuotasSuggestions(), third, true)
// case "secrets":
// return prompt.FilterContains(getSecretSuggestions(), third, true)
// case "sa", "serviceaccounts":
// return prompt.FilterContains(getServiceAccountSuggestions(), third, true)
// case "svc", "services":
// return prompt.FilterContains(getServiceSuggestions(), third, true)
// }
// }
// case "namespace":
// if len(args) == 2 {
// return prompt.FilterContains(getNameSpaceSuggestions(), args[1], true)
// }
// case "logs":
// if len(args) == 2 {
// return prompt.FilterContains(getPodSuggestions(), args[1], true)
// }
// case "rolling-update", "rollingupdate":
// if len(args) == 2 {
// return prompt.FilterContains(getReplicationControllerSuggestions(), args[1], true)
// } else if len(args) == 3 {
// return prompt.FilterContains(getReplicationControllerSuggestions(), args[2], true)
// }
// case "scale", "resize":
// if len(args) == 2 {
// // Deployment, ReplicaSet, Replication Controller, or Job.
// r := getDeploymentSuggestions()
// r = append(r, getReplicaSetSuggestions()...)
// r = append(r, getReplicationControllerSuggestions()...)
// return prompt.FilterContains(r, args[1], true)
// }
// case "cordon":
// fallthrough
// case "drain":
// fallthrough
// case "uncordon":
// if len(args) == 2 {
// return prompt.FilterHasPrefix(getNodeSuggestions(), args[1], true)
// }
// case "attach":
// if len(args) == 2 {
// return prompt.FilterContains(getPodSuggestions(), args[1], true)
// }
// case "exec":
// if len(args) == 2 {
// return prompt.FilterContains(getPodSuggestions(), args[1], true)
// }
// case "port-forward":
// if len(args) == 2 {
// return prompt.FilterContains(getPodSuggestions(), args[1], true)
// }
// if len(args) == 3 {
// return prompt.FilterHasPrefix(getPortsFromPodName(args[1]), args[2], true)
// }
// case "rollout":
// subCommands := []prompt.Suggest{
// {Text: "history", Description: "view rollout history"},
// {Text: "pause", Description: "Mark the provided resource as paused"},
// {Text: "resume", Description: "Resume a paused resource"},
// {Text: "undo", Description: "undoes a previous rollout"},
// }
// if len(args) == 2 {
// return prompt.FilterHasPrefix(subCommands, args[1], true)
// }
// case "annotate":
// case "config":
// subCommands := []prompt.Suggest{
// {Text: "current-context", Description: "Displays the current-context"},
// {Text: "delete-cluster", Description: "Delete the specified cluster from the kubeconfig"},
// {Text: "delete-context", Description: "Delete the specified context from the kubeconfig"},
// {Text: "get-clusters", Description: "Display clusters defined in the kubeconfig"},
// {Text: "get-contexts", Description: "Describe one or many contexts"},
// {Text: "set", Description: "Sets an individual value in a kubeconfig file"},
// {Text: "set-cluster", Description: "Sets a cluster entry in kubeconfig"},
// {Text: "set-context", Description: "Sets a context entry in kubeconfig"},
// {Text: "set-credentials", Description: "Sets a user entry in kubeconfig"},
// {Text: "unset", Description: "Unsets an individual value in a kubeconfig file"},
// {Text: "use-context", Description: "Sets the current-context in a kubeconfig file"},
// {Text: "view", Description: "Display merged kubeconfig settings or a specified kubeconfig file"},
// }
// if len(args) == 2 {
// return prompt.FilterHasPrefix(subCommands, args[1], true)
// }
// if len(args) == 3 {
// third := args[2]
// switch args[1] {
// case "use-context":
// return prompt.FilterContains(getContextSuggestions(), third, true)
// }
// }
// case "cluster-info":
// subCommands := []prompt.Suggest{
// {Text: "dump", Description: "Dump lots of relevant info for debugging and diagnosis"},
// }
// if len(args) == 2 {
// return prompt.FilterHasPrefix(subCommands, args[1], true)
// }
// case "explain":
// return prompt.FilterHasPrefix(resourceTypes, args[1], true)
default:
return []prompt.Suggest{}
}
return []prompt.Suggest{}
}