Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
support for service acccounts with deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan committed Aug 5, 2021
1 parent be78ef9 commit e0050de
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
13 changes: 10 additions & 3 deletions client/apis/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(), "")
Expand Down
11 changes: 8 additions & 3 deletions client/sharedflows/sharedflows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
5 changes: 4 additions & 1 deletion cmd/apis/depapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand All @@ -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")
Expand Down
5 changes: 4 additions & 1 deletion cmd/sharedflows/depsf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand All @@ -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")
Expand Down

0 comments on commit e0050de

Please sign in to comment.