Skip to content

Commit

Permalink
add possibility to turn on/off image scanning not only during repo cr…
Browse files Browse the repository at this point in the history
…eation, but when repo already created
  • Loading branch information
Roman Voitenko committed Oct 1, 2020
1 parent d8b6b48 commit 3501d9a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/drone-ecr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ func main() {
if err != nil {
log.Fatal(fmt.Sprintf("error creating ECR repo: %v", err))
}
err = updateImageScannningConfig(svc, trimHostname(repo, registry), scanOnPush)
if err != nil {
log.Fatal(fmt.Sprintf("error updating scan on push for ECR repo: %v", err))
}
}

if lifecyclePolicy != "" {
Expand Down Expand Up @@ -134,6 +138,15 @@ func ensureRepoExists(svc *ecr.ECR, name string, scanOnPush bool) (err error) {
return
}

func updateImageScannningConfig(svc *ecr.ECR, name string, scanOnPush bool) (err error) {
input := &ecr.PutImageScanningConfigurationInput{}
input.SetRepositoryName(name)
input.SetImageScanningConfiguration(&ecr.ImageScanningConfiguration{ScanOnPush: &scanOnPush})
_, err = svc.PutImageScanningConfiguration(input)

return err
}

func uploadLifeCyclePolicy(svc *ecr.ECR, lifecyclePolicy string, name string) (err error) {
input := &ecr.PutLifecyclePolicyInput{}
input.SetLifecyclePolicyText(lifecyclePolicy)
Expand Down

0 comments on commit 3501d9a

Please sign in to comment.