From fe133927b8f529ca27a7a0b9a88236d27fe68903 Mon Sep 17 00:00:00 2001 From: "Claire.Nicholas" Date: Wed, 3 Jan 2024 14:25:16 -0600 Subject: [PATCH] fix: removing fix so that it can be included in another PR --- library/secret.go | 20 ++++++-------------- library/secret_test.go | 12 ++++++------ 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/library/secret.go b/library/secret.go index adfb348c..42188708 100644 --- a/library/secret.go +++ b/library/secret.go @@ -71,24 +71,16 @@ func (s *Secret) Match(from *pipeline.Container) bool { switch from.Environment["VELA_BUILD_EVENT"] { case constants.EventPush: eACL = checkEvent(events, constants.EventPush) - case constants.EventPull + ":" + constants.ActionOpened: - eACL = checkEvent(events, constants.EventPull+":"+constants.ActionOpened) - case constants.EventPull + ":" + constants.ActionSynchronize: - eACL = checkEvent(events, constants.EventPull+":"+constants.ActionSynchronize) - case constants.EventPull + ":" + constants.ActionEdited: - eACL = checkEvent(events, constants.EventPull+":"+constants.ActionEdited) + case constants.EventPull: + eACL = checkEvent(events, constants.EventPull) case constants.EventTag: eACL = checkEvent(events, constants.EventTag) case constants.EventDeploy: eACL = checkEvent(events, constants.EventDeploy) - case constants.EventComment + ":" + constants.ActionCreated: - eACL = checkEvent(events, constants.EventComment+":"+constants.ActionCreated) - case constants.EventComment + ":" + constants.ActionEdited: - eACL = checkEvent(events, constants.EventComment+":"+constants.ActionEdited) - case constants.EventDelete + ":" + constants.ActionBranch: - eACL = checkEvent(events, constants.EventDelete+":"+constants.ActionBranch) - case constants.EventDelete + ":" + constants.ActionTag: - eACL = checkEvent(events, constants.EventDelete+":"+constants.ActionTag) + case constants.EventComment: + eACL = checkEvent(events, constants.EventComment) + case constants.EventDelete: + eACL = checkEvent(events, constants.EventDelete) case constants.EventSchedule: eACL = checkEvent(events, constants.EventSchedule) } diff --git a/library/secret_test.go b/library/secret_test.go index b0e120a8..4fe2986f 100644 --- a/library/secret_test.go +++ b/library/secret_test.go @@ -49,9 +49,9 @@ func TestLibrary_Secret_Match(t *testing.T) { { step: &pipeline.Container{ Image: "alpine:latest", - Environment: map[string]string{"VELA_BUILD_EVENT": "pull_request:opened"}, + Environment: map[string]string{"VELA_BUILD_EVENT": "pull_request"}, }, - sec: &Secret{Name: &v, Value: &v, Images: &[]string{}, Events: &[]string{"pull_request:opened"}}, + sec: &Secret{Name: &v, Value: &v, Images: &[]string{}, Events: &[]string{"pull_request"}}, want: true, }, { @@ -73,9 +73,9 @@ func TestLibrary_Secret_Match(t *testing.T) { { step: &pipeline.Container{ Image: "alpine:latest", - Environment: map[string]string{"VELA_BUILD_EVENT": "comment:created"}, + Environment: map[string]string{"VELA_BUILD_EVENT": "comment"}, }, - sec: &Secret{Name: &v, Value: &v, Images: &[]string{}, Events: &[]string{"comment:created"}}, + sec: &Secret{Name: &v, Value: &v, Images: &[]string{}, Events: &[]string{"comment"}}, want: true, }, { @@ -163,9 +163,9 @@ func TestLibrary_Secret_Match(t *testing.T) { { step: &pipeline.Container{ Image: "alpine:latest", - Environment: map[string]string{"VELA_BUILD_EVENT": "pull_request:opened"}, + Environment: map[string]string{"VELA_BUILD_EVENT": "pull_request"}, }, - sec: &Secret{Name: &v, Value: &v, Images: &[]string{"alpine:latest"}, Events: &[]string{"push:opened"}}, + sec: &Secret{Name: &v, Value: &v, Images: &[]string{"alpine:latest"}, Events: &[]string{"push"}}, want: false, }, {