docker-stack 2.2.2__tar.gz → 2.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {docker_stack-2.2.2 → docker_stack-2.2.3}/PKG-INFO +1 -1
- {docker_stack-2.2.2 → docker_stack-2.2.3}/docker_stack/cli.py +20 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/docker_stack.egg-info/PKG-INFO +1 -1
- {docker_stack-2.2.2 → docker_stack-2.2.3}/setup.py +1 -1
- {docker_stack-2.2.2 → docker_stack-2.2.3}/tests/test_docker_stack.py +51 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/README.md +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/docker_stack/__init__.py +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/docker_stack/command_runner.py +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/docker_stack/compose.py +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/docker_stack/docker_objects.py +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/docker_stack/envsubst.py +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/docker_stack/envsubst_merge.py +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/docker_stack/helpers.py +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/docker_stack/login.py +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/docker_stack/manager_api.py +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/docker_stack/markers.py +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/docker_stack/merge_conf.py +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/docker_stack/registry.py +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/docker_stack/shell_auth.py +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/docker_stack/url_parser.py +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/docker_stack.egg-info/SOURCES.txt +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/docker_stack.egg-info/dependency_links.txt +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/docker_stack.egg-info/entry_points.txt +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/docker_stack.egg-info/requires.txt +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/docker_stack.egg-info/top_level.txt +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/pyproject.toml +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/setup.cfg +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/tests/test_docker_objects.py +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/tests/test_load_env.py +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/tests/test_login.py +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/tests/test_manager_api.py +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/tests/test_node_ls.py +0 -0
- {docker_stack-2.2.2 → docker_stack-2.2.3}/tests/test_shell_auth.py +0 -0
|
@@ -266,15 +266,35 @@ def _format_names(names: object, *, no_trunc: bool) -> str:
|
|
|
266
266
|
return ",".join(values)
|
|
267
267
|
|
|
268
268
|
|
|
269
|
+
DOCKER_HUB_NAME_PREFIXES = (
|
|
270
|
+
"docker.io/library/",
|
|
271
|
+
"index.docker.io/library/",
|
|
272
|
+
"docker.io/",
|
|
273
|
+
"index.docker.io/",
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
def _familiar_image_name(value: str) -> str:
|
|
278
|
+
for prefix in DOCKER_HUB_NAME_PREFIXES:
|
|
279
|
+
if value.startswith(prefix):
|
|
280
|
+
return value[len(prefix) :]
|
|
281
|
+
return value
|
|
282
|
+
|
|
283
|
+
|
|
269
284
|
def _format_image(image: object, image_id: object, *, no_trunc: bool) -> str:
|
|
270
285
|
value = str(image or "")
|
|
271
286
|
if not value:
|
|
272
287
|
return "<no image>"
|
|
273
288
|
if no_trunc:
|
|
274
289
|
return value
|
|
290
|
+
if value.startswith("sha256:"):
|
|
291
|
+
return _short_id(value)
|
|
275
292
|
identifier = str(image_id or "")
|
|
276
293
|
if identifier and _short_id(identifier) == _short_id(value):
|
|
277
294
|
return _short_id(value)
|
|
295
|
+
if "@" in value:
|
|
296
|
+
# docker ps keeps `name[:tag]` and drops the pinned digest unless --no-trunc.
|
|
297
|
+
return _familiar_image_name(value.split("@", 1)[0])
|
|
278
298
|
return value
|
|
279
299
|
|
|
280
300
|
|
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name="docker-stack",
|
|
5
|
-
version="2.2.
|
|
5
|
+
version="2.2.3",
|
|
6
6
|
description="CLI for deploying and managing Docker stacks.",
|
|
7
7
|
long_description=open("README.md").read(), # You can include a README file to describe your package
|
|
8
8
|
long_description_content_type="text/markdown",
|
|
@@ -131,6 +131,57 @@ def test_managed_docker_ps_matches_docker_columns(monkeypatch, capsys):
|
|
|
131
131
|
assert row == row.rstrip()
|
|
132
132
|
|
|
133
133
|
|
|
134
|
+
@pytest.mark.parametrize(
|
|
135
|
+
"image,expected,expected_no_trunc",
|
|
136
|
+
[
|
|
137
|
+
(
|
|
138
|
+
"registry.example.com/app/design-system:af037b33@sha256:15d623cfa2f856c8101f9f3c47003d412f9b2bf72c69c95d5dff07a74e5f7b60",
|
|
139
|
+
"registry.example.com/app/design-system:af037b33",
|
|
140
|
+
"registry.example.com/app/design-system:af037b33@sha256:15d623cfa2f856c8101f9f3c47003d412f9b2bf72c69c95d5dff07a74e5f7b60",
|
|
141
|
+
),
|
|
142
|
+
(
|
|
143
|
+
"docker.io/library/alpine@sha256:28bd5fe8b56d1bd048e5babf5b10710ebe0bae67db86916198a6eec434943f8b",
|
|
144
|
+
"alpine",
|
|
145
|
+
"docker.io/library/alpine@sha256:28bd5fe8b56d1bd048e5babf5b10710ebe0bae67db86916198a6eec434943f8b",
|
|
146
|
+
),
|
|
147
|
+
("nginx:1.27", "nginx:1.27", "nginx:1.27"),
|
|
148
|
+
(
|
|
149
|
+
"sha256:0e901e68141fd02f237cf63eb842529f8a9500636a9419e3cf4fb986b8fe3d5d",
|
|
150
|
+
"0e901e68141f",
|
|
151
|
+
"sha256:0e901e68141fd02f237cf63eb842529f8a9500636a9419e3cf4fb986b8fe3d5d",
|
|
152
|
+
),
|
|
153
|
+
],
|
|
154
|
+
)
|
|
155
|
+
def test_managed_docker_ps_drops_pinned_digest_like_docker(monkeypatch, capsys, image, expected, expected_no_trunc):
|
|
156
|
+
client = SimpleNamespace(
|
|
157
|
+
supports=lambda feature: feature == "cluster_container_cli_v1",
|
|
158
|
+
list_containers=lambda **_kwargs: {
|
|
159
|
+
"containers": [
|
|
160
|
+
{
|
|
161
|
+
"node_name": "worker-02",
|
|
162
|
+
"docker": {
|
|
163
|
+
"Id": "abcdef1234567890",
|
|
164
|
+
"Image": image,
|
|
165
|
+
"Command": "sleep",
|
|
166
|
+
"Created": int(time.time()) - 60,
|
|
167
|
+
"Status": "Up 1 minute",
|
|
168
|
+
"Ports": [],
|
|
169
|
+
"Names": ["/svc.1.abc"],
|
|
170
|
+
},
|
|
171
|
+
}
|
|
172
|
+
],
|
|
173
|
+
"node_errors": [],
|
|
174
|
+
},
|
|
175
|
+
)
|
|
176
|
+
monkeypatch.setattr("docker_stack.cli.discover_manager_client", lambda: client)
|
|
177
|
+
|
|
178
|
+
assert _managed_docker(["ps"]) == 0
|
|
179
|
+
assert capsys.readouterr().out.splitlines()[1].split()[1] == expected
|
|
180
|
+
|
|
181
|
+
assert _managed_docker(["ps", "--no-trunc"]) == 0
|
|
182
|
+
assert capsys.readouterr().out.splitlines()[1].split()[1] == expected_no_trunc
|
|
183
|
+
|
|
184
|
+
|
|
134
185
|
def test_managed_docker_ps_forwards_global_latest_and_limit(monkeypatch):
|
|
135
186
|
calls = []
|
|
136
187
|
client = SimpleNamespace(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|