-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
_logger.setLevel(logging.DEBUG) | ||
|
||
|
||
class LocalDockerRegistry(DockerRegistry): |
There was a problem hiding this comment.
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.
There was a problem hiding this 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
Added test to verify DssDockerImage calls registry.push()
I added tests with |
registry: LocalDockerRegistry, | ||
tag: str = None, | ||
): | ||
def tagged_image(old: DockerImageSpec, new: DockerImageSpec): | ||
""" | ||
Prepend host and port of LocalDockerRegistry to the repository name of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this description is outdated
There was a problem hiding this comment.
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``. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
test/unit/test_dss_docker_image.py
Outdated
registry = DockerRegistry("user", "password") | ||
registry.push = MagicMock() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Closes #36