Skip to content

Commit

Permalink
Merge pull request #68 from openinfradev/fix-stage-actions
Browse files Browse the repository at this point in the history
app-serving: 파이프라인 상의 버튼 위치 조정
  • Loading branch information
robertchoi80 authored Jun 1, 2023
2 parents f4bbf9f + a0d7bc9 commit edc58ed
Showing 1 changed file with 37 additions and 20 deletions.
57 changes: 37 additions & 20 deletions internal/delivery/http/app-serve-app.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,9 @@ func makeStages(app *domain.AppServeApp) []domain.StageResponse {
}

func makeStage(app *domain.AppServeApp, pl string) domain.StageResponse {
taskStatus := app.AppServeAppTasks[0].Status
strategy := app.AppServeAppTasks[0].Strategy

stage := domain.StageResponse{
Name: pl,
Status: StatusStages[app.Status][pl],
Expand All @@ -350,21 +353,42 @@ func makeStage(app *domain.AppServeApp, pl string) domain.StageResponse {

var actions []domain.ActionResponse
if stage.Status == "DEPLOY_SUCCESS" {
action := domain.ActionResponse{
Name: "ENDPOINT",
Uri: app.EndpointUrl,
Type: "LINK",
}
actions = append(actions, action)
} else if stage.Status == "PROMOTE_WAIT" && app.AppServeAppTasks[0].Strategy == "blue-green" {
action := domain.ActionResponse{
Name: "PREVIEW",
Uri: app.PreviewEndpointUrl,
Type: "LINK",
if strategy == "rolling-update" {
action := domain.ActionResponse{
Name: "ENDPOINT",
Uri: app.EndpointUrl,
Type: "LINK",
}
actions = append(actions, action)
} else if strategy == "blue-green" {
if taskStatus == "PROMOTE_SUCCESS" || taskStatus == "ABORT_SUCCESS" {
action := domain.ActionResponse{
Name: "ENDPOINT",
Uri: app.EndpointUrl,
Type: "LINK",
}
actions = append(actions, action)
} else if taskStatus == "PROMOTE_WAIT" {
action := domain.ActionResponse{
Name: "OLD_EP",
Uri: app.EndpointUrl,
Type: "LINK",
}
actions = append(actions, action)

action = domain.ActionResponse{
Name: "NEW_EP",
Uri: app.PreviewEndpointUrl,
Type: "LINK",
}
actions = append(actions, action)
}
} else {
log.Error("Not supported strategy!")
}
actions = append(actions, action)

action = domain.ActionResponse{
} else if stage.Status == "PROMOTE_WAIT" && strategy == "blue-green" {
action := domain.ActionResponse{
Name: "PROMOTE",
Uri: fmt.Sprintf(internal.API_PREFIX+internal.API_VERSION+
"/organizations/%v/app-serve-apps/%v", app.OrganizationId, app.ID),
Expand All @@ -383,13 +407,6 @@ func makeStage(app *domain.AppServeApp, pl string) domain.StageResponse {
Body: map[string]string{"strategy": "blue-green", "abort": "true"},
}
actions = append(actions, action)
} else if stage.Status == "PROMOTE_SUCCESS" {
action := domain.ActionResponse{
Name: "ENDPOINT",
Uri: app.EndpointUrl,
Type: "LINK",
}
actions = append(actions, action)
}

stage.Actions = &actions
Expand Down

0 comments on commit edc58ed

Please sign in to comment.