@@ -14,21 +14,6 @@ import (
14
14
"github.com/spf13/cobra"
15
15
)
16
16
17
- func refCheck (ids interface {}) (string , error ) {
18
- if idsArray , ok := ids .([]interface {}); ok {
19
- if len (idsArray ) == 1 {
20
- if id , ok := idsArray [0 ].(string ); ok {
21
- return id , nil
22
- } else {
23
- return "" , fmt .Errorf ("ref id is not of a string type" )
24
- }
25
- } else {
26
- return "" , fmt .Errorf ("ref object matches more than one element" )
27
- }
28
- }
29
- return "" , fmt .Errorf ("ref object is not an array" )
30
- }
31
-
32
17
func GetProjectIdFromFlagAndConfig (cmd * cobra.Command ) (string , error ) {
33
18
projectName , err := cmd .Flags ().GetString ("project" )
34
19
if err != nil {
@@ -90,15 +75,10 @@ func GetProjectIdByNameInConfig(config *Config, name string) (string, error) {
90
75
if err != nil {
91
76
return "" , err
92
77
}
93
- filter := fmt .Sprintf ("$.results[?(@.name == '%s')]. id" , name )
78
+ filter := fmt .Sprintf ("$.metadata. id" )
94
79
res , err := jsonpath .JsonPathLookup (obj , filter )
95
80
if err == nil {
96
- id , err := refCheck (res )
97
- if err != nil {
98
- log .GetLogger ().Debugf ("ref check failed %s" , err )
99
- } else {
100
- return id , nil
101
- }
81
+ return res .(string ), nil
102
82
} else {
103
83
log .GetLogger ().Debugf ("ref looked up name failed %s" , err )
104
84
}
0 commit comments