convert legacy deployment event to promote event

This commit is contained in:
Brad Rydzewski 2019-07-21 10:10:14 -07:00
parent c50000a465
commit b5eadf626c
2 changed files with 15 additions and 2 deletions

View File

@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased ## Unreleased
### Added ### Added
- Convert legacy branch filter to ref trigger, by [@bradrydzewski](https://github.com/bradrydzewski). - Convert legacy branch filter to ref trigger, by [@bradrydzewski](https://github.com/bradrydzewski).
- Convert legacy deployment event to promotion event, by [@bradrydzewski](https://github.com/bradrydzewski).
## [1.2.1] - 2019-07-17 ## [1.2.1] - 2019-07-17
### Added ### Added

View File

@ -267,13 +267,25 @@ func toConditions(from Constraints) droneyaml.Conditions {
Exclude: from.Branch.Exclude, Exclude: from.Branch.Exclude,
}, },
Status: droneyaml.Condition{ Status: droneyaml.Condition{
Include: from.Status.Include, Include: toPromote(from.Status.Include),
Exclude: from.Status.Exclude, Exclude: toPromote(from.Status.Exclude),
}, },
Matrix: from.Matrix, Matrix: from.Matrix,
} }
} }
// helper function finds and replaces deployment event status
// with promote status
func toPromote(events []string) []string {
for i, s := range events {
switch s {
case "deploy", "deployment":
events[i] = "promote"
}
}
return events
}
// helper function converts the legacy environment syntax // helper function converts the legacy environment syntax
// to the new environment syntax. // to the new environment syntax.
func toEnvironment(from *Container) map[string]*droneyaml.Variable { func toEnvironment(from *Container) map[string]*droneyaml.Variable {