phenixblue / imageswap-webhook

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

"library image" support for "docker.io" "index.docker.io" #77

Closed xujinheng closed 1 year ago

xujinheng commented 2 years ago

What would you like to be added:

This is how imageswap determine whether a image is a library image now:

if image_split[1] == "" and image_split[2] == "":

It can deal with cases like "nginx", but can not detect "docker.io/nginx" and "index.docker.io/nginx" as library images. Because:

>>> "nginx".partition("/")
('nginx', '', '')
>>> "docker.io/nginx".partition("/")
('docker.io', '/', 'nginx')
>>> "index.docker.io/nginx".partition("/")
('index.docker.io', '/', 'nginx')

Why is this needed: To cover more cases when input images are from first level repositories

justusbunsi commented 1 year ago

This is already possible with the correct replacement mappings.

docker.io/library::<your registry>
index.docker.io/library::<your registry>

Tested with 1.5.2.