Skip to content

Commit

Permalink
feat: add fwd proxy uri #327 (#329)
Browse files Browse the repository at this point in the history
* feat: add fwd proxy uri #327

* merge conflicts #327

* fix lint errors #327
  • Loading branch information
srinandan authored Nov 6, 2023
1 parent 91da054 commit 8e1b916
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
14 changes: 12 additions & 2 deletions cmd/env/crtenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
package env

import (
"fmt"
"net/url"

"internal/apiclient"

"internal/client/env"
Expand All @@ -28,21 +31,28 @@ var CreateCmd = &cobra.Command{
Short: "Create a new environment",
Long: "Create a new environment",
Args: func(cmd *cobra.Command, args []string) (err error) {
_, err = url.Parse(fwdProxyURI)
if err != nil {
return fmt.Errorf("invalid URI string for fwdProxyURI: %v", err)
}
apiclient.SetApigeeEnv(environment)
return apiclient.SetApigeeOrg(org)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
_, err = env.Create(deploymentType)
_, err = env.Create(deploymentType, fwdProxyURI)
return
},
}

var deploymentType string
var deploymentType, fwdProxyURI string

func init() {
CreateCmd.Flags().StringVarP(&environment, "env", "e",
"", "Apigee environment name")
CreateCmd.Flags().StringVarP(&deploymentType, "deptype", "d",
"", "Deployment type - must be PROXY or ARCHIVE")
CreateCmd.Flags().StringVarP(&fwdProxyURI, "fwdproxyuri", "f",
"", "URL of the forward proxy to be applied to the runtime instances in this env")

_ = CreateCmd.MarkFlagRequired("env")
}
6 changes: 5 additions & 1 deletion internal/client/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
)

// Create
func Create(deploymentType string) (respBody []byte, err error) {
func Create(deploymentType string, fwdProxyURI string) (respBody []byte, err error) {
environment := []string{}
environment = append(environment, "\"name\":\""+apiclient.GetApigeeEnv()+"\"")

Expand All @@ -37,6 +37,10 @@ func Create(deploymentType string) (respBody []byte, err error) {
environment = append(environment, "\"deployment_type\":\""+deploymentType+"\"")
}

if fwdProxyURI != "" {
environment = append(environment, "\"forwardProxyUri\":\""+fwdProxyURI+"\"")
}

payload := "{" + strings.Join(environment, ",") + "}"

u, _ := url.Parse(apiclient.BaseURL)
Expand Down

0 comments on commit 8e1b916

Please sign in to comment.