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

Supported pushing Docker image to a Docker registry #89

Merged
merged 10 commits into from
Dec 6, 2023

Conversation

ckunki
Copy link
Contributor

@ckunki ckunki commented Dec 4, 2023

Closes #36

exasol/ds/sandbox/cli/commands/create_docker_image.py Outdated Show resolved Hide resolved
exasol/ds/sandbox/lib/dss_docker/push_image.py Outdated Show resolved Hide resolved
test/integration/conftest.py Show resolved Hide resolved
test/integration/test_push_docker_image.py Outdated Show resolved Hide resolved
@ckunki ckunki requested a review from tkilias December 5, 2023 07:35
_logger.setLevel(logging.DEBUG)


class LocalDockerRegistry(DockerRegistry):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compared to ITDE I did not need a LocalDockerRegistryContextManager as the pytest fixture already provides context-like functionality.

The reason for the earlier construct returning a context was the parameter repository to the registry which now has become obsolete and has been removed.

Copy link
Collaborator

@tkilias tkilias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You only test the DockerRegistry, but not that is called properly

test/integration/test_push_docker_image.py Outdated Show resolved Hide resolved
test/integration/test_push_docker_image.py Outdated Show resolved Hide resolved
Added test to verify DssDockerImage calls registry.push()
@ckunki
Copy link
Contributor Author

ckunki commented Dec 6, 2023

You only test the DockerRegistry, but not that is called properly

I added tests with MagicMock in test/unit/test_dss_docker_image.py.

registry: LocalDockerRegistry,
tag: str = None,
):
def tagged_image(old: DockerImageSpec, new: DockerImageSpec):
"""
Prepend host and port of LocalDockerRegistry to the repository name of the
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this description is outdated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch - you're right. Will be fixed in next push.



@pytest.fixture(scope="session")
def docker_registry(request):
def docker_registry(request, registry_image):
"""
Provide a context for creating a LocalDockerRegistry accepting
parameter ``repository``.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this description seems to be also a little bit outdated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, correct, thanks!
See next push.

with tagged_image(dss_docker_image, docker_registry) as tagged:
tagged._push()
def test_push_tag(sample_docker_image, docker_registry):
old = DockerImageSpec("registry", "2")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, you don't need this, because you are getting samle_docker_image as input

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, see next push for a simplified version.

Comment on lines 117 to 118
registry = DockerRegistry("user", "password")
registry.push = MagicMock()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use registry = create_autospec(DockerRegistry), don't use workarounds everywhere only because you used it once.

Copy link
Contributor Author

@ckunki ckunki Dec 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good. Thanks. See next push.

tkilias
tkilias previously approved these changes Dec 6, 2023
@ckunki ckunki merged commit 8fca4e2 into main Dec 6, 2023
3 checks passed
@ckunki ckunki deleted the feature/#36_Push_Docker_Image branch December 6, 2023 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DSS Push Docker Image to a Docker Registry
3 participants