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

[Bug]: ImageSubstitutor not applied to ryuk image #1893

Closed
aloifolia opened this issue Nov 3, 2023 · 4 comments · Fixed by #1928
Closed

[Bug]: ImageSubstitutor not applied to ryuk image #1893

aloifolia opened this issue Nov 3, 2023 · 4 comments · Fixed by #1928
Labels
bug An issue with the library

Comments

@aloifolia
Copy link

Testcontainers version

v0.26.0

Using the latest Testcontainers version?

Yes

Host OS

Linux

Host arch

x86

Go version

1.21

Docker version

24.0.7 (dind + client)

Docker info

24.0.7

What happened?

When I use image name substitution, the substitutor will not be applied to the ryuk image. Hence, I see logs like

Waiting for container id 4887f0360761 image: docker.io/testcontainers/ryuk:0.5.1.

Now, this looks like a bug. In an environment that requires you to use a private registry, you need to be able to adapt ryuk, as well. Or am I missing something?

My test code looks like this:

type MyImageSubstitutor struct{}

func (s MyImageSubstitutor) Description() string {
	return "MyImageSubstitutor: prepending my.private.registry.com/"
}

func (s MyImageSubstitutor) Substitute(image string) (string, error) {
        # these lines will never appear for the ryuk image, just for user-defined images
	fmt.Println("############################")
	fmt.Println(image)

	prefix := "my.private.registry.com/"
	if !strings.Contains(image, prefix) {
		return prefix + image, nil
	}

	return image, nil
}

testcontainers.ContainerRequest{
        Image: "hashicorp/consul:latest," # this will be replaced, as expected
        ...
        ImageSubstitutors: []testcontainers.ImageSubstitutor{MyImageSubstitutor{}},
}

Relevant log output

No response

Additional information

No response

@aloifolia aloifolia added the bug An issue with the library label Nov 3, 2023
@aloifolia aloifolia changed the title [Bug]: [Bug]: ImageSubstitutor not applied to ryuk image Nov 3, 2023
@mdelapenya
Copy link
Collaborator

Hey @aloifolia at the moment the image substitutor is not applied to the reaper.

I think we can implement as a feature request instead of a bug, probably supporting it at the properties level. Please see my follow-up comment in #1719:

We can support setting custom substitutions in the testcontainers.properties file. Please see https://java.testcontainers.org/features/image_name_substitution/#automatically-modifying-docker-hub-image-names to check requirements.

@mdelapenya
Copy link
Collaborator

Hey @aloifolia would it be enough if you could define the Ryuk image at the properties level, like in Java https://java.testcontainers.org/features/configuration/#customizing-images?

I have a working branch to implement that.

@aloifolia
Copy link
Author

The documentation mentions that the configuration via properties is deprecated.

For this reason, I use the environment variable TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX which does the job equally well for me.

@mdelapenya
Copy link
Collaborator

Cool, thanks for your input. I'm currently providing support for TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX in a consistent manner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue with the library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants