phenixblue / imageswap-webhook

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

Add logic to handle `:<port>` in key or value for swap map entries #50

Closed phenixblue closed 3 years ago

phenixblue commented 3 years ago

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespace from that line:

/kind bug

/kind cleanup /kind deprecation /kind design /kind documentation /kind feature /kind release

What this PR does / why we need it:

This PR adds additional logic to handle :<port> style registry syntax for the key or value portions of a map definition.

Example:

registry.waldo.com:8443::registry.garply.com # Swap map key that includes a port
registry.foo.com::localhost:30003/foo # Swap map value that includes a port
registry.bar.com:8443::registry.baz.com:30003/bar # Swap map key & value that include a port

This adds a new separator type for map definitions: :: instead of :

Going forward the :: syntax will be the default, but for now the existing : will work for any map definitions that don't include a port in the key or value.

Additional logic has also been added to handle the case where a map definition includes a port in the key or value with/without the new separator.

Warning messages will be logged for maps using the old style separator or when a port is specified with the incorrect syntax.

Which issue(s) this PR fixes:

Fixes #49

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

- The existing separator syntax for maps (ie `:`) has been deprecated. A new separator syntax has been added for map definitions. Please use `::` instead of `:` from now on. 
- Logic has been added to filter out lines of the map file with incorrect syntax. While this shouldn't interfere with backwards compatibility, not all possible combinations of characters have been tested. Check the logs of the ImageSwap pods if you experience issues and open an issue if necessary.

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

phenixblue commented 3 years ago

Docs updated