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

Feature: fail oc:build if image tag already exist #1111

Open
lbruun opened this issue Nov 10, 2021 · 0 comments
Open

Feature: fail oc:build if image tag already exist #1111

lbruun opened this issue Nov 10, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@lbruun
Copy link

lbruun commented Nov 10, 2021

Some Docker Registries have a feature which disallows re-deploy of the same tag. This is good for several reasons.
(btw: there are differences in how "clever" such feature is in the registries which supports it, for example compare Azure, AWS, Harbor Registry, etc)

The benefits of having immutable build artifacts are well known. It is also well-known why it doesn't make sense for image consumers to use SHA tags (it is obscure and undecipherable for humans). This is why the various makers of Docker Registries have scrambled to provide immutable tag feature.

But what if the target registry supports no such feature? (looking at you OpenShift)

In such case we have no other option than to have the "deny" feature in the build pipeline, i.e. reject the build if tag already exist in the target registry.

Such feature is hereby proposed on the oc:build goal.

I propose two new configuration properties on this goal:

  • failBuildOnImageTagExist: (boolean). fails the build if the requested image tag already exists in the target Docker Registry. Defaults to false.

  • failBuildOnImageTagExistPattern (string) : Only performs the check if the tag name matches the regexp pattern given here. Only has relevance when failBuildOnImageTagExist is true. Defaults to ".*". (Justification: with this feature we can limit the feature to only certain tag name patterns. For example we may never want to replace existing tags with the word "FINAL" in the tag name, but replacing for other tag values is perfectly acceptable.

I'm fully aware that this will require an additional round-trip to the target Docker Registry: before initiating the build the plugin first needs to query for existing tags and evaluate those. In other words: the Maven build will take longer to execute with this feature enabled. Which is why it must be an opt-in feature.

I void this feature request if OpenShift will some day follow its competitors and implement tag name protection at the registry itself. :-)

@manusa manusa added the enhancement New feature or request label Nov 22, 2021
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

No branches or pull requests

2 participants