Skip to content

Commit ffa71cd

Browse files
authored
Change uint64 time to int64 (#348)
1 parent cf2f828 commit ffa71cd

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

cmd/acr/annotate.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var (
4646
type annotateParameters struct {
4747
*rootParameters
4848
filters []string
49-
filterTimeout uint64
49+
filterTimeout int64
5050
artifactType string
5151
annotations []string
5252
untagged bool
@@ -136,7 +136,7 @@ func newAnnotateCmd(rootParams *rootParameters) *cobra.Command {
136136

137137
cmd.Flags().StringArrayVarP(&annotateParams.filters, "filter", "f", nil, `Specify the repository and a regular expression filter for the tag name. If a tag matches the filter, it will be annotated. If multiple tags refer to the same manifest and a tag matches the filter, the manifest will be annotated.
138138
Note: If backtracking is used in the regexp it's possible for the expression to run into an infinite loop. The default timeout is set to 1 minute for evaluation of any filter expression. Use the '--filter-timeout-seconds' option to set a different value`)
139-
cmd.Flags().Uint64Var(&annotateParams.filterTimeout, "filter-timeout-seconds", defaultRegexpMatchTimeoutSeconds, "This limits the evaluation of the regex filter, and will return a timeout error if this duration is exceeded during a single evaluation. If written incorrectly a regexp filter with backtracking can result in an infinite loop")
139+
cmd.Flags().Int64Var(&annotateParams.filterTimeout, "filter-timeout-seconds", defaultRegexpMatchTimeoutSeconds, "This limits the evaluation of the regex filter, and will return a timeout error if this duration is exceeded during a single evaluation. If written incorrectly a regexp filter with backtracking can result in an infinite loop")
140140
cmd.Flags().StringVar(&annotateParams.artifactType, "artifact-type", "", "The configurable artifact type for an organization")
141141
cmd.Flags().StringSliceVarP(&annotateParams.annotations, "annotations", "a", []string{}, "The configurable annotation key value that can be specified one or more times")
142142
cmd.Flags().BoolVar(&annotateParams.untagged, "untagged", false, "If the untagged flag is set, all the manifests that do not have any tags associated to them will also be annotated, except if they belong to a manifest list that contains at least one tag")
@@ -159,7 +159,7 @@ func annotateTags(ctx context.Context,
159159
artifactType string,
160160
annotations []string,
161161
tagFilter string,
162-
regexpMatchTimeoutSeconds uint64,
162+
regexpMatchTimeoutSeconds int64,
163163
dryRun bool) (int, error) {
164164

165165
if !dryRun {

cmd/acr/purge.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ var (
5858

5959
// Default settings for regexp2
6060
const (
61-
defaultRegexpMatchTimeoutSeconds uint64 = 60
61+
defaultRegexpMatchTimeoutSeconds int64 = 60
6262
)
6363

6464
// purgeParameters defines the parameters that the purge command uses (including the registry name, username and password).
@@ -67,7 +67,7 @@ type purgeParameters struct {
6767
ago string
6868
keep int
6969
filters []string
70-
filterTimeout uint64
70+
filterTimeout int64
7171
untagged bool
7272
dryRun bool
7373
concurrency int
@@ -160,7 +160,7 @@ func newPurgeCmd(rootParams *rootParameters) *cobra.Command {
160160
cmd.Flags().IntVar(&purgeParams.keep, "keep", 0, "Number of latest to-be-deleted tags to keep, use this when you want to keep at least x number of latest tags that could be deleted meeting all other filter criteria")
161161
cmd.Flags().StringArrayVarP(&purgeParams.filters, "filter", "f", nil, "Specify the repository and a regular expression filter for the tag name, if a tag matches the filter and is older than the duration specified in ago it will be deleted. Note: If backtracking is used in the regexp it's possible for the expression to run into an infinite loop. The default timeout is set to 1 minute for evaluation of any filter expression. Use the '--filter-timeout-seconds' option to set a different value.")
162162
cmd.Flags().StringArrayVarP(&purgeParams.configs, "config", "c", nil, "Authentication config paths (e.g. C://Users/docker/config.json)")
163-
cmd.Flags().Uint64Var(&purgeParams.filterTimeout, "filter-timeout-seconds", defaultRegexpMatchTimeoutSeconds, "This limits the evaluation of the regex filter, and will return a timeout error if this duration is exceeded during a single evaluation. If written incorrectly a regexp filter with backtracking can result in an infinite loop.")
163+
cmd.Flags().Int64Var(&purgeParams.filterTimeout, "filter-timeout-seconds", defaultRegexpMatchTimeoutSeconds, "This limits the evaluation of the regex filter, and will return a timeout error if this duration is exceeded during a single evaluation. If written incorrectly a regexp filter with backtracking can result in an infinite loop.")
164164
cmd.Flags().IntVar(&purgeParams.concurrency, "concurrency", defaultPoolSize, concurrencyDescription)
165165
cmd.Flags().BoolP("help", "h", false, "Print usage")
166166
cmd.MarkFlagRequired("filter")
@@ -169,7 +169,7 @@ func newPurgeCmd(rootParams *rootParameters) *cobra.Command {
169169
}
170170

171171
// purgeTags deletes all tags that are older than the ago value and that match the tagFilter string.
172-
func purgeTags(ctx context.Context, acrClient api.AcrCLIClientInterface, poolSize int, loginURL string, repoName string, ago string, tagFilter string, keep int, regexpMatchTimeoutSeconds uint64) (int, error) {
172+
func purgeTags(ctx context.Context, acrClient api.AcrCLIClientInterface, poolSize int, loginURL string, repoName string, ago string, tagFilter string, keep int, regexpMatchTimeoutSeconds int64) (int, error) {
173173
fmt.Printf("Deleting tags for repository: %s\n", repoName)
174174
agoDuration, err := parseDuration(ago)
175175
if err != nil {
@@ -330,7 +330,7 @@ func purgeDanglingManifests(ctx context.Context, acrClient api.AcrCLIClientInter
330330
}
331331

332332
// dryRunPurge outputs everything that would be deleted if the purge command was executed
333-
func dryRunPurge(ctx context.Context, acrClient api.AcrCLIClientInterface, loginURL string, repoName string, ago string, filter string, untagged bool, keep int, regexMatchTimeout uint64) (int, int, error) {
333+
func dryRunPurge(ctx context.Context, acrClient api.AcrCLIClientInterface, loginURL string, repoName string, ago string, filter string, untagged bool, keep int, regexMatchTimeout int64) (int, int, error) {
334334
deletedTagsCount := 0
335335
deletedManifestsCount := 0
336336
// In order to keep track if a manifest would get deleted a map is defined that as a key has the manifest

cmd/common/image_functions.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const (
2525
headerLink = "Link"
2626
mediaTypeDockerManifestList = "application/vnd.docker.distribution.manifest.list.v2+json"
2727
defaultRegexpOptions regexp2.RegexOptions = regexp2.RE2 // This option will turn on compatibility mode so that it uses the group rules in regexp
28-
defaultRegexpMatchTimeoutSeconds uint64 = 60
28+
defaultRegexpMatchTimeoutSeconds int64 = 60
2929
mediaTypeArtifactManifest = "application/vnd.oci.artifact.manifest.v1+json"
3030
)
3131

@@ -48,7 +48,7 @@ func GetAllRepositoryNames(ctx context.Context, client acrapi.BaseClientAPI) ([]
4848
}
4949

5050
// GetMatchingRepos get all repositories in current registry, that match the provided regular expression
51-
func GetMatchingRepos(repoNames []string, repoRegex string, regexMatchTimeout uint64) ([]string, error) {
51+
func GetMatchingRepos(repoNames []string, repoRegex string, regexMatchTimeout int64) ([]string, error) {
5252
filter, err := BuildRegexFilter(repoRegex, regexMatchTimeout)
5353
if err != nil {
5454
return nil, err
@@ -97,7 +97,7 @@ func GetRepositoryAndTagRegex(filter string) (string, string, error) {
9797
}
9898

9999
// CollectTagFilters collects all matching repos and collects the associated tag filters
100-
func CollectTagFilters(ctx context.Context, rawFilters []string, client acrapi.BaseClientAPI, regexMatchTimeout uint64) (map[string]string, error) {
100+
func CollectTagFilters(ctx context.Context, rawFilters []string, client acrapi.BaseClientAPI, regexMatchTimeout int64) (map[string]string, error) {
101101
allRepoNames, err := GetAllRepositoryNames(ctx, client)
102102
if err != nil {
103103
return nil, err
@@ -270,7 +270,7 @@ func UpdateForManifestWithoutSubjectToDelete(ctx context.Context, manifest acr.M
270270
}
271271

272272
// BuildRegexFilter compiles a regex state machine from a regex expression
273-
func BuildRegexFilter(expression string, regexpMatchTimeoutSeconds uint64) (*regexp2.Regexp, error) {
273+
func BuildRegexFilter(expression string, regexpMatchTimeoutSeconds int64) (*regexp2.Regexp, error) {
274274
regexp, err := regexp2.Compile(expression, defaultRegexpOptions)
275275
if err != nil {
276276
return nil, err

0 commit comments

Comments
 (0)