Skip to content

Commit

Permalink
Merge pull request #155 from jrasell/f_gh_121
Browse files Browse the repository at this point in the history
Break levant/deploy function out to make smaller and cleaner.
  • Loading branch information
jrasell committed Apr 28, 2018
2 parents 03c53d5 + cfa7090 commit 9263d4d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions levant/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ func TriggerDeployment(config *structs.Config) bool {
return false
}

preDep := levantDep.preDeploy()
if !preDep {
logging.Error("levant/deploy: pre-deployment process of job %s failed", *config.Job.Name)
return false
}

// Start the main deployment function.
success := levantDep.deploy()
if !success {
Expand All @@ -73,9 +79,7 @@ func TriggerDeployment(config *structs.Config) bool {
return true
}

// deploy triggers a register of the job resulting in a Nomad deployment which
// is monitored to determine the eventual state.
func (l *levantDeployment) deploy() (success bool) {
func (l *levantDeployment) preDeploy() (success bool) {

// Validate the job to check it is syntactically correct.
if _, _, err := l.nomad.Jobs().Validate(l.config.Job, nil); err != nil {
Expand All @@ -102,6 +106,13 @@ func (l *levantDeployment) deploy() (success bool) {
return
}

return true
}

// deploy triggers a register of the job resulting in a Nomad deployment which
// is monitored to determine the eventual state.
func (l *levantDeployment) deploy() (success bool) {

logging.Info("levant/deploy: triggering a deployment of job %s", *l.config.Job.Name)

eval, _, err := l.nomad.Jobs().Register(l.config.Job, nil)
Expand Down

0 comments on commit 9263d4d

Please sign in to comment.