diff --git a/client/env/env.go b/client/env/env.go index 0ee5d97b..5431a4ac 100644 --- a/client/env/env.go +++ b/client/env/env.go @@ -93,6 +93,31 @@ func GetDeployments(sharedflows bool) (respBody []byte, err error) { return respBody, err } +func GetAllDeployments() (respBody []byte, err error) { + + apiclient.SetPrintOutput(false) + proxiesResponse, err := GetDeployments(false) + if err != nil { + return nil, err + } + + sharedFlowsResponse, err := GetDeployments(true) + if err != nil { + return nil, err + } + + deployments := []string{} + + deployments = append(deployments, "\"proxies\":"+string(proxiesResponse)) + deployments = append(deployments, "\"sharedFlows\":"+string(sharedFlowsResponse)) + payload := "{" + strings.Join(deployments, ",") + "}" + + err = apiclient.PrettyPrint([]byte(payload)) + apiclient.SetPrintOutput(true) + + return []byte(payload), err +} + //GetDeployedConfig func GetDeployedConfig() (respBody []byte, err error) { u, _ := url.Parse(apiclient.BaseURL) diff --git a/cmd/env/getdeployments.go b/cmd/env/getdeployments.go index 1176e699..80bf58f6 100644 --- a/cmd/env/getdeployments.go +++ b/cmd/env/getdeployments.go @@ -30,15 +30,21 @@ var GetDeployCmd = &cobra.Command{ return apiclient.SetApigeeOrg(org) }, RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = environments.GetDeployments(sharedflows) + if all { + _, err = environments.GetAllDeployments() + } else { + _, err = environments.GetDeployments(sharedflows) + } return }, } -var sharedflows bool +var sharedflows, all bool func init() { GetDeployCmd.Flags().BoolVarP(&sharedflows, "sharedflows", "s", false, "Return sharedflow deployments") + GetDeployCmd.Flags().BoolVarP(&all, "all", "", + false, "Return all deployments") }