[POR-570] [hotfix] Fix the way we are listing environments from the CLI API client
@@ -10,10 +10,10 @@ import (
func (c *Client) ListEnvironments(
ctx context.Context,
projID, clusterID uint,
-) ([]*types.Environment, error) {
- var resp []*types.Environment
+) (*types.ListEnvironmentsResponse, error) {
+ resp := &types.ListEnvironmentsResponse{}
- err := c.postRequest(
+ err := c.getRequest(
fmt.Sprintf("/projects/%d/clusters/%d/environments", projID, clusterID),
nil,
resp,
@@ -142,7 +142,7 @@ func createDeployment(
// Create Deployment Status to indicate it's in progress
state := "in_progress"
- log_url := fmt.Sprintf("https://github.com/%s/%s/runs/%d", env.GitRepoOwner, env.GitRepoName, actionID)
+ log_url := fmt.Sprintf("https://github.com/%s/%s/actions/runs/%d", env.GitRepoOwner, env.GitRepoName, actionID)
deploymentStatusRequest := github.DeploymentStatusRequest{
State: &state,
@@ -35,7 +35,7 @@ func (c *ListEnvironmentHandler) ServeHTTP(w http.ResponseWriter, r *http.Reques
return
}
- res := make([]*types.Environment, 0)
+ var res types.ListEnvironmentsResponse
for _, env := range envs {
environment := env.ToEnvironmentType()
@@ -110,3 +110,5 @@ type PullRequest struct {
BranchFrom string `json:"branch_from"`
BranchInto string `json:"branch_into"`
+
+type ListEnvironmentsResponse []*Environment
@@ -721,7 +721,9 @@ func (t *DeploymentHook) PreApply() error {
return err
- for _, env := range envList {
+ envs := *envList
+ for _, env := range envs {
if env.GitRepoOwner == t.repoOwner && env.GitRepoName == t.repoName && env.GitInstallationID == t.gitInstallationID {
t.envID = env.ID
break