@@ -14,21 +14,6 @@ import (
1414 "github.com/spf13/cobra"
1515)
1616
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-
3217func GetProjectIdFromFlagAndConfig (cmd * cobra.Command ) (string , error ) {
3318 projectName , err := cmd .Flags ().GetString ("project" )
3419 if err != nil {
@@ -90,15 +75,10 @@ func GetProjectIdByNameInConfig(config *Config, name string) (string, error) {
9075 if err != nil {
9176 return "" , err
9277 }
93- filter := fmt .Sprintf ("$.results[?(@.name == '%s')]. id" , name )
78+ filter := fmt .Sprintf ("$.metadata. id" )
9479 res , err := jsonpath .JsonPathLookup (obj , filter )
9580 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
10282 } else {
10383 log .GetLogger ().Debugf ("ref looked up name failed %s" , err )
10484 }
0 commit comments