Skip to content

Commit ac274c9

Browse files
committed
CL-522 | filter already revoked jobs in the Filter function
Signed-off-by: Gabriela S. Soria <[email protected]>
1 parent e8a0a93 commit ac274c9

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

resources/signer.signingjobs.go

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
package resources
22

33
import (
4+
"fmt"
5+
46
"github.com/aws/aws-sdk-go/aws"
57
"github.com/aws/aws-sdk-go/aws/session"
68
"github.com/aws/aws-sdk-go/service/signer"
79
"github.com/rebuy-de/aws-nuke/v2/pkg/types"
810
)
911

1012
type SignerSigningJob struct {
11-
svc *signer.Signer
12-
jobId *string
13-
reason string
13+
svc *signer.Signer
14+
jobId *string
15+
reason string
16+
isRevoked *bool
1417
}
1518

1619
func init() {
@@ -26,14 +29,12 @@ func ListSignerSigningJobs(sess *session.Session) ([]Resource, error) {
2629

2730
err := svc.ListSigningJobsPages(listJobsInput, func(page *signer.ListSigningJobsOutput, lastPage bool) bool {
2831
for _, job := range page.Jobs {
29-
// Consider all non-revoked jobs on this page
30-
if job.IsRevoked == nil || !*job.IsRevoked {
31-
resources = append(resources, &SignerSigningJob{
32-
svc: svc,
33-
jobId: job.JobId,
34-
reason: reason,
35-
})
36-
}
32+
resources = append(resources, &SignerSigningJob{
33+
svc: svc,
34+
jobId: job.JobId,
35+
reason: reason,
36+
isRevoked: job.IsRevoked,
37+
})
3738
}
3839
return true // continue iterating over pages
3940
})
@@ -44,6 +45,10 @@ func ListSignerSigningJobs(sess *session.Session) ([]Resource, error) {
4445
}
4546

4647
func (j *SignerSigningJob) Filter() error {
48+
// Consider all non-revoked jobs
49+
if *j.isRevoked {
50+
return fmt.Errorf("job already revoked")
51+
}
4752
return nil
4853
}
4954

0 commit comments

Comments
 (0)