Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add fwd proxy uri #327 #329

Merged
merged 4 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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