Skip to content

Commit

Permalink
Better error message if Compose version is 'dev'. (#826)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein authored Mar 29, 2024
1 parent 8f3f310 commit 7102d38
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/826-docker-compose-v2-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "docker_compose_v2* modules - abort with a nice error message instead of crash when the Docker Compose CLI plugin version is ``dev`` (https://github.com/ansible-collections/community.docker/issues/825, https://github.com/ansible-collections/community.docker/pull/826)."
6 changes: 6 additions & 0 deletions plugins/module_utils/compose_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,12 @@ def __init__(self, client, min_version=MINIMUM_COMPOSE_VERSION):
compose = self.client.get_client_plugin_info('compose')
if compose is None:
self.client.fail('Docker CLI {0} does not have the compose plugin installed'.format(self.client.get_cli()))
if compose['Version'] == 'dev':
self.client.fail(
'Docker CLI {0} has a compose plugin installed, but it reports version "dev".'
' Please use a version of the plugin that returns a proper version.'
.format(self.client.get_cli())
)
compose_version = compose['Version'].lstrip('v')
self.compose_version = LooseVersion(compose_version)
if self.compose_version < LooseVersion(min_version):
Expand Down

0 comments on commit 7102d38

Please sign in to comment.