From 4413245d639d19cd5c5aa8b7acd168ff8b399887 Mon Sep 17 00:00:00 2001 From: Leandro Carneiro <42899277+carnei-ro@users.noreply.github.com> Date: Tue, 23 May 2023 10:29:34 -0300 Subject: [PATCH 1/4] workaround(validate): panic when trying to use inexistent .Error() (#95) Co-authored-by: Leandro Carneiro --- cmd/k8s-pipeliner/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/k8s-pipeliner/main.go b/cmd/k8s-pipeliner/main.go index 857a6f1..19e6968 100644 --- a/cmd/k8s-pipeliner/main.go +++ b/cmd/k8s-pipeliner/main.go @@ -53,8 +53,8 @@ func main() { } if err := app.Run(os.Args); err != nil { - fmt.Println(err.Error()) - os.Exit(1) + fmt.Printf("error: %v", err) + os.Exit(255) } } From 1a16925f3a895b2668f8eb38e7dd73d338778736 Mon Sep 17 00:00:00 2001 From: Leandro Carneiro <42899277+carnei-ro@users.noreply.github.com> Date: Thu, 25 May 2023 14:25:41 -0300 Subject: [PATCH 2/4] add TrafficManagement to stage metadata (#96) Co-authored-by: Leandro Carneiro --- pipeline/builder/builder.go | 7 +++++++ pipeline/builder/builder_test.go | 16 ++++++++++++++++ pipeline/builder/types/triggers.go | 1 + pipeline/builder/types/types.go | 12 ++++++++++++ 4 files changed, 36 insertions(+) diff --git a/pipeline/builder/builder.go b/pipeline/builder/builder.go index 35ba208..fd6f313 100644 --- a/pipeline/builder/builder.go +++ b/pipeline/builder/builder.go @@ -838,6 +838,13 @@ func buildStageMetadata(s config.Stage, t string, index int, linear bool) types. Type: t, Notifications: notifications, SendNotifications: (len(notifications) > 0), + TrafficManagement: &types.TrafficManagement{ + Enabled: false, + Options: &types.TrafficManagementOptions{ + EnableTraffic: false, + Services: []string{}, + }, + }, } if len(s.Condition) > 0 { diff --git a/pipeline/builder/builder_test.go b/pipeline/builder/builder_test.go index 42c2988..7d1fdb4 100644 --- a/pipeline/builder/builder_test.go +++ b/pipeline/builder/builder_test.go @@ -1399,6 +1399,22 @@ func TestBuilderPipelineStages(t *testing.T) { assert.Equal(t, []string{"2"}, spinnaker.Stages[0].(*types.RunSpinnakerPipelineStage).StageMetadata.RequisiteStageRefIds) }) + + t.Run("TrafficManagement is assigned", func(t *testing.T) { + pipeline := &config.Pipeline{ + Stages: []config.Stage{ + { + Deploy: &config.DeployStage{}, + }, + }, + } + + builder := builder.New(pipeline) + spinnaker, err := builder.Pipeline() + require.NoError(t, err, "error generating pipeline json") + + assert.Equal(t, &types.TrafficManagement{Enabled: false, Options: &types.TrafficManagementOptions{EnableTraffic: false, Services: []string{}}}, spinnaker.Stages[0].(*types.DeployStage).StageMetadata.TrafficManagement) + }) }) } diff --git a/pipeline/builder/types/triggers.go b/pipeline/builder/types/triggers.go index 9b617ce..5c6b155 100644 --- a/pipeline/builder/types/triggers.go +++ b/pipeline/builder/types/triggers.go @@ -20,6 +20,7 @@ type StageMetadata struct { Notifications []Notification `json:"notifications,omitempty"` SendNotifications bool `json:"sendNotifications,omitempty"` StageEnabled *OptionalStageSupport `json:"stageEnabled,omitempty"` + TrafficManagement *TrafficManagement `json:"trafficManagement"` } // JenkinsTrigger constructs the JSON necessary to include a Jenkins trigger diff --git a/pipeline/builder/types/types.go b/pipeline/builder/types/types.go index f7e58d5..36f7284 100644 --- a/pipeline/builder/types/types.go +++ b/pipeline/builder/types/types.go @@ -569,3 +569,15 @@ type EvaluateVariablesStage struct { func (evs EvaluateVariablesStage) spinnakerStage() {} var _ Stage = EvaluateVariablesStage{} + +// TrafficManagement is a struct for the Spinnaker traffic management configuration +type TrafficManagement struct { + Enabled bool `json:"enabled" default:"false"` + Options *TrafficManagementOptions `json:"options"` +} + +// TrafficManagementOptions options for traffic management +type TrafficManagementOptions struct { + EnableTraffic bool `json:"enableTraffic" default:"false"` + Services []string `json:"services" default:"[]"` +} From 63c3df6c10fc68c962a658140d27a491ebf9aa49 Mon Sep 17 00:00:00 2001 From: Leandro Carneiro <42899277+carnei-ro@users.noreply.github.com> Date: Fri, 28 Jul 2023 16:52:23 -0300 Subject: [PATCH 3/4] SRE-8978: rollout jira_comment action (#98) Co-authored-by: Leandro Carneiro --- .github/workflows/jira_comment.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/workflows/jira_comment.yml diff --git a/.github/workflows/jira_comment.yml b/.github/workflows/jira_comment.yml new file mode 100644 index 0000000..32a8b8a --- /dev/null +++ b/.github/workflows/jira_comment.yml @@ -0,0 +1,11 @@ +on: + pull_request_target: + types: + - closed + +jobs: + jira_comment: + if: github.event.pull_request.merged == true + uses: namely/sre/.github/workflows/reusable-workflow-jira-comment.yml@main + secrets: + jira_token: ${{ secrets.NAMELY_ENG_INTEGRATIONS_JIRA_PAT }} From ab9081e43f2fae5dd1194b6dc229f653f06cedf0 Mon Sep 17 00:00:00 2001 From: Leandro Carneiro <42899277+carnei-ro@users.noreply.github.com> Date: Tue, 5 Dec 2023 08:57:09 -0300 Subject: [PATCH 4/4] SRE-9103 ci: Add permissions to jira_comment workflow (#99) Co-authored-by: Leandro Carneiro --- .github/workflows/jira_comment.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/jira_comment.yml b/.github/workflows/jira_comment.yml index 32a8b8a..6c9760d 100644 --- a/.github/workflows/jira_comment.yml +++ b/.github/workflows/jira_comment.yml @@ -5,6 +5,8 @@ on: jobs: jira_comment: + permissions: + pull-requests: read if: github.event.pull_request.merged == true uses: namely/sre/.github/workflows/reusable-workflow-jira-comment.yml@main secrets: