diff --git a/client/apis/apis.go b/client/apis/apis.go index 73f25ef1..d9765ab9 100644 --- a/client/apis/apis.go +++ b/client/apis/apis.go @@ -64,13 +64,20 @@ func DeleteProxy(name string, revision int) (respBody []byte, err error) { } //DeployProxy -func DeployProxy(name string, revision int, overrides bool) (respBody []byte, err error) { +func DeployProxy(name string, revision int, overrides bool, serviceAccountName string) (respBody []byte, err error) { u, _ := url.Parse(apiclient.BaseURL) - if overrides { + + if overrides || serviceAccountName != "" { q := u.Query() - q.Set("override", "true") + if overrides { + q.Set("override", "true") + } + if serviceAccountName != "" { + q.Set("serviceAccount", serviceAccountName) + } u.RawQuery = q.Encode() } + u.Path = path.Join(u.Path, apiclient.GetApigeeOrg(), "environments", apiclient.GetApigeeEnv(), "apis", name, "revisions", strconv.Itoa(revision), "deployments") respBody, err = apiclient.HttpClient(apiclient.GetPrintOutput(), u.String(), "") diff --git a/client/sharedflows/sharedflows.go b/client/sharedflows/sharedflows.go index 71bcec53..061dd882 100644 --- a/client/sharedflows/sharedflows.go +++ b/client/sharedflows/sharedflows.go @@ -127,11 +127,16 @@ func ListRevisionDeployments(name string, revision int) (respBody []byte, err er } //Deploy -func Deploy(name string, revision int, overrides bool) (respBody []byte, err error) { +func Deploy(name string, revision int, overrides bool, serviceAccountName string) (respBody []byte, err error) { u, _ := url.Parse(apiclient.BaseURL) - if overrides { + if overrides || serviceAccountName != "" { q := u.Query() - q.Set("override", "true") + if overrides { + q.Set("override", "true") + } + if serviceAccountName != "" { + q.Set("serviceAccount", serviceAccountName) + } u.RawQuery = q.Encode() } u.Path = path.Join(u.Path, apiclient.GetApigeeOrg(), "environments", apiclient.GetApigeeEnv(), diff --git a/cmd/apis/depapi.go b/cmd/apis/depapi.go index eb1987c6..281d61c6 100644 --- a/cmd/apis/depapi.go +++ b/cmd/apis/depapi.go @@ -30,12 +30,13 @@ var DepCmd = &cobra.Command{ return apiclient.SetApigeeOrg(org) }, RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = apis.DeployProxy(name, revision, overrides) + _, err = apis.DeployProxy(name, revision, overrides, serviceAccountName) return }, } var overrides bool +var serviceAccountName string func init() { @@ -47,6 +48,8 @@ func init() { -1, "API Proxy revision") DepCmd.Flags().BoolVarP(&overrides, "ovr", "r", false, "Forces deployment of the new revision") + DepCmd.Flags().StringVarP(&serviceAccountName, "sa", "s", + false, "The format must be {ACCOUNT_ID}@{PROJECT}.iam.gserviceaccount.com.") _ = DepCmd.MarkFlagRequired("env") _ = DepCmd.MarkFlagRequired("name") diff --git a/cmd/sharedflows/depsf.go b/cmd/sharedflows/depsf.go index d0f70058..f531ab7c 100644 --- a/cmd/sharedflows/depsf.go +++ b/cmd/sharedflows/depsf.go @@ -30,12 +30,13 @@ var DepCmd = &cobra.Command{ return apiclient.SetApigeeOrg(org) }, RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = sharedflows.Deploy(name, revision, overrides) + _, err = sharedflows.Deploy(name, revision, overrides, serviceAccountName) return }, } var overrides bool +var serviceAccountName string func init() { @@ -47,6 +48,8 @@ func init() { -1, "Sharedflow revision") DepCmd.Flags().BoolVarP(&overrides, "ovr", "r", false, "Forces deployment of the new revision") + DepCmd.Flags().StringVarP(&serviceAccountName, "sa", "s", + false, "The format must be {ACCOUNT_ID}@{PROJECT}.iam.gserviceaccount.com.") _ = DepCmd.MarkFlagRequired("env") _ = DepCmd.MarkFlagRequired("name")