From b5eadf626cbf466e71713b2d6302a810276751b5 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Sun, 21 Jul 2019 10:10:14 -0700 Subject: [PATCH] convert legacy deployment event to promote event --- CHANGELOG.md | 1 + yaml/converter/legacy/internal/config.go | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54df9fc..768b6a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased ### Added - 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 ### Added diff --git a/yaml/converter/legacy/internal/config.go b/yaml/converter/legacy/internal/config.go index fd2bab6..7ea7ae6 100644 --- a/yaml/converter/legacy/internal/config.go +++ b/yaml/converter/legacy/internal/config.go @@ -267,13 +267,25 @@ func toConditions(from Constraints) droneyaml.Conditions { Exclude: from.Branch.Exclude, }, Status: droneyaml.Condition{ - Include: from.Status.Include, - Exclude: from.Status.Exclude, + Include: toPromote(from.Status.Include), + Exclude: toPromote(from.Status.Exclude), }, 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 // to the new environment syntax. func toEnvironment(from *Container) map[string]*droneyaml.Variable {