phenixblue / imageswap-webhook

Image Swap Mutating Admission Webhook for Kubernetes
Apache License 2.0
154 stars 53 forks source link

Fixes #51 add mapping mode "EXACT" #52

Closed ferenc-hechler closed 3 years ago

ferenc-hechler commented 3 years ago

What type of PR is this?

/kind feature

What this PR does / why we need it:

See ISSUE #51

Which issue(s) this PR fixes:

Fixes #51

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Support for new mapping-mode "EXACT" was added.
The enhancement is backward compatible, so the "MAPS" and "LEGACY" mapping modes work as before.

Additional documentation e.g., usage docs, etc.:

To activate the new mapping mode the environment variable IMAGESWAP_MODE has to be set to "EXACT".
In this mode, the mapping configuration is handled simply by matching the full docker image name against the left side 
of the mapping. If the docker image name contains an image tag, the new seperator syntax "::" has to be used 
in the mapping file. E.g.:

    mysql/mysql-server:5.6::myownrepo.example.com/base/public-image-cache:mysql_mysql-server_5.6
phenixblue commented 3 years ago

Hi @ferenc-hechler thanks for opening a PR!

Just a heads up that it's probably going to be the weekend before I can get around to reviewing this.

One comment though...I would be interested in exploring if this can be added in a way that can work with the "MAPS" mode instead of having an explicit mode to its own. I think there's some potential for this to be useful along with a mix of normal map configurations.

Maybe there's a way to add a new map syntax or adapt the existing syntax used for library level image maps in some way.

Thoughts?

ferenc-hechler commented 3 years ago

Hi @phenixblue,

thanks for your answer. Of course, this feature can be implemented by extending the existing mapping config syntax to mark entries to be handled only as EXACT matches. Internally those entries should be handled in a separate dictionary to avoid confusion. I will update the PR before weekend. :-)

I will start with the following syntax:

[EXACT]<source>::<target>

Feel free to make better suggestions.

phenixblue commented 3 years ago

I also just noticed your target branch was my feature branch. I just merged #50 into master. Would you mind correcting that/rebasing to target master so CI can kick in and run the checks as well?

ferenc-hechler commented 3 years ago

Rebase sounds difficult, I will create a new PR, then we can reject this one.

ferenc-hechler commented 3 years ago

Created a replacement for this PR: #54