-
Notifications
You must be signed in to change notification settings - Fork 217
/
helpers.go
57 lines (53 loc) · 1.76 KB
/
helpers.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
package eventing
import (
"github.com/spaceuptech/space-cloud/space-cli/cmd/utils"
"github.com/spf13/cobra"
)
func eventingTriggersAutoCompleteFun(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
project, check := utils.GetProjectID()
if !check {
utils.LogDebug("Project not specified in flag", nil)
return nil, cobra.ShellCompDirectiveDefault
}
objs, err := GetEventingTrigger(project, "eventing-trigger", map[string]string{})
if err != nil {
return nil, cobra.ShellCompDirectiveDefault
}
var ids []string
for _, v := range objs {
ids = append(ids, v.Meta["id"])
}
return ids, cobra.ShellCompDirectiveDefault
}
func eventingSchemasAutoCompleteFun(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
project, check := utils.GetProjectID()
if !check {
utils.LogDebug("Project not specified in flag", nil)
return nil, cobra.ShellCompDirectiveDefault
}
objs, err := GetEventingSchema(project, "eventing-schema", map[string]string{})
if err != nil {
return nil, cobra.ShellCompDirectiveDefault
}
var ids []string
for _, v := range objs {
ids = append(ids, v.Meta["id"])
}
return ids, cobra.ShellCompDirectiveDefault
}
func eventingRulesAutoCompleteFun(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
project, check := utils.GetProjectID()
if !check {
utils.LogDebug("Project not specified in flag", nil)
return nil, cobra.ShellCompDirectiveDefault
}
objs, err := GetEventingSecurityRule(project, "eventing-rule", map[string]string{})
if err != nil {
return nil, cobra.ShellCompDirectiveDefault
}
var ids []string
for _, v := range objs {
ids = append(ids, v.Meta["id"])
}
return ids, cobra.ShellCompDirectiveDefault
}