Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend image policy with numerical ordering #102

Closed
stefanprodan opened this issue Feb 10, 2021 · 2 comments · Fixed by #104
Closed

Extend image policy with numerical ordering #102

stefanprodan opened this issue Feb 10, 2021 · 2 comments · Fixed by #104
Assignees
Labels
enhancement New feature or request

Comments

@stefanprodan
Copy link
Member

While alphabetical ordering works great with image tags that contain a RFC3339 timestamp, it's not suitable for CI build IDs, as these are numbers with no padding.

I propose we introduce a new ordering option called numerical to be able to correct detect the latest build for tags in the format <PREFIX>-<BUILD_ID>.

Example:

kind: ImagePolicy
spec:
  filterTags:
    pattern: '^main-[a-fA-F0-9]+-(?P<id>.*)'
    extract: '$id'
  policy:
    numerical:
      order: asc

Given the tags main-845d3a80-100 and main-3e32dc8a-2 the numerical policy, unlike alphabetical, will chose main-3e32dc8a-100 as the latest build.

@stefanprodan stefanprodan added the enhancement New feature or request label Feb 10, 2021
@relu
Copy link
Member

relu commented Feb 10, 2021

I think this makes sense. I can take a stab at it, should be straightforward to implement.

@squaremo
Copy link
Member

Would also be a nicer fit for using with date +%s, and would make git rev-list --count HEAD workable.

relu added a commit that referenced this issue Feb 10, 2021
Converts the given list of tags to floats and compares them based on the
ordering rule.
If a tag is not convertable, it will err and fail to compute the latest
version.

Fixes #102

Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
relu added a commit that referenced this issue Feb 11, 2021
Converts the given list of tags to floats and compares them based on the
ordering rule.
If a tag is not convertible, it will err and fail to compute the latest
version.

Fixes #102

Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
relu added a commit that referenced this issue Feb 11, 2021
Converts the given list of tags to floats and compares them based on the
ordering rule.
If a tag is not convertible, it will err and fail to compute the latest
version.

Fixes #102

Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
relu added a commit that referenced this issue Feb 11, 2021
Converts the given list of tags to floats and compares them based on the
ordering rule.
If a tag is not convertible, it will err and fail to compute the latest
version.

Fixes #102

Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
relu added a commit that referenced this issue Feb 11, 2021
Converts the given list of tags to floats and compares them based on the
ordering rule.
If a tag is not convertible, it will err and fail to compute the latest
version.

Fixes #102

Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants