Skip to content

Commit

Permalink
update environments api endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Sami Alajrami committed May 4, 2021
1 parent 92c0e4f commit 7df9438
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cmd/watcher/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func newEnvCmd(out io.Writer) *cobra.Command {
return fmt.Errorf("--namespace and --exclude-namespace can't be used together. This can also happen if you set one of the two options in a config file or env var and the other on the command line")
}
envName := args[0]
url := fmt.Sprintf("%s/api/v1/projects/%s/environments/%s/data", global.host, global.owner, envName)
url := fmt.Sprintf("%s/api/v1/environments/%s/%s/data", global.host, global.owner, envName)
clientset, err := kube.NewK8sClientSet(o.kubeconfig)
if err != nil {
return err
Expand All @@ -101,7 +101,7 @@ func newEnvCmd(out io.Writer) *cobra.Command {
} else {
fmt.Println("****** Sending a Test to the API ******")
fmt.Println(string(js))
resp, err := requests.DoPost(js, url, global.apiToken, global.maxAPIRetries)
resp, err := requests.DoPut(js, url, global.apiToken, global.maxAPIRetries)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions internal/requests/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ func getRetryableHttpClient(maxAPIRetries int) *http.Client {
return client
}

// DoPost sends an HTTP Post request to a URL and returns the response body and status code
func DoPost(jsonBody []byte, url string, apiToken string, maxAPIRetries int) (*HTTPResponse, error) {
// DoPut sends an HTTP Post request to a URL and returns the response body and status code
func DoPut(jsonBody []byte, url string, apiToken string, maxAPIRetries int) (*HTTPResponse, error) {
client := getRetryableHttpClient(maxAPIRetries)
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonBody))
req, err := http.NewRequest("PUT", url, bytes.NewBuffer(jsonBody))
if err != nil {
return &HTTPResponse{}, fmt.Errorf("failed to create post request to %s : %v", url, err)
}
Expand Down

0 comments on commit 7df9438

Please sign in to comment.