Skip to content

Commit

Permalink
feat: add fwd proxy uri #327
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan committed Nov 6, 2023
1 parent 8880d46 commit ea965d3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 10 additions & 2 deletions cmd/env/crtenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
package env

import (
"fmt"

Check failure on line 18 in cmd/env/crtenv.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed (gofumpt)

Check failure on line 18 in cmd/env/crtenv.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed (gofumpt)
"internal/apiclient"
"net/url"

Check failure on line 20 in cmd/env/crtenv.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed (gofumpt)

Check failure on line 20 in cmd/env/crtenv.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed (gofumpt)

"internal/client/env"

Expand All @@ -28,16 +30,20 @@ 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, apiProxyType)
_, err = env.Create(deploymentType, apiProxyType, fwdProxyURI)
return
},
}

var deploymentType, apiProxyType string
var deploymentType, apiProxyType, fwdProxyURI string

func init() {
CreateCmd.Flags().StringVarP(&environment, "env", "e",
Expand All @@ -46,5 +52,7 @@ func init() {
"", "Deployment type - must be PROXY or ARCHIVE")
CreateCmd.Flags().StringVarP(&apiProxyType, "proxtype", "p",
"", "Proxy type - must be PROGRAMMABLE or CONFIGURABLE")
CreateCmd.Flags().StringVarP(&fwdProxyURI, "fowdproxyuri", "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, apiProxyType string) (respBody []byte, err error) {
func Create(deploymentType string, apiProxyType string, fwdProxyURI string) (respBody []byte, err error) {
environment := []string{}
environment = append(environment, "\"name\":\""+apiclient.GetApigeeEnv()+"\"")

Expand All @@ -44,6 +44,10 @@ func Create(deploymentType string, apiProxyType string) (respBody []byte, err er
environment = append(environment, "\"apiProxyType\":\""+apiProxyType+"\"")
}

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

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

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

0 comments on commit ea965d3

Please sign in to comment.