Skip to content

Commit

Permalink
feat(cd): use manual flag from deployment job creator
Browse files Browse the repository at this point in the history
  • Loading branch information
smrz2001 committed Nov 9, 2023
1 parent 26ea4a5 commit a5054a8
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions cd/manager/jobs/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,13 @@ func (d deployJob) Advance() (job.JobState, error) {

func (d deployJob) prepareJob(deployTags map[manager.DeployComponent]string) error {
deployTag := ""
manual := false
if d.rollback {
// Use the latest successfully deployed tag when rolling back
deployTag = deployTags[d.component]
} else
// - If the specified deployment target is "latest", fetch the latest branch commit hash from GitHub.
// - Else if the specified deployment target is "release", use the specified release tag.
// - Else if the specified deployment target is "release" or "rollback", use the specified tag.
// - Else if it's a valid hash, use it.
// - Else use the last successfully deployed target from the database.
//
// The last 3 cases will only happen when (re)deploying manually, so we can note that in the notification.
if d.sha == job.DeployJobTarget_Latest {
if repo, err := manager.ComponentRepo(d.component); err != nil {
return err
Expand All @@ -172,17 +168,12 @@ func (d deployJob) prepareJob(deployTags map[manager.DeployComponent]string) err
}
} else if (d.sha == job.DeployJobTarget_Release) || (d.sha == job.DeployJobTarget_Rollback) {
deployTag = d.shaTag
manual = true
} else if manager.IsValidSha(d.sha) {
deployTag = d.sha
manual = true
} else {
return fmt.Errorf("prepareJob: invalid deployment type")
}
d.state.Params[job.DeployJobParam_DeployTag] = deployTag
if manual {
d.state.Params[job.DeployJobParam_Manual] = true
}
return nil
}

Expand Down

0 comments on commit a5054a8

Please sign in to comment.