Skip to content

Commit

Permalink
Merge pull request #223 from uselagoon/json-string-on-update-bug
Browse files Browse the repository at this point in the history
Allowing json string flag to be used when updating a project
  • Loading branch information
shreddedbacon committed Apr 21, 2022
2 parents b47180f + 099653a commit 3eedf3f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
11 changes: 9 additions & 2 deletions cmd/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,15 @@ var updateProjectCmd = &cobra.Command{
os.Exit(1)
}

jsonPatch, _ := json.Marshal(projectFlags)
projectUpdateID, err := pClient.UpdateProject(cmdProjectName, string(jsonPatch))
var jsonPatchFromProjectFlags string
if string(jsonPatch) != "" {
jsonPatchFromProjectFlags = jsonPatch
} else {
jsonMarshalPatch, _ := json.Marshal(projectFlags)
jsonPatchFromProjectFlags = string(jsonMarshalPatch)
}

projectUpdateID, err := pClient.UpdateProject(cmdProjectName, jsonPatchFromProjectFlags)
handleError(err)
var updatedProject api.Project
err = json.Unmarshal([]byte(projectUpdateID), &updatedProject)
Expand Down
2 changes: 2 additions & 0 deletions pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ type Project struct {
Environments []Environment `json:"environments,omitempty"`
Deployments []Deployment `json:"deployments,omitempty"`
Notifications []interface{} `json:"notifications,omitempty"`
FactsUI *int `json:"factsUi,omitempty"`
}

// ProjectPatch struct.
Expand All @@ -273,6 +274,7 @@ type ProjectPatch struct {
OpenshiftProjectPattern string `json:"openshiftProjectPattern,omitempty"`
DevelopmentEnvironmentsLimit *int `json:"developmentEnvironmentsLimit,omitempty"`
Openshift *int `json:"openshift,omitempty"`
FactsUI *int `json:"factsUi,omitempty"`
}

// AddSSHKey .
Expand Down
2 changes: 1 addition & 1 deletion pkg/lagoon/projects/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func processProjectUpdate(projectByName []byte, jsonPatch string) (api.UpdatePro
var projects api.Project
var projectUpdate api.UpdateProject
var project api.ProjectPatch
err := json.Unmarshal([]byte(projectByName), &projects)
err := json.Unmarshal(projectByName, &projects)
if err != nil {
return projectUpdate, err
}
Expand Down

0 comments on commit 3eedf3f

Please sign in to comment.