Skip to content

Commit

Permalink
Merge pull request #7 from aiven/rkar-remove-requester-from-approvers
Browse files Browse the repository at this point in the history
remove requester from approvers
  • Loading branch information
roope-kar authored Oct 3, 2024
2 parents 42d0bff + b6e6790 commit fa5a6e8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3,949 deletions.
Binary file modified build/checker
Binary file not shown.
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func main() {
result := Result{Ok: true, Errors: []ResultError{}}

requester := findExternalIdentity(*requesterID, &plan)
approvers := findApprovers(strings.Split(*approverIDs, ","), &plan)
approvers := findApprovers(strings.Split(*approverIDs, ","), *requesterID, &plan)

for _, resourceChange := range plan.Changes {
if resourceChange.Type == AivenKafkaTopic {
Expand All @@ -149,11 +149,11 @@ func findExternalIdentity(userID string, plan *Plan) *StateResource {
return nil
}

func findApprovers(approverIDs []string, plan *Plan) []*StateResource {
func findApprovers(approverIDs []string, requesterID string, plan *Plan) []*StateResource {
var approvers []*StateResource
for _, approverID := range approverIDs {
approver := findExternalIdentity(approverID, plan)
if approver != nil {
if approver != nil && requesterID != approverID {
approvers = append(approvers, approver)
}
}
Expand Down
10 changes: 10 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ func TestE2E_Plans(t *testing.T) {
ExpectStdout: `{"ok":false,"errors":\[{"error":"approval is required from a member of the owner group","address":"aiven_kafka_topic.foo"}\]}`, //nolint:lll
ExpectStderr: "",
},
{
Name: fmt.Sprintf("[%s] Does not consider requester as approver", plan),
Args: Args{
Requester: "alice",
Approvers: "alice",
Plan: plan,
},
ExpectStdout: `{"ok":false,"errors":\[{"error":"approval is required from a member of the owner group","address":"aiven_kafka_topic.foo"}\]}`, //nolint:lll
ExpectStderr: "",
},
}
all_tests = append(all_tests, tests...)

Check failure on line 140 in main_test.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

SA4010: this result of append is never used, except maybe in other appends (staticcheck)
}
Expand Down
Loading

0 comments on commit fa5a6e8

Please sign in to comment.