diff --git a/api/container_registries_ghcr_test.go b/api/container_registries_ghcr_test.go index 8c9e0fe63..035564e1f 100644 --- a/api/container_registries_ghcr_test.go +++ b/api/container_registries_ghcr_test.go @@ -34,11 +34,10 @@ func TestContainerRegistriesNewGhcr(t *testing.T) { subject := api.NewContainerRegistry("integration_name", api.GhcrContainerRegistry, api.GhcrData{ - RegistryDomain: "southamerica-east1-docker.pkg.dev", - LimitByTag: []string{"foo"}, - LimitByLabel: []map[string]string{{"key": "value"}}, - LimitByRep: []string{"xyz/name"}, - LimitNumImg: 15, + LimitByTag: []string{"foo"}, + LimitByLabel: []map[string]string{{"key": "value"}}, + LimitByRep: []string{"xyz/name"}, + LimitNumImg: 15, Credentials: api.GhcrCredentials{ Username: "user", Password: "pass", diff --git a/cli/cmd/integration_ctr_reg_limits.go b/cli/cmd/integration_ctr_reg_limits.go index e73fb3890..1fc78862e 100644 --- a/cli/cmd/integration_ctr_reg_limits.go +++ b/cli/cmd/integration_ctr_reg_limits.go @@ -42,7 +42,7 @@ func castStringToLimitByLabel(labels string) []map[string]string { return out } -func askForV2Limits(answers interface{}) error { +func askV2LimitByTags(answers interface{}) error { custom := false if err := survey.AskOne(&survey.Confirm{ Message: "Configure limit of scans by tags?", @@ -63,7 +63,11 @@ func askForV2Limits(answers interface{}) error { } } - custom = false + return nil +} + +func askV2LimitByLabels(answers interface{}) error { + custom := false if err := survey.AskOne(&survey.Confirm{ Message: "Configure limit of scans by labels?", }, &custom); err != nil { @@ -83,7 +87,11 @@ func askForV2Limits(answers interface{}) error { } } - custom = false + return nil +} + +func askV2LimitByRepositories(answers interface{}) error { + custom := false if err := survey.AskOne(&survey.Confirm{ Message: "Configure limit of scans by repositories?", }, &custom); err != nil { @@ -105,3 +113,13 @@ func askForV2Limits(answers interface{}) error { return nil } + +func askV2Limits(answers interface{}) error { + if err := askV2LimitByTags(answers); err != nil { + return err + } + if err := askV2LimitByLabels(answers); err != nil { + return err + } + return askV2LimitByRepositories(answers) +} diff --git a/cli/cmd/integration_gar.go b/cli/cmd/integration_gar.go index ed77b3149..26be72ee8 100644 --- a/cli/cmd/integration_gar.go +++ b/cli/cmd/integration_gar.go @@ -131,7 +131,7 @@ func createGarIntegration() error { } // @afiune these are the new API v2 limits - if err := askForV2Limits(&answers); err != nil { + if err := askV2Limits(&answers); err != nil { return err } diff --git a/cli/cmd/integration_ghcr.go b/cli/cmd/integration_ghcr.go index 7830010c0..5d0aab7ab 100644 --- a/cli/cmd/integration_ghcr.go +++ b/cli/cmd/integration_ghcr.go @@ -91,7 +91,7 @@ func createGhcrIntegration() error { } // @afiune these are the new API v2 limits - if err := askForV2Limits(&answers); err != nil { + if err := askV2Limits(&answers); err != nil { return err }