@@ -306,3 +306,49 @@ func TestExecOnce(t *testing.T) {
306306
307307 // TODO: mock tcp hijack
308308}
309+
310+ func TestGetRegistryImageUrl (t * testing.T ) {
311+ t .Run ("docker.io keeps provided namespace (library)" , func (t * testing.T ) {
312+ viper .Set ("INTERNAL_IMAGE_REGISTRY" , "docker.io" )
313+
314+ got := GetRegistryImageUrl ("library/kong:2.8.1" )
315+ assert .Equal (t , "docker.io/library/kong:2.8.1" , got )
316+ })
317+
318+ t .Run ("non-docker.io defaults namespace to supabase when no override" , func (t * testing.T ) {
319+ viper .Set ("INTERNAL_IMAGE_REGISTRY" , "ghcr.io" )
320+
321+ got := GetRegistryImageUrl ("library/kong:2.8.1" )
322+ assert .Equal (t , "ghcr.io/supabase/kong:2.8.1" , got )
323+ })
324+
325+ t .Run ("supabase namespace remains supabase on non-docker.io registry" , func (t * testing.T ) {
326+ viper .Set ("INTERNAL_IMAGE_REGISTRY" , "ghcr.io" )
327+
328+ got := GetRegistryImageUrl ("supabase/postgres:17.6.1.074" )
329+ assert .Equal (t , "ghcr.io/supabase/postgres:17.6.1.074" , got )
330+ })
331+
332+ t .Run ("namespace override gets applied" , func (t * testing.T ) {
333+ viper .Set ("INTERNAL_IMAGE_REGISTRY" , "ghcr.io" )
334+ viper .Set ("INTERNAL_IMAGE_NAMESPACE_POSTGREST" , "custom" )
335+
336+ got := GetRegistryImageUrl ("postgrest/postgrest:v14.3" )
337+ assert .Equal (t , "ghcr.io/custom/postgrest:v14.3" , got )
338+ })
339+
340+ t .Run ("invalid image format returns as-is" , func (t * testing.T ) {
341+ viper .Set ("INTERNAL_IMAGE_REGISTRY" , "docker.io" )
342+
343+ got := GetRegistryImageUrl ("postgrest" )
344+ assert .Equal (t , "postgrest" , got )
345+ })
346+
347+ t .Run ("overrides kong namespace to docker/library on public.ecr.aws" , func (t * testing.T ) {
348+ viper .Set ("INTERNAL_IMAGE_REGISTRY" , "public.ecr.aws" )
349+ viper .Set ("INTERNAL_IMAGE_NAMESPACE_KONG" , "docker/library" )
350+
351+ got := GetRegistryImageUrl ("library/kong:2.8.1" )
352+ assert .Equal (t , "public.ecr.aws/docker/library/kong:2.8.1" , got )
353+ })
354+ }
0 commit comments