Skip to content

Commit

Permalink
Merge pull request #212 from uselagoon/feature/211-routerPattern-proj…
Browse files Browse the repository at this point in the history
…ect-update-support

Feature/211 router pattern project update support
  • Loading branch information
shreddedbacon authored Mar 17, 2022
2 parents 5188f6a + 573665f commit daa6337
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions cmd/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ func init() {
updateProjectCmd.Flags().StringVarP(&projectPatch.GitURL, "gitUrl", "g", "", "GitURL of the project")
updateProjectCmd.Flags().StringVarP(&projectPatch.PrivateKey, "privateKey", "I", "", "Private key to use for the project")
updateProjectCmd.Flags().StringVarP(&projectPatch.Subfolder, "subfolder", "s", "", "Set if the .lagoon.yml should be found in a subfolder useful if you have multiple Lagoon projects per Git Repository")
updateProjectCmd.Flags().StringVarP(&projectPatch.RouterPattern, "routerPattern", "Z", "", "Router pattern of the project, e.g. '${service}-${environment}-${project}.lagoon.example.com'")
updateProjectCmd.Flags().StringVarP(&projectPatch.ActiveSystemsTask, "activeSystemsTask", "T", "", "Which internal Lagoon System is responsible for tasks")
updateProjectCmd.Flags().StringVarP(&projectPatch.ActiveSystemsDeploy, "activeSystemsDeploy", "D", "", "Which internal Lagoon System is responsible for deploying ")
updateProjectCmd.Flags().StringVarP(&projectPatch.ActiveSystemsRemove, "activeSystemsRemove", "R", "", "Which internal Lagoon System is responsible for removing")
Expand All @@ -382,6 +383,7 @@ func init() {
addProjectCmd.Flags().StringVarP(&projectPatch.GitURL, "gitUrl", "g", "", "GitURL of the project")
addProjectCmd.Flags().StringVarP(&projectPatch.PrivateKey, "privateKey", "I", "", "Private key to use for the project")
addProjectCmd.Flags().StringVarP(&projectPatch.Subfolder, "subfolder", "s", "", "Set if the .lagoon.yml should be found in a subfolder useful if you have multiple Lagoon projects per Git Repository")
addProjectCmd.Flags().StringVarP(&projectPatch.RouterPattern, "routerPattern", "Z", "", "Router pattern of the project, e.g. '${service}-${environment}-${project}.lagoon.example.com'")
addProjectCmd.Flags().StringVarP(&projectPatch.ActiveSystemsTask, "activeSystemsTask", "T", "", "Which internal Lagoon System is responsible for tasks")
addProjectCmd.Flags().StringVarP(&projectPatch.ActiveSystemsDeploy, "activeSystemsDeploy", "D", "", "Which internal Lagoon System is responsible for deploying ")
addProjectCmd.Flags().StringVarP(&projectPatch.ActiveSystemsRemove, "activeSystemsRemove", "R", "", "Which internal Lagoon System is responsible for removing")
Expand Down
1 change: 1 addition & 0 deletions docs/commands/lagoon_add_project.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ lagoon add project [flags]
-I, --privateKey string Private key to use for the project
-E, --productionEnvironment string Which environment(the name) should be marked as the production environment
-m, --pullrequests string Which Pull Requests should be deployed
-Z, --routerPattern string Router pattern of the project, e.g. '${service}-${environment}-${project}.lagoon.example.com'
--standbyProductionEnvironment string Which environment(the name) should be marked as the standby production environment
-C, --storageCalc int Should storage for this environment be calculated
-s, --subfolder string Set if the .lagoon.yml should be found in a subfolder useful if you have multiple Lagoon projects per Git Repository
Expand Down
1 change: 1 addition & 0 deletions docs/commands/lagoon_update_project.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ lagoon update project [flags]
-I, --privateKey string Private key to use for the project
-E, --productionEnvironment string Which environment(the name) should be marked as the production environment
-m, --pullrequests string Which Pull Requests should be deployed
-Z, --routerPattern string Router pattern of the project, e.g. '${service}-${environment}-${project}.lagoon.example.com'
--standbyProductionEnvironment string Which environment(the name) should be marked as the standby production environment
-C, --storageCalc int Should storage for this environment be calculated
-s, --subfolder string Set if the .lagoon.yml should be found in a subfolder useful if you have multiple Lagoon projects per Git Repository
Expand Down
2 changes: 1 addition & 1 deletion internal/lagoon/client/lgraphql/lgraphql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ type Project struct {
GitURL string `json:"gitUrl,omitempty"`
PrivateKey string `json:"privateKey,omitempty"`
Subfolder string `json:"subfolder,omitempty"`
RouterPattern string `json:"routerPattern,omitempty"`
ActiveSystemsTask string `json:"activeSystemsTask,omitempty"`
ActiveSystemsDeploy string `json:"activeSystemsDeploy,omitempty"`
ActiveSystemsRemove string `json:"activeSystemsRemove,omitempty"`
Expand Down Expand Up @@ -257,6 +258,7 @@ type ProjectPatch struct {
GitURL string `json:"gitUrl,omitempty"`
PrivateKey string `json:"privateKey,omitempty"`
Subfolder string `json:"subfolder,omitempty"`
RouterPattern string `json:"routerPattern,omitempty"`
ActiveSystemsTask string `json:"activeSystemsTask,omitempty"`
ActiveSystemsDeploy string `json:"activeSystemsDeploy,omitempty"`
ActiveSystemsRemove string `json:"activeSystemsRemove,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions pkg/graphql/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var ProjectByNameFragment = `fragment Project on Project {
name
gitUrl
subfolder
routerPattern
branches
pullrequests
productionEnvironment
Expand Down
3 changes: 2 additions & 1 deletion pkg/lagoon/projects/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func processProjectInfo(projectByName []byte) ([]byte, error) {
var data []output.Data
data = append(data, projectData)
dataMain := output.Table{
Header: []string{"ID", "ProjectName", "GitURL", "Branches", "PullRequests", "ProductionRoute", "DevEnvironments", "DevEnvLimit", "ProductionEnv", "AutoIdle"},
Header: []string{"ID", "ProjectName", "GitURL", "Branches", "PullRequests", "ProductionRoute", "DevEnvironments", "DevEnvLimit", "ProductionEnv", "RouterPattern", "AutoIdle"},
Data: data,
}
return json.Marshal(dataMain)
Expand Down Expand Up @@ -166,6 +166,7 @@ func processProjectExtra(project api.Project) []string {
fmt.Sprintf("%v/%v", currentDevEnvironments, project.DevelopmentEnvironmentsLimit),
fmt.Sprintf("%v", project.DevelopmentEnvironmentsLimit),
fmt.Sprintf("%v", project.ProductionEnvironment),
fmt.Sprintf("%s", project.RouterPattern),
fmt.Sprintf("%v", *project.AutoIdle),
}
return data
Expand Down
6 changes: 3 additions & 3 deletions pkg/lagoon/projects/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ func TestProjectInfo(t *testing.T) {
{"deployType":"branch","environmentType":"development","id":5,"name":"Development","openshiftProjectName":"high-cotton-development","route":"https://varnish-highcotton-org-development.us.amazee.io"},
{"deployType":"pullrequest","environmentType":"development","id":6,"name":"PR-175","openshiftProjectName":"high-cotton-pr-175","route":""},
{"deployType":"branch","environmentType":"development","id":10,"name":"high-cotton","openshiftProjectName":"high-cotton-high-cotton","route":null}],
"gitUrl":"test","id":18,"name":"high-cotton","productionEnvironment":"doopdd","pullrequests":"false","storageCalc":1,"subfolder":null}`
var projectInfoSuccess = `{"header":["ID","ProjectName","GitURL","Branches","PullRequests","ProductionRoute","DevEnvironments","DevEnvLimit","ProductionEnv","AutoIdle"],"data":[["18","high-cotton","test","false","false","http://highcotton.org","4/5","5","doopdd","1"]]}`
"gitUrl":"test","id":18,"name":"high-cotton","productionEnvironment":"doopdd","routerPattern":"${environment}-${project}.lagoon.example.com","pullrequests":"false","storageCalc":1,"subfolder":null}`
var projectInfoSuccess = `{"header":["ID","ProjectName","GitURL","Branches","PullRequests","ProductionRoute","DevEnvironments","DevEnvLimit","ProductionEnv","RouterPattern","AutoIdle"],"data":[["18","high-cotton","test","false","false","http://highcotton.org","4/5","5","doopdd","${environment}-${project}.lagoon.example.com","1"]]}`

returnResult, err := processProjectInfo([]byte(projectInfo))
if err != nil {
Expand All @@ -100,7 +100,7 @@ func TestProjectUpdate(t *testing.T) {
{"deployType":"branch","environmentType":"development","id":5,"name":"Development","openshiftProjectName":"high-cotton-development","route":"https://varnish-highcotton-org-development.us.amazee.io"},
{"deployType":"pullrequest","environmentType":"development","id":6,"name":"PR-175","openshiftProjectName":"high-cotton-pr-175","route":""},
{"deployType":"branch","environmentType":"development","id":10,"name":"high-cotton","openshiftProjectName":"high-cotton-high-cotton","route":null}],
"gitUrl":"test","id":18,"name":"high-cotton","productionEnvironment":"Master","pullrequests":"true","storageCalc":1,"subfolder":null}`
"gitUrl":"test","id":18,"name":"high-cotton","productionEnvironment":"Master","routerPattern":"${environment}-${project}.lagoon.example.com","pullrequests":"true","storageCalc":1,"subfolder":null}`

var jsonPatch = `{"branches":"false"}`
var updateProjectsSuccess = `{"id":18,"patch":{"branches":"false"}}`
Expand Down

0 comments on commit daa6337

Please sign in to comment.