mirror of
https://github.com/docker/cli.git
synced 2026-11-13 16:23:41 -04:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7fc2dff9bc | ||
|
|
ca5a266c81 | ||
|
|
39f182cbaa | ||
|
|
0684ae0cc1 | ||
|
|
b7dc94c65f | ||
|
|
12566dd80d | ||
|
|
4167943209 | ||
|
|
9dcf8afb5d | ||
|
|
6fdced88c5 | ||
|
|
0a563b177a | ||
|
|
4a63305d74 | ||
|
|
87ff477cb6 | ||
|
|
101ffc09eb | ||
|
|
32ff1e7281 | ||
|
|
d146e672a6 | ||
|
|
ac976d9edb | ||
|
|
48baf6c322 | ||
|
|
47a06aa077 | ||
|
|
1bf3eb68ce | ||
|
|
60dffc9412 | ||
|
|
b0a6803f9b | ||
|
|
f90c2894a8 | ||
|
|
ed4de7d484 | ||
|
|
74b7f5cf27 | ||
|
|
824b68911b | ||
|
|
dbad17f16f | ||
|
|
eb8fab8023 | ||
|
|
7b322e4dc2 | ||
|
|
676ca0067b | ||
|
|
ab989d8316 | ||
|
|
d306b9d600 | ||
|
|
0ffb4c4e0b | ||
|
|
e914d34ac3 | ||
|
|
a6538bea40 | ||
|
|
88096ef005 | ||
|
|
c50ce17c19 | ||
|
|
441acb383d | ||
|
|
cec24c7b9a | ||
|
|
ed68c49095 | ||
|
|
d5ea3bdc8a | ||
|
|
7cf09ba485 | ||
|
|
6239084af1 | ||
|
|
45a3e0bc2a | ||
|
|
79dd1f4ad0 | ||
|
|
32bfe54148 | ||
|
|
d7036970e8 | ||
|
|
ade907089f | ||
|
|
e92e07589b | ||
|
|
09d30a34bf | ||
|
|
51780c0691 | ||
|
|
fee40c1660 | ||
|
|
91fc8ad4a2 | ||
|
|
cb6c7bc03f | ||
|
|
b1b8a602f6 | ||
|
|
36e01adcfa | ||
|
|
e54eb133cb | ||
|
|
f01f978aca | ||
|
|
d078f15f2b | ||
|
|
13e32611b5 | ||
|
|
7c883814b8 | ||
|
|
b07de47694 | ||
|
|
9878ff214b | ||
|
|
c24195d63f | ||
|
|
d7ad1d7268 | ||
|
|
e6ee8bee34 | ||
|
|
c096bd1261 | ||
|
|
3014a55736 | ||
|
|
3cb9f1cb86 | ||
|
|
fd25e9699e | ||
|
|
e480e6c6fc | ||
|
|
977d999382 | ||
|
|
64484430f4 | ||
|
|
7631c67208 | ||
|
|
b1780e06a0 | ||
|
|
6ea81b3e2e | ||
|
|
33d586d81f | ||
|
|
ed406be52e | ||
|
|
be607d1163 | ||
|
|
f838c7c84b | ||
|
|
bcc4be9f8b | ||
|
|
f0f38d5cb9 | ||
|
|
b4189c2f7f | ||
|
|
4a9a0ab3aa | ||
|
|
7b7eb0ef6b | ||
|
|
a458c3871c | ||
|
|
dc67811426 | ||
|
|
1164af3e60 | ||
|
|
cffd24dea4 | ||
|
|
5a7e00d7c2 | ||
|
|
63da0b015b | ||
|
|
cef1e66947 | ||
|
|
52611d0d6a | ||
|
|
6292b73b99 | ||
|
|
84d70fbdc3 | ||
|
|
4239f5d121 | ||
|
|
be9ca38f8b | ||
|
|
8eb66b47e3 | ||
|
|
76b505b054 | ||
|
|
65b90d8888 | ||
|
|
0f0e561a3f | ||
|
|
573a46e506 | ||
|
|
433ab01649 | ||
|
|
175b4e0a98 | ||
|
|
5e0fdb3f6e | ||
|
|
00de141abf | ||
|
|
1f46660e37 | ||
|
|
ff3273f3e4 | ||
|
|
6fccf35355 | ||
|
|
511f136927 | ||
|
|
b17df8fea3 | ||
|
|
dc47c19e55 | ||
|
|
3cd22ff935 | ||
|
|
45f589590b | ||
|
|
6b8da05715 | ||
|
|
65ad909cde | ||
|
|
52eb28a512 | ||
|
|
bb63125969 | ||
|
|
2a24c3c77d | ||
|
|
3f096b4ffd | ||
|
|
ebc3d5aeab | ||
|
|
6261c55c56 | ||
|
|
2c36f84eaf | ||
|
|
4f7a1841ba | ||
|
|
ef48c25aed | ||
|
|
f2514827f4 | ||
|
|
f8d6265672 | ||
|
|
744eee4bd4 | ||
|
|
d6041d1abc | ||
|
|
06275f9094 | ||
|
|
bf6f62cc7c | ||
|
|
376f03c858 | ||
|
|
de4a008614 | ||
|
|
f3f7da9f3d | ||
|
|
eed270f656 | ||
|
|
d072fe407f | ||
|
|
3fe73079aa | ||
|
|
a79a16bd63 | ||
|
|
28f756087e | ||
|
|
387b8e2af8 | ||
|
|
f7e66aa1ff | ||
|
|
55e4a7eef5 | ||
|
|
58d9cdd2d9 | ||
|
|
4f169946e7 | ||
|
|
3c53edb6c5 | ||
|
|
1612f4c767 | ||
|
|
cf53a284da | ||
|
|
0da5f45651 | ||
|
|
ce15202968 | ||
|
|
8659aa5d4c | ||
|
|
8d08c75e81 | ||
|
|
24af004cbf | ||
|
|
eb68ed19d2 | ||
|
|
8a375034e2 | ||
|
|
f755f48a12 | ||
|
|
a7c0741fa7 | ||
|
|
12892075d2 | ||
|
|
e1f9b284df | ||
|
|
951f7653fc | ||
|
|
4f84911bfe | ||
|
|
228f29e810 | ||
|
|
d8c3543407 | ||
|
|
2dd7b7e15b | ||
|
|
244404379d |
@@ -1,34 +1,37 @@
|
|||||||
<!--
|
<!--
|
||||||
Make sure you've read and understood our contributing guidelines;
|
Please make sure you've read and understood our contributing guidelines;
|
||||||
https://github.com/docker/cli/blob/master/CONTRIBUTING.md
|
https://github.com/docker/cli/blob/master/CONTRIBUTING.md
|
||||||
|
|
||||||
** Make sure all your commits include a signature generated with `git commit -s` **
|
Make sure commits are signed off (`git commit -s`) with your real name.
|
||||||
|
|
||||||
If this is a bug fix, make sure your description includes "fixes #xxxx", or
|
If the PR relates to an existing issue or PR, mention it at the top:
|
||||||
"closes #xxxx"
|
|
||||||
|
|
||||||
Provide the following information:
|
- Fixes: https://github.com/docker/cli/issues/12345678
|
||||||
|
- Replaces: https://github.com/docker/cli/pull/12345678
|
||||||
|
- Follow up to: https://github.com/docker/cli/pull/12345678
|
||||||
|
- Related to: https://github.com/docker/cli/issues/12345678
|
||||||
-->
|
-->
|
||||||
|
|
||||||
**- What I did**
|
## Summary
|
||||||
|
|
||||||
**- How I did it**
|
## Release notes (optional)
|
||||||
|
|
||||||
**- How to verify it**
|
|
||||||
|
|
||||||
**- Human readable description for the release notes**
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Write a short (one line) summary that describes the changes in this
|
One-sentence user-facing release note.
|
||||||
pull request for inclusion in the changelog.
|
Leave empty if the change is not changelog-worthy.
|
||||||
It must be placed inside the below triple backticks section.
|
Use present tense and imperative tone.
|
||||||
|
|
||||||
NOTE: Only fill this section if changes introduced in this PR are user-facing.
|
Good:
|
||||||
The PR must have a relevant impact/ label.
|
- Fix a panic when running `docker top` on a non-running Windows container.
|
||||||
|
- Don't print warnings in `docker info` for broken symlinks in CLI plugin directories.
|
||||||
|
|
||||||
|
Bad:
|
||||||
|
- Refactor test TestFooWithBar
|
||||||
|
- Fixed a panic when running docker top
|
||||||
-->
|
-->
|
||||||
|
|
||||||
```markdown changelog
|
```markdown changelog
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**- A picture of a cute animal (not mandatory but encouraged)**
|
## A picture of a cute animal (not mandatory but encouraged)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
prepare:
|
prepare:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-26.04
|
||||||
outputs:
|
outputs:
|
||||||
matrix: ${{ steps.platforms.outputs.matrix }}
|
matrix: ${{ steps.platforms.outputs.matrix }}
|
||||||
steps:
|
steps:
|
||||||
@@ -49,7 +49,7 @@ jobs:
|
|||||||
echo ${{ steps.platforms.outputs.matrix }}
|
echo ${{ steps.platforms.outputs.matrix }}
|
||||||
|
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-26.04
|
||||||
needs:
|
needs:
|
||||||
- prepare
|
- prepare
|
||||||
strategy:
|
strategy:
|
||||||
@@ -65,10 +65,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
|
uses: docker/setup-buildx-action@594f3bf4285d9ea8dc53c9a0c9c4092420091003 # v4.4.0
|
||||||
-
|
-
|
||||||
name: Build
|
name: Build
|
||||||
uses: docker/bake-action@d3418bd7d0e9324001bca92fa8ba175ea7e6dc9b # v7.3.0
|
uses: docker/bake-action@018cb6412ab401ebaa809aa5f85966b74628600f # v7.4.0
|
||||||
with:
|
with:
|
||||||
targets: ${{ matrix.target }}
|
targets: ${{ matrix.target }}
|
||||||
set: |
|
set: |
|
||||||
@@ -99,7 +99,7 @@ jobs:
|
|||||||
|
|
||||||
bin-image:
|
bin-image:
|
||||||
if: ${{ github.event_name != 'pull_request' && github.repository == 'docker/cli' }}
|
if: ${{ github.event_name != 'pull_request' && github.repository == 'docker/cli' }}
|
||||||
uses: docker/github-builder/.github/workflows/bake.yml@27ade872c1e2296e62ef15ab3b10d37665e57cf7 # v1.15.0
|
uses: docker/github-builder/.github/workflows/bake.yml@58cb9f5b71b1836d6f690c1e95effdeb9b98cb8a # v1.17.0
|
||||||
permissions:
|
permissions:
|
||||||
contents: read # same as global permission
|
contents: read # same as global permission
|
||||||
id-token: write # for signing attestation(s) and authenticating to Docker Hub with GitHub OIDC Token
|
id-token: write # for signing attestation(s) and authenticating to Docker Hub with GitHub OIDC Token
|
||||||
@@ -126,7 +126,7 @@ jobs:
|
|||||||
connection_id: ${{ vars.DOCKERHUB_OIDC_CONNECTIONID }}
|
connection_id: ${{ vars.DOCKERHUB_OIDC_CONNECTIONID }}
|
||||||
|
|
||||||
prepare-plugins:
|
prepare-plugins:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-26.04
|
||||||
outputs:
|
outputs:
|
||||||
matrix: ${{ steps.platforms.outputs.matrix }}
|
matrix: ${{ steps.platforms.outputs.matrix }}
|
||||||
steps:
|
steps:
|
||||||
@@ -146,7 +146,7 @@ jobs:
|
|||||||
echo ${{ steps.platforms.outputs.matrix }}
|
echo ${{ steps.platforms.outputs.matrix }}
|
||||||
|
|
||||||
plugins:
|
plugins:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-26.04
|
||||||
needs:
|
needs:
|
||||||
- prepare-plugins
|
- prepare-plugins
|
||||||
strategy:
|
strategy:
|
||||||
@@ -156,10 +156,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
|
uses: docker/setup-buildx-action@594f3bf4285d9ea8dc53c9a0c9c4092420091003 # v4.4.0
|
||||||
-
|
-
|
||||||
name: Build
|
name: Build
|
||||||
uses: docker/bake-action@d3418bd7d0e9324001bca92fa8ba175ea7e6dc9b # v7.3.0
|
uses: docker/bake-action@018cb6412ab401ebaa809aa5f85966b74628600f # v7.4.0
|
||||||
with:
|
with:
|
||||||
targets: plugins-cross
|
targets: plugins-cross
|
||||||
set: |
|
set: |
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
codeql:
|
codeql:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-26.04
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
env:
|
env:
|
||||||
DISABLE_WARN_OUTSIDE_CONTAINER: '1'
|
DISABLE_WARN_OUTSIDE_CONTAINER: '1'
|
||||||
@@ -64,18 +64,18 @@ jobs:
|
|||||||
name: Update Go
|
name: Update Go
|
||||||
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
|
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
|
||||||
with:
|
with:
|
||||||
go-version: "1.26.5"
|
go-version: "1.26.8"
|
||||||
cache: false
|
cache: false
|
||||||
-
|
-
|
||||||
name: Initialize CodeQL
|
name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3
|
uses: github/codeql-action/init@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4.38.0
|
||||||
with:
|
with:
|
||||||
languages: go
|
languages: go
|
||||||
-
|
-
|
||||||
name: Autobuild
|
name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3
|
uses: github/codeql-action/autobuild@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4.38.0
|
||||||
-
|
-
|
||||||
name: Perform CodeQL Analysis
|
name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3
|
uses: github/codeql-action/analyze@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4.38.0
|
||||||
with:
|
with:
|
||||||
category: "/language:go"
|
category: "/language:go"
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
tests:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-26.04
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -51,7 +51,7 @@ jobs:
|
|||||||
name: Update daemon.json
|
name: Update daemon.json
|
||||||
run: |
|
run: |
|
||||||
if [ ! -f /etc/docker/daemon.json ]; then
|
if [ ! -f /etc/docker/daemon.json ]; then
|
||||||
# ubuntu 24.04 runners no longer have a default daemon.json present
|
# ubuntu runners no longer have a default daemon.json present
|
||||||
sudo mkdir -p /etc/docker/
|
sudo mkdir -p /etc/docker/
|
||||||
echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json
|
echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json
|
||||||
else
|
else
|
||||||
@@ -65,7 +65,7 @@ jobs:
|
|||||||
docker info
|
docker info
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
|
uses: docker/setup-buildx-action@594f3bf4285d9ea8dc53c9a0c9c4092420091003 # v4.4.0
|
||||||
-
|
-
|
||||||
name: Run ${{ matrix.target }}
|
name: Run ${{ matrix.target }}
|
||||||
run: |
|
run: |
|
||||||
@@ -76,7 +76,7 @@ jobs:
|
|||||||
TESTFLAGS: -coverprofile=/tmp/coverage/coverage.txt
|
TESTFLAGS: -coverprofile=/tmp/coverage/coverage.txt
|
||||||
-
|
-
|
||||||
name: Send to Codecov
|
name: Send to Codecov
|
||||||
uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6.0.1
|
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
|
||||||
with:
|
with:
|
||||||
files: ./build/coverage/coverage.txt
|
files: ./build/coverage/coverage.txt
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ permissions:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
review:
|
review:
|
||||||
uses: docker/docker-agent-action/.github/workflows/review-pr.yml@baf90543d81f5de59751dfd10e6cf45e21a5a982 # v2.0.3
|
uses: docker/docker-agent-action/.github/workflows/review-pr.yml@3654ec391b070e247de2e2e3c1ff2519b6378b3a # v2.0.9
|
||||||
permissions:
|
permissions:
|
||||||
contents: read # Read repository files and PR diffs
|
contents: read # Read repository files and PR diffs
|
||||||
pull-requests: write # Post review comments
|
pull-requests: write # Post review comments
|
||||||
issues: write # Create security incident issues if secrets detected
|
issues: write # Create security incident issues if secrets detected
|
||||||
checks: write # (Optional) Show review progress as a check run
|
checks: write # (Optional) Show review progress as a check run
|
||||||
id-token: write # Required for OIDC authentication to AWS Secrets Manager
|
id-token: write # Required for OIDC authentication to AWS Secrets Manager
|
||||||
actions: read # Download artifacts from trigger workflow
|
actions: write # Required since v2.0.3 — review-lock cache cleanup and feedback artifacts
|
||||||
with:
|
with:
|
||||||
trigger-run-id: ${{ github.event_name == 'workflow_run' && format('{0}', github.event.workflow_run.id) || '' }}
|
trigger-run-id: ${{ github.event_name == 'workflow_run' && format('{0}', github.event.workflow_run.id) || '' }}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
sync-release-branch:
|
sync-release-branch:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-26.04
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
actions: write
|
actions: write
|
||||||
@@ -116,7 +116,7 @@ jobs:
|
|||||||
push-release-branch:
|
push-release-branch:
|
||||||
needs: sync-release-branch
|
needs: sync-release-branch
|
||||||
if: ${{ !inputs.dry_run && needs.sync-release-branch.outputs.has_changes == 'true' }}
|
if: ${{ !inputs.dry_run && needs.sync-release-branch.outputs.has_changes == 'true' }}
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-26.04
|
||||||
environment: docker-releases
|
environment: docker-releases
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|||||||
@@ -26,19 +26,19 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ctn:
|
ctn:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-26.04
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
|
uses: docker/setup-buildx-action@594f3bf4285d9ea8dc53c9a0c9c4092420091003 # v4.4.0
|
||||||
-
|
-
|
||||||
name: Test
|
name: Test
|
||||||
uses: docker/bake-action@d3418bd7d0e9324001bca92fa8ba175ea7e6dc9b # v7.3.0
|
uses: docker/bake-action@018cb6412ab401ebaa809aa5f85966b74628600f # v7.4.0
|
||||||
with:
|
with:
|
||||||
targets: test-coverage
|
targets: test-coverage
|
||||||
-
|
-
|
||||||
name: Send to Codecov
|
name: Send to Codecov
|
||||||
uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6.0.1
|
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
|
||||||
with:
|
with:
|
||||||
files: ./build/coverage/coverage.txt
|
files: ./build/coverage/coverage.txt
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
@@ -68,7 +68,7 @@ jobs:
|
|||||||
name: Set up Go
|
name: Set up Go
|
||||||
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
|
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
|
||||||
with:
|
with:
|
||||||
go-version: "1.26.5"
|
go-version: "1.26.8"
|
||||||
cache: false
|
cache: false
|
||||||
-
|
-
|
||||||
name: Test
|
name: Test
|
||||||
@@ -82,7 +82,7 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
-
|
-
|
||||||
name: Send to Codecov
|
name: Send to Codecov
|
||||||
uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6.0.1
|
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
|
||||||
with:
|
with:
|
||||||
files: /tmp/coverage.txt
|
files: /tmp/coverage.txt
|
||||||
working-directory: ${{ env.GOPATH }}/src/github.com/docker/cli
|
working-directory: ${{ env.GOPATH }}/src/github.com/docker/cli
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
validate-milestone:
|
validate-milestone:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-26.04
|
||||||
timeout-minutes: 5
|
timeout-minutes: 5
|
||||||
steps:
|
steps:
|
||||||
- name: Validate milestone matches VERSION
|
- name: Validate milestone matches VERSION
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check-labels:
|
check-labels:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-26.04
|
||||||
timeout-minutes: 120 # guardrails timeout for the whole job
|
timeout-minutes: 120 # guardrails timeout for the whole job
|
||||||
steps:
|
steps:
|
||||||
- name: Missing `area/` label
|
- name: Missing `area/` label
|
||||||
@@ -32,7 +32,7 @@ jobs:
|
|||||||
run: exit 0
|
run: exit 0
|
||||||
|
|
||||||
check-changelog:
|
check-changelog:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-26.04
|
||||||
timeout-minutes: 120 # guardrails timeout for the whole job
|
timeout-minutes: 120 # guardrails timeout for the whole job
|
||||||
env:
|
env:
|
||||||
HAS_IMPACT_LABEL: ${{ contains(join(github.event.pull_request.labels.*.name, ','), 'impact/') }}
|
HAS_IMPACT_LABEL: ${{ contains(join(github.event.pull_request.labels.*.name, ','), 'impact/') }}
|
||||||
@@ -70,7 +70,7 @@ jobs:
|
|||||||
echo "$desc"
|
echo "$desc"
|
||||||
|
|
||||||
check-pr-branch:
|
check-pr-branch:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-26.04
|
||||||
timeout-minutes: 120 # guardrails timeout for the whole job
|
timeout-minutes: 120 # guardrails timeout for the whole job
|
||||||
env:
|
env:
|
||||||
PR_TITLE: ${{ github.event.pull_request.title }}
|
PR_TITLE: ${{ github.event.pull_request.title }}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
validate:
|
validate:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-26.04
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -38,13 +38,13 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Run
|
name: Run
|
||||||
uses: docker/bake-action@d3418bd7d0e9324001bca92fa8ba175ea7e6dc9b # v7.3.0
|
uses: docker/bake-action@018cb6412ab401ebaa809aa5f85966b74628600f # v7.4.0
|
||||||
with:
|
with:
|
||||||
targets: ${{ matrix.target }}
|
targets: ${{ matrix.target }}
|
||||||
|
|
||||||
# check that the generated Markdown and the checked-in files match
|
# check that the generated Markdown and the checked-in files match
|
||||||
validate-md:
|
validate-md:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-26.04
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
@@ -66,7 +66,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
validate-make:
|
validate-make:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-26.04
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -86,7 +86,7 @@ jobs:
|
|||||||
make -f docker.Makefile ${{ matrix.target }}
|
make -f docker.Makefile ${{ matrix.target }}
|
||||||
|
|
||||||
validate-gocompat:
|
validate-gocompat:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-26.04
|
||||||
env:
|
env:
|
||||||
GOPATH: ${{ github.workspace }}
|
GOPATH: ${{ github.workspace }}
|
||||||
GO111MODULE: off
|
GO111MODULE: off
|
||||||
@@ -101,7 +101,7 @@ jobs:
|
|||||||
name: Set up Go
|
name: Set up Go
|
||||||
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
|
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
|
||||||
with:
|
with:
|
||||||
go-version: "1.26.5"
|
go-version: "1.26.8"
|
||||||
cache: false
|
cache: false
|
||||||
-
|
-
|
||||||
name: Run gocompat check
|
name: Run gocompat check
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
run:
|
run:
|
||||||
uses: crazy-max/.github/.github/workflows/zizmor.yml@46267a6e61cd56aac2fc79943df180152f4c89d6 # v1.10.1
|
uses: crazy-max/.github/.github/workflows/zizmor.yml@f91220cba053bd54299ba645a599ee8ed436f222 # v1.11.0
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
security-events: write
|
security-events: write
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ run:
|
|||||||
# which causes it to fallback to go1.17 semantics.
|
# which causes it to fallback to go1.17 semantics.
|
||||||
#
|
#
|
||||||
# TODO(thaJeztah): update "usetesting" settings to enable go1.24 features once our minimum version is go1.24
|
# TODO(thaJeztah): update "usetesting" settings to enable go1.24 features once our minimum version is go1.24
|
||||||
go: "1.26.5"
|
go: "1.26.8"
|
||||||
|
|
||||||
timeout: 5m
|
timeout: 5m
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -267,7 +267,7 @@ Then you just add a line to every git commit message:
|
|||||||
|
|
||||||
Signed-off-by: Joe Smith <joe.smith@email.com>
|
Signed-off-by: Joe Smith <joe.smith@email.com>
|
||||||
|
|
||||||
Use your real name (sorry, no pseudonyms or anonymous contributions.)
|
Use a known identity (sorry, no anonymous contributions.)
|
||||||
|
|
||||||
If you set your `user.name` and `user.email` git configs, you can sign your
|
If you set your `user.name` and `user.email` git configs, you can sign your
|
||||||
commit automatically with `git commit -s`.
|
commit automatically with `git commit -s`.
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ ARG BASE_VARIANT=alpine
|
|||||||
ARG ALPINE_VERSION=3.23
|
ARG ALPINE_VERSION=3.23
|
||||||
ARG BASE_DEBIAN_DISTRO=bookworm
|
ARG BASE_DEBIAN_DISTRO=bookworm
|
||||||
|
|
||||||
ARG GO_VERSION=1.26.5
|
ARG GO_VERSION=1.26.8
|
||||||
|
|
||||||
# XX_VERSION specifies the version of the xx utility to use.
|
# XX_VERSION specifies the version of the xx utility to use.
|
||||||
# It must be a valid tag in the docker.io/tonistiigi/xx image repository.
|
# It must be a valid tag in the docker.io/tonistiigi/xx image repository.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
// Package hooks defines the contract between the Docker CLI and CLI plugin hook
|
// Package hooks defines the contract between the Docker CLI and CLI plugin hook
|
||||||
// implementations.
|
// implementations.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package hooks
|
package hooks
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package manager
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"slices"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -45,7 +46,7 @@ func TestPluginStubCompletionRestoresOSArgs(t *testing.T) {
|
|||||||
t.Cleanup(func() { os.Args = savedArgs })
|
t.Cleanup(func() { os.Args = savedArgs })
|
||||||
|
|
||||||
originalArgs := []string{"docker", "image", "ls"}
|
originalArgs := []string{"docker", "image", "ls"}
|
||||||
os.Args = append([]string(nil), originalArgs...)
|
os.Args = slices.Clone(originalArgs)
|
||||||
|
|
||||||
_, directive := cmd.ValidArgsFunction(cmd, []string{"--all"}, "alp")
|
_, directive := cmd.ValidArgsFunction(cmd, []string{"--all"}, "alp")
|
||||||
assert.Equal(t, directive, cobra.ShellCompDirectiveError)
|
assert.Equal(t, directive, cobra.ShellCompDirectiveError)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package manager
|
package manager
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package manager
|
package manager
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
|
//go:build go1.26
|
||||||
|
|
||||||
package manager
|
package manager
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -6,7 +9,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
slices "slices"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
@@ -164,8 +167,8 @@ func ListPlugins(dockerCli config.Provider, rootcmd *cobra.Command) ([]Plugin, e
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Slice(plugins, func(i, j int) bool {
|
slices.SortFunc(plugins, func(a, b Plugin) int {
|
||||||
return sortorder.NaturalLess(plugins[i].Name, plugins[j].Name)
|
return sortorder.NaturalCompare(a.Name, b.Name)
|
||||||
})
|
})
|
||||||
|
|
||||||
return plugins, nil
|
return plugins, nil
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
|
//go:build go1.26
|
||||||
|
|
||||||
package manager
|
package manager
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -167,8 +170,7 @@ func (p *Plugin) RunHook(ctx context.Context, hookData hooks.Request) ([]byte, e
|
|||||||
|
|
||||||
out, err := pCmd.Output()
|
out, err := pCmd.Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var exitErr *exec.ExitError
|
if _, ok := errors.AsType[*exec.ExitError](err); ok {
|
||||||
if errors.As(err, &exitErr) {
|
|
||||||
return nil, wrapAsPluginError(err, "plugin hook subcommand exited unsuccessfully")
|
return nil, wrapAsPluginError(err, "plugin hook subcommand exited unsuccessfully")
|
||||||
}
|
}
|
||||||
return nil, wrapAsPluginError(err, "failed to execute plugin hook subcommand: "+pCmd.String())
|
return nil, wrapAsPluginError(err, "failed to execute plugin hook subcommand: "+pCmd.String())
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
|
//go:build go1.26
|
||||||
|
|
||||||
package plugin
|
package plugin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -97,8 +100,7 @@ func Run(makeCmd func(command.Cli) *cobra.Command, meta metadata.Metadata, ops .
|
|||||||
plugin := makeCmd(dockerCLI)
|
plugin := makeCmd(dockerCLI)
|
||||||
|
|
||||||
if err := RunPlugin(dockerCLI, plugin, meta); err != nil {
|
if err := RunPlugin(dockerCLI, plugin, meta); err != nil {
|
||||||
var stErr cli.StatusError
|
if stErr, ok := errors.AsType[cli.StatusError](err); ok {
|
||||||
if errors.As(err, &stErr) {
|
|
||||||
// StatusError should only be used for errors, and all errors should
|
// StatusError should only be used for errors, and all errors should
|
||||||
// have a non-zero exit status, so never exit with 0
|
// have a non-zero exit status, so never exit with 0
|
||||||
if stErr.StatusCode == 0 { // FIXME(thaJeztah): this should never be used with a zero status-code. Check if we do this anywhere.
|
if stErr.StatusCode == 0 { // FIXME(thaJeztah): this should never be used with a zero status-code. Check if we do this anywhere.
|
||||||
|
|||||||
+6
-3
@@ -1,9 +1,12 @@
|
|||||||
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
|
//go:build go1.26
|
||||||
|
|
||||||
package cli
|
package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/docker/cli/cli-plugins/metadata"
|
"github.com/docker/cli/cli-plugins/metadata"
|
||||||
@@ -273,8 +276,8 @@ func topCommands(cmd *cobra.Command) []*cobra.Command {
|
|||||||
cmds = append(cmds, sub)
|
cmds = append(cmds, sub)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sort.SliceStable(cmds, func(i, j int) bool {
|
slices.SortStableFunc(cmds, func(a, b *cobra.Command) int {
|
||||||
return sortorder.NaturalLess(cmds[i].Annotations["category-top"], cmds[j].Annotations["category-top"])
|
return sortorder.NaturalCompare(a.Annotations["category-top"], b.Annotations["category-top"])
|
||||||
})
|
})
|
||||||
return cmds
|
return cmds
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-2
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package command
|
package command
|
||||||
|
|
||||||
@@ -316,7 +316,11 @@ func newAPIClientFromEndpoint(ep docker.Endpoint, configFile *configfile.ConfigF
|
|||||||
opts = append(opts, withCustomHeaders)
|
opts = append(opts, withCustomHeaders)
|
||||||
}
|
}
|
||||||
opts = append(opts, extraOpts...)
|
opts = append(opts, extraOpts...)
|
||||||
return client.New(opts...)
|
apiClient, err := client.New(opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return apiClient, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resolveDockerEndpoint(s store.Reader, contextName string) (docker.Endpoint, error) {
|
func resolveDockerEndpoint(s store.Reader, contextName string) (docker.Endpoint, error) {
|
||||||
|
|||||||
@@ -132,6 +132,15 @@ func TestNewAPIClientFromFlagsWithAPIVersionFromEnv(t *testing.T) {
|
|||||||
assert.Equal(t, apiclient.ClientVersion(), expectedVersion)
|
assert.Equal(t, apiclient.ClientVersion(), expectedVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNewAPIClientFromFlagsWithInvalidAPIVersionFromEnv(t *testing.T) {
|
||||||
|
t.Setenv("DOCKER_API_VERSION", "1")
|
||||||
|
t.Setenv("DOCKER_HOST", ":2375")
|
||||||
|
|
||||||
|
apiClient, err := NewAPIClientFromFlags(&flags.ClientOptions{}, &configfile.ConfigFile{})
|
||||||
|
assert.ErrorContains(t, err, "invalid API version")
|
||||||
|
assert.Check(t, apiClient == nil)
|
||||||
|
}
|
||||||
|
|
||||||
type fakeClient struct {
|
type fakeClient struct {
|
||||||
client.Client
|
client.Client
|
||||||
pingFunc func() (client.PingResult, error)
|
pingFunc func() (client.PingResult, error)
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ package completion
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"sort"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp/cmpopts"
|
||||||
"github.com/moby/moby/api/types/container"
|
"github.com/moby/moby/api/types/container"
|
||||||
"github.com/moby/moby/api/types/image"
|
"github.com/moby/moby/api/types/image"
|
||||||
"github.com/moby/moby/api/types/network"
|
"github.com/moby/moby/api/types/network"
|
||||||
@@ -177,9 +177,10 @@ func TestCompleteEnvVarNames(t *testing.T) {
|
|||||||
values, directives := EnvVarNames()(nil, nil, "")
|
values, directives := EnvVarNames()(nil, nil, "")
|
||||||
assert.Check(t, is.Equal(directives&cobra.ShellCompDirectiveNoFileComp, cobra.ShellCompDirectiveNoFileComp), "Should not perform file completion")
|
assert.Check(t, is.Equal(directives&cobra.ShellCompDirectiveNoFileComp, cobra.ShellCompDirectiveNoFileComp), "Should not perform file completion")
|
||||||
|
|
||||||
sort.Strings(values)
|
|
||||||
expected := []string{"ENV_A", "ENV_B"}
|
expected := []string{"ENV_A", "ENV_B"}
|
||||||
assert.Check(t, is.DeepEqual(values, expected))
|
assert.Check(t, is.DeepEqual(values, expected, cmpopts.SortSlices(func(a, b string) bool {
|
||||||
|
return a < b
|
||||||
|
})))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCompleteFileNames(t *testing.T) {
|
func TestCompleteFileNames(t *testing.T) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package config
|
package config
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package config
|
package config
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
|
//go:build go1.26
|
||||||
|
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"sort"
|
"slices"
|
||||||
|
|
||||||
"github.com/docker/cli/cli"
|
"github.com/docker/cli/cli"
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
@@ -10,6 +13,7 @@ import (
|
|||||||
flagsHelper "github.com/docker/cli/cli/flags"
|
flagsHelper "github.com/docker/cli/cli/flags"
|
||||||
"github.com/docker/cli/opts"
|
"github.com/docker/cli/opts"
|
||||||
"github.com/fvbommel/sortorder"
|
"github.com/fvbommel/sortorder"
|
||||||
|
"github.com/moby/moby/api/types/swarm"
|
||||||
"github.com/moby/moby/client"
|
"github.com/moby/moby/client"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@@ -62,8 +66,8 @@ func runList(ctx context.Context, dockerCLI command.Cli, options listOptions) er
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Slice(res.Items, func(i, j int) bool {
|
slices.SortFunc(res.Items, func(a, b swarm.Config) int {
|
||||||
return sortorder.NaturalLess(res.Items[i].Spec.Name, res.Items[j].Spec.Name)
|
return sortorder.NaturalCompare(a.Spec.Name, b.Spec.Name)
|
||||||
})
|
})
|
||||||
|
|
||||||
configCtx := formatter.Context{
|
configCtx := formatter.Context{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package container
|
package container
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sort"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -15,6 +14,7 @@ import (
|
|||||||
"github.com/docker/cli/cli/config/configfile"
|
"github.com/docker/cli/cli/config/configfile"
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
|
"github.com/google/go-cmp/cmp/cmpopts"
|
||||||
"github.com/moby/moby/api/types/container"
|
"github.com/moby/moby/api/types/container"
|
||||||
"github.com/moby/moby/api/types/system"
|
"github.com/moby/moby/api/types/system"
|
||||||
"github.com/moby/moby/client"
|
"github.com/moby/moby/client"
|
||||||
@@ -284,12 +284,12 @@ func TestCreateContainerWithProxyConfig(t *testing.T) {
|
|||||||
"ALL_PROXY=allProxy",
|
"ALL_PROXY=allProxy",
|
||||||
"all_proxy=allProxy",
|
"all_proxy=allProxy",
|
||||||
}
|
}
|
||||||
sort.Strings(expected)
|
|
||||||
|
|
||||||
fakeCLI := test.NewFakeCli(&fakeClient{
|
fakeCLI := test.NewFakeCli(&fakeClient{
|
||||||
createContainerFunc: func(options client.ContainerCreateOptions) (client.ContainerCreateResult, error) {
|
createContainerFunc: func(options client.ContainerCreateOptions) (client.ContainerCreateResult, error) {
|
||||||
sort.Strings(options.Config.Env)
|
assert.DeepEqual(t, options.Config.Env, expected, cmpopts.SortSlices(func(a, b string) bool {
|
||||||
assert.DeepEqual(t, options.Config.Env, expected)
|
return a < b
|
||||||
|
}))
|
||||||
return client.ContainerCreateResult{}, nil
|
return client.ContainerCreateResult{}, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package container
|
package container
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package container
|
package container
|
||||||
|
|
||||||
@@ -139,6 +139,7 @@ type containerOptions struct {
|
|||||||
runtime string
|
runtime string
|
||||||
autoRemove bool
|
autoRemove bool
|
||||||
init bool
|
init bool
|
||||||
|
umask opts.UmaskOpt
|
||||||
annotations *opts.MapOpts
|
annotations *opts.MapOpts
|
||||||
|
|
||||||
Image string
|
Image string
|
||||||
@@ -313,6 +314,9 @@ func addFlags(flags *pflag.FlagSet) *containerOptions {
|
|||||||
flags.Var(&copts.shmSize, "shm-size", "Size of /dev/shm")
|
flags.Var(&copts.shmSize, "shm-size", "Size of /dev/shm")
|
||||||
flags.StringVar(&copts.utsMode, "uts", "", "UTS namespace to use")
|
flags.StringVar(&copts.utsMode, "uts", "", "UTS namespace to use")
|
||||||
flags.StringVar(&copts.runtime, "runtime", "", "Runtime to use for this container")
|
flags.StringVar(&copts.runtime, "runtime", "", "Runtime to use for this container")
|
||||||
|
flags.Var(&copts.umask, "umask", "Set umask for the container")
|
||||||
|
flags.SetAnnotation("umask", "version", []string{"1.56"})
|
||||||
|
flags.SetAnnotation("umask", "ostype", []string{"linux"})
|
||||||
|
|
||||||
flags.BoolVar(&copts.init, "init", false, "Run an init inside the container that forwards signals and reaps processes")
|
flags.BoolVar(&copts.init, "init", false, "Run an init inside the container that forwards signals and reaps processes")
|
||||||
flags.SetAnnotation("init", "version", []string{"1.25"})
|
flags.SetAnnotation("init", "version", []string{"1.25"})
|
||||||
@@ -710,6 +714,7 @@ func parse(flags *pflag.FlagSet, copts *containerOptions, serverOS string) (*con
|
|||||||
MaskedPaths: maskedPaths,
|
MaskedPaths: maskedPaths,
|
||||||
ReadonlyPaths: readonlyPaths,
|
ReadonlyPaths: readonlyPaths,
|
||||||
Annotations: copts.annotations.GetAll(),
|
Annotations: copts.annotations.GetAll(),
|
||||||
|
Umask: copts.umask.Value(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if copts.autoRemove && !hostConfig.RestartPolicy.IsNone() {
|
if copts.autoRemove && !hostConfig.RestartPolicy.IsNone() {
|
||||||
|
|||||||
@@ -154,6 +154,19 @@ func TestParseRunLinks(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestParseRunWithoutUmask(t *testing.T) {
|
||||||
|
_, hostConfig, _, err := parseRun([]string{"ubuntu", "bash"})
|
||||||
|
assert.NilError(t, err)
|
||||||
|
assert.Assert(t, hostConfig.Umask == nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestParseRunUmask(t *testing.T) {
|
||||||
|
_, hostConfig, _, err := parseRun([]string{"--umask", "0022", "ubuntu", "bash"})
|
||||||
|
assert.NilError(t, err)
|
||||||
|
assert.Assert(t, hostConfig.Umask != nil)
|
||||||
|
assert.Equal(t, uint32(0o22), *hostConfig.Umask)
|
||||||
|
}
|
||||||
|
|
||||||
func TestParseRunAttach(t *testing.T) {
|
func TestParseRunAttach(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
input string
|
input string
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
|
//go:build go1.26
|
||||||
|
|
||||||
package container
|
package container
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"sort"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/docker/cli/cli"
|
"github.com/docker/cli/cli"
|
||||||
@@ -80,9 +83,7 @@ func runPort(ctx context.Context, dockerCli command.Cli, opts *portOptions) erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(out) > 0 {
|
if len(out) > 0 {
|
||||||
sort.Slice(out, func(i, j int) bool {
|
slices.SortFunc(out, sortorder.NaturalCompare)
|
||||||
return sortorder.NaturalLess(out[i], out[j])
|
|
||||||
})
|
|
||||||
_, _ = fmt.Fprintln(dockerCli.Out(), strings.Join(out, "\n"))
|
_, _ = fmt.Fprintln(dockerCli.Out(), strings.Join(out, "\n"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"sort"
|
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
|
"github.com/google/go-cmp/cmp/cmpopts"
|
||||||
"github.com/moby/moby/client"
|
"github.com/moby/moby/client"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
is "gotest.tools/v3/assert/cmp"
|
is "gotest.tools/v3/assert/cmp"
|
||||||
@@ -87,8 +87,9 @@ func TestRestart(t *testing.T) {
|
|||||||
} else {
|
} else {
|
||||||
assert.Check(t, is.Nil(err))
|
assert.Check(t, is.Nil(err))
|
||||||
}
|
}
|
||||||
sort.Strings(restarted)
|
assert.Check(t, is.DeepEqual(restarted, tc.restarted, cmpopts.SortSlices(func(a, b string) bool {
|
||||||
assert.Check(t, is.DeepEqual(restarted, tc.restarted))
|
return a < b
|
||||||
|
})))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"sort"
|
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
|
"github.com/google/go-cmp/cmp/cmpopts"
|
||||||
"github.com/moby/moby/client"
|
"github.com/moby/moby/client"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
)
|
)
|
||||||
@@ -53,8 +53,10 @@ func TestRemoveForce(t *testing.T) {
|
|||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
}
|
}
|
||||||
assert.Equal(t, cli.ErrBuffer().String(), "")
|
assert.Equal(t, cli.ErrBuffer().String(), "")
|
||||||
sort.Strings(removed)
|
expected := []string{"mycontainer", "nosuchcontainer"}
|
||||||
assert.DeepEqual(t, removed, []string{"mycontainer", "nosuchcontainer"})
|
assert.DeepEqual(t, removed, expected, cmpopts.SortSlices(func(a, b string) bool {
|
||||||
|
return a < b
|
||||||
|
}))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
|
//go:build go1.26
|
||||||
|
|
||||||
package container
|
package container
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -169,8 +172,7 @@ func RunStart(ctx context.Context, dockerCli command.Cli, opts *StartOptions) er
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if attachErr := <-cErr; attachErr != nil {
|
if attachErr := <-cErr; attachErr != nil {
|
||||||
var escapeError term.EscapeError
|
if _, ok := errors.AsType[term.EscapeError](attachErr); ok {
|
||||||
if errors.As(attachErr, &escapeError) {
|
|
||||||
// The user entered the detach escape sequence.
|
// The user entered the detach escape sequence.
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package container
|
package container
|
||||||
|
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"sort"
|
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
|
"github.com/google/go-cmp/cmp/cmpopts"
|
||||||
"github.com/moby/moby/client"
|
"github.com/moby/moby/client"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
is "gotest.tools/v3/assert/cmp"
|
is "gotest.tools/v3/assert/cmp"
|
||||||
@@ -88,8 +88,9 @@ func TestStop(t *testing.T) {
|
|||||||
} else {
|
} else {
|
||||||
assert.Check(t, is.Nil(err))
|
assert.Check(t, is.Nil(err))
|
||||||
}
|
}
|
||||||
sort.Strings(stopped)
|
assert.Check(t, is.DeepEqual(stopped, tc.stopped, cmpopts.SortSlices(func(a, b string) bool {
|
||||||
assert.Check(t, is.DeepEqual(stopped, tc.stopped))
|
return a < b
|
||||||
|
})))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package container
|
package container
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package command
|
package command
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package context
|
package context
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package context
|
package context
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package context
|
package context
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package context
|
package context
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package context
|
package context
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"slices"
|
||||||
|
|
||||||
"github.com/docker/cli/cli"
|
"github.com/docker/cli/cli"
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
@@ -101,8 +101,8 @@ func runList(dockerCli command.Cli, opts *listOptions) error {
|
|||||||
Error: errMsg,
|
Error: errMsg,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
sort.Slice(contexts, func(i, j int) bool {
|
slices.SortFunc(contexts, func(a, b *formatter.ClientContext) int {
|
||||||
return sortorder.NaturalLess(contexts[i].Name, contexts[j].Name)
|
return sortorder.NaturalCompare(a.Name, b.Name)
|
||||||
})
|
})
|
||||||
if err := format(dockerCli, opts, contexts); err != nil {
|
if err := format(dockerCli, opts, contexts); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
|
//go:build go1.26
|
||||||
|
|
||||||
package context
|
package context
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -69,8 +72,7 @@ func parseBool(config map[string]string, name string) (bool, error) {
|
|||||||
}
|
}
|
||||||
res, err := strconv.ParseBool(strVal)
|
res, err := strconv.ParseBool(strVal)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var nErr *strconv.NumError
|
if nErr, ok := errors.AsType[*strconv.NumError](err); ok {
|
||||||
if errors.As(err, &nErr) {
|
|
||||||
return res, fmt.Errorf("%s: parsing %q: %w", name, nErr.Num, nErr.Err)
|
return res, fmt.Errorf("%s: parsing %q: %w", name, nErr.Num, nErr.Err)
|
||||||
}
|
}
|
||||||
return res, fmt.Errorf("%s: %w", name, err)
|
return res, fmt.Errorf("%s: %w", name, err)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package command
|
package command
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package command
|
package command
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package command
|
package command
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
|
//go:build go1.26
|
||||||
|
|
||||||
package formatter
|
package formatter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sort"
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -52,20 +55,20 @@ shared: {{.Shared}}
|
|||||||
}
|
}
|
||||||
|
|
||||||
func buildCacheSort(buildCache []build.CacheRecord) {
|
func buildCacheSort(buildCache []build.CacheRecord) {
|
||||||
sort.Slice(buildCache, func(i, j int) bool {
|
slices.SortFunc(buildCache, func(a, b build.CacheRecord) int {
|
||||||
lui, luj := buildCache[i].LastUsedAt, buildCache[j].LastUsedAt
|
|
||||||
switch {
|
switch {
|
||||||
case lui == nil && luj == nil:
|
case a.LastUsedAt == nil && b.LastUsedAt == nil:
|
||||||
return strings.Compare(buildCache[i].ID, buildCache[j].ID) < 0
|
return strings.Compare(a.ID, b.ID)
|
||||||
case lui == nil:
|
case a.LastUsedAt == nil:
|
||||||
return true
|
return -1
|
||||||
case luj == nil:
|
case b.LastUsedAt == nil:
|
||||||
return false
|
return 1
|
||||||
case lui.Equal(*luj):
|
|
||||||
return strings.Compare(buildCache[i].ID, buildCache[j].ID) < 0
|
|
||||||
default:
|
|
||||||
return lui.Before(*luj)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c := a.LastUsedAt.Compare(*b.LastUsedAt); c != 0 {
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
return strings.Compare(a.ID, b.ID)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package formatter
|
package formatter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"cmp"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"sort"
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -295,7 +296,7 @@ func (c *ContainerContext) Labels() string {
|
|||||||
for k, v := range c.c.Labels {
|
for k, v := range c.c.Labels {
|
||||||
joinLabels = append(joinLabels, k+"="+v)
|
joinLabels = append(joinLabels, k+"="+v)
|
||||||
}
|
}
|
||||||
sort.Strings(joinLabels)
|
slices.Sort(joinLabels)
|
||||||
return strings.Join(joinLabels, ",")
|
return strings.Join(joinLabels, ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -395,9 +396,7 @@ func DisplayablePorts(ports []container.PortSummary) string {
|
|||||||
var result []string
|
var result []string
|
||||||
var hostMappings []string
|
var hostMappings []string
|
||||||
var groupMapKeys []string
|
var groupMapKeys []string
|
||||||
sort.Slice(ports, func(i, j int) bool {
|
slices.SortFunc(ports, comparePorts)
|
||||||
return comparePorts(ports[i], ports[j])
|
|
||||||
})
|
|
||||||
|
|
||||||
for _, port := range ports {
|
for _, port := range ports {
|
||||||
current := port.PrivatePort
|
current := port.PrivatePort
|
||||||
@@ -452,18 +451,13 @@ func formGroup(key string, start, last uint16) string {
|
|||||||
return group + "/" + groupType
|
return group + "/" + groupType
|
||||||
}
|
}
|
||||||
|
|
||||||
func comparePorts(i, j container.PortSummary) bool {
|
// comparePorts compares ports by private port, IP address, public port,
|
||||||
if i.PrivatePort != j.PrivatePort {
|
// and protocol, in that order.
|
||||||
return i.PrivatePort < j.PrivatePort
|
func comparePorts(a, b container.PortSummary) int {
|
||||||
}
|
return cmp.Or(
|
||||||
|
cmp.Compare(a.PrivatePort, b.PrivatePort),
|
||||||
if i.IP != j.IP {
|
a.IP.Compare(b.IP),
|
||||||
return i.IP.String() < j.IP.String()
|
cmp.Compare(a.PublicPort, b.PublicPort),
|
||||||
}
|
cmp.Compare(a.Type, b.Type),
|
||||||
|
)
|
||||||
if i.PublicPort != j.PublicPort {
|
|
||||||
return i.PublicPort < j.PublicPort
|
|
||||||
}
|
|
||||||
|
|
||||||
return i.Type < j.Type
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package formatter
|
package formatter
|
||||||
|
|
||||||
@@ -946,6 +946,24 @@ func TestDisplayablePorts(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expected: "80/tcp, 80/udp, 1024/tcp, 1024/udp, 12345/sctp, 1.1.1.1:1024->80/tcp, 1.1.1.1:1024->80/udp, 2.1.1.1:1024->80/tcp, 2.1.1.1:1024->80/udp, 1.1.1.1:80->1024/tcp, 1.1.1.1:80->1024/udp, 2.1.1.1:80->1024/tcp, 2.1.1.1:80->1024/udp", //nolint:revive // ignore line-length-limit (revive)
|
expected: "80/tcp, 80/udp, 1024/tcp, 1024/udp, 12345/sctp, 1.1.1.1:1024->80/tcp, 1.1.1.1:1024->80/udp, 2.1.1.1:1024->80/tcp, 2.1.1.1:1024->80/udp, 1.1.1.1:80->1024/tcp, 1.1.1.1:80->1024/udp, 2.1.1.1:80->1024/tcp, 2.1.1.1:80->1024/udp", //nolint:revive // ignore line-length-limit (revive)
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
// host IPs are ordered numerically, not lexicographically:
|
||||||
|
// "10.0.0.2" sorts as a string before "9.0.0.1".
|
||||||
|
ports: []container.PortSummary{
|
||||||
|
{
|
||||||
|
IP: netip.MustParseAddr("10.0.0.2"),
|
||||||
|
PublicPort: 8080,
|
||||||
|
PrivatePort: 80,
|
||||||
|
Type: "tcp",
|
||||||
|
}, {
|
||||||
|
IP: netip.MustParseAddr("9.0.0.1"),
|
||||||
|
PublicPort: 8081,
|
||||||
|
PrivatePort: 80,
|
||||||
|
Type: "tcp",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expected: "9.0.0.1:8081->80/tcp, 10.0.0.2:8080->80/tcp",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, port := range cases {
|
for _, port := range cases {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package formatter
|
package formatter
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package formatter
|
package formatter
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package formatter
|
package formatter
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package formatter
|
package formatter
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package formatter
|
package formatter
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package formatter
|
package formatter
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package formatter
|
package formatter
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package formatter
|
package formatter
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package idresolver
|
package idresolver
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
|
//go:build go1.26
|
||||||
|
|
||||||
package image
|
package image
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -364,8 +367,7 @@ func runBuild(ctx context.Context, dockerCli command.Cli, options buildOptions)
|
|||||||
|
|
||||||
err = jsonstream.Display(ctx, response.Body, streams.NewOut(buildBuff), jsonstream.WithAuxCallback(aux))
|
err = jsonstream.Display(ctx, response.Body, streams.NewOut(buildBuff), jsonstream.WithAuxCallback(aux))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var jerr *jsonstream.JSONError
|
if jerr, ok := errors.AsType[*jsonstream.JSONError](err); ok {
|
||||||
if errors.As(err, &jerr) {
|
|
||||||
// If no error code is set, default to 1
|
// If no error code is set, default to 1
|
||||||
if jerr.Code == 0 {
|
if jerr.Code == 0 {
|
||||||
jerr.Code = 1
|
jerr.Code = 1
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
|
//go:build go1.26
|
||||||
|
|
||||||
package git
|
package git
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -7,6 +10,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/moby/sys/symlink"
|
"github.com/moby/sys/symlink"
|
||||||
@@ -202,7 +206,7 @@ func (repo gitRepo) checkout(root string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (repo gitRepo) gitWithinDir(dir string, args ...string) ([]byte, error) {
|
func (repo gitRepo) gitWithinDir(dir string, args ...string) ([]byte, error) {
|
||||||
args = append([]string{"-c", "protocol.file.allow=never"}, args...) // Block sneaky repositories from using repos from the filesystem as submodules.
|
args = slices.Concat([]string{"-c", "protocol.file.allow=never"}, args) // Block sneaky repositories from using repos from the filesystem as submodules.
|
||||||
cmd := exec.Command("git", args...)
|
cmd := exec.Command("git", args...)
|
||||||
cmd.Dir = dir
|
cmd.Dir = dir
|
||||||
// Disable unsafe remote protocols.
|
// Disable unsafe remote protocols.
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"slices"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/cli/streams"
|
"github.com/docker/cli/cli/streams"
|
||||||
@@ -211,6 +211,6 @@ func (f *fakeBuild) filenames(t *testing.T) []string {
|
|||||||
for _, header := range h {
|
for _, header := range h {
|
||||||
names = append(names, header.Name)
|
names = append(names, header.Name)
|
||||||
}
|
}
|
||||||
sort.Strings(names)
|
slices.Sort(names)
|
||||||
return names
|
return names
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,14 @@ func TestNewHistoryCommandErrors(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestNewHistoryCommandSuccess(t *testing.T) {
|
func TestNewHistoryCommandSuccess(t *testing.T) {
|
||||||
|
// Set to UTC timezone as timestamps in output are
|
||||||
|
// printed in the current timezone
|
||||||
|
local := time.Local
|
||||||
|
time.Local = time.UTC
|
||||||
|
t.Cleanup(func() {
|
||||||
|
time.Local = local
|
||||||
|
})
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
@@ -118,9 +126,6 @@ func TestNewHistoryCommandSuccess(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
// Set to UTC timezone as timestamps in output are
|
|
||||||
// printed in the current timezone
|
|
||||||
t.Setenv("TZ", "UTC")
|
|
||||||
cli := test.NewFakeCli(&fakeClient{imageHistoryFunc: tc.imageHistoryFunc})
|
cli := test.NewFakeCli(&fakeClient{imageHistoryFunc: tc.imageHistoryFunc})
|
||||||
cmd := newHistoryCommand(cli)
|
cmd := newHistoryCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package image
|
package image
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package image
|
package image
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package image
|
package image
|
||||||
|
|
||||||
|
|||||||
@@ -102,9 +102,11 @@ func TestRunPushRespectsNoColorForAuxNotes(t *testing.T) {
|
|||||||
SelectedManifest: ocispec.Descriptor{Digest: "sha256:2222222222222222222222222222222222222222222222222222222222222222"},
|
SelectedManifest: ocispec.Descriptor{Digest: "sha256:2222222222222222222222222222222222222222222222222222222222222222"},
|
||||||
})
|
})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
line := append([]byte(`{"aux":`), aux...)
|
var buf bytes.Buffer
|
||||||
line = append(line, '}', '\n')
|
buf.WriteString(`{"aux":`)
|
||||||
return fakeStreamResult{ReadCloser: io.NopCloser(bytes.NewReader(line))}, nil
|
buf.Write(aux)
|
||||||
|
buf.WriteString("}\n")
|
||||||
|
return fakeStreamResult{ReadCloser: io.NopCloser(&buf)}, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
cli.Out().SetIsTerminal(true)
|
cli.Out().SetIsTerminal(true)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package image
|
package image
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package inspect
|
package inspect
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package manifest
|
package manifest
|
||||||
|
|
||||||
@@ -48,27 +48,6 @@ func newManifestStore(dockerCLI command.Cli) store.Store {
|
|||||||
return store.NewStore(filepath.Join(config.Dir(), "manifests"))
|
return store.NewStore(filepath.Join(config.Dir(), "manifests"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// authConfigKey is the key used to store credentials for Docker Hub. It is
|
|
||||||
// a copy of [registry.IndexServer].
|
|
||||||
//
|
|
||||||
// [registry.IndexServer]: https://pkg.go.dev/github.com/docker/docker@v28.3.3+incompatible/registry#IndexServer
|
|
||||||
const authConfigKey = "https://index.docker.io/v1/"
|
|
||||||
|
|
||||||
// getAuthConfigKey special-cases using the full index address of the official
|
|
||||||
// index as the AuthConfig key, and uses the (host)name[:port] for private indexes.
|
|
||||||
//
|
|
||||||
// It is similar to [registry.GetAuthConfigKey], but does not require on
|
|
||||||
// [registrytypes.IndexInfo] as intermediate.
|
|
||||||
//
|
|
||||||
// [registry.GetAuthConfigKey]: https://pkg.go.dev/github.com/docker/docker@v28.3.3+incompatible/registry#GetAuthConfigKey
|
|
||||||
// [registrytypes.IndexInfo]: https://pkg.go.dev/github.com/docker/docker@v28.3.3+incompatible/api/types/registry#IndexInfo
|
|
||||||
func getAuthConfigKey(domainName string) string {
|
|
||||||
if domainName == "docker.io" || domainName == "index.docker.io" {
|
|
||||||
return authConfigKey
|
|
||||||
}
|
|
||||||
return domainName
|
|
||||||
}
|
|
||||||
|
|
||||||
// newRegistryClient returns a client for communicating with a Docker distribution
|
// newRegistryClient returns a client for communicating with a Docker distribution
|
||||||
// registry
|
// registry
|
||||||
func newRegistryClient(dockerCLI command.Cli, allowInsecure bool) registryclient.RegistryClient {
|
func newRegistryClient(dockerCLI command.Cli, allowInsecure bool) registryclient.RegistryClient {
|
||||||
@@ -78,8 +57,7 @@ func newRegistryClient(dockerCLI command.Cli, allowInsecure bool) registryclient
|
|||||||
}
|
}
|
||||||
cfg := dockerCLI.ConfigFile()
|
cfg := dockerCLI.ConfigFile()
|
||||||
resolver := func(ctx context.Context, domainName string) registry.AuthConfig {
|
resolver := func(ctx context.Context, domainName string) registry.AuthConfig {
|
||||||
configKey := getAuthConfigKey(domainName)
|
a, _ := cfg.GetAuthConfig(domainName)
|
||||||
a, _ := cfg.GetAuthConfig(configKey)
|
|
||||||
return registry.AuthConfig{
|
return registry.AuthConfig{
|
||||||
Username: a.Username,
|
Username: a.Username,
|
||||||
Password: a.Password,
|
Password: a.Password,
|
||||||
|
|||||||
@@ -189,8 +189,6 @@ func TestNetworkCreateWithFlags(t *testing.T) {
|
|||||||
// TestNetworkCreateIPv4 verifies behavior of the "--ipv4" option. This option
|
// TestNetworkCreateIPv4 verifies behavior of the "--ipv4" option. This option
|
||||||
// is an optional bool, and must default to "nil", not "true" or "false".
|
// is an optional bool, and must default to "nil", not "true" or "false".
|
||||||
func TestNetworkCreateIPv4(t *testing.T) {
|
func TestNetworkCreateIPv4(t *testing.T) {
|
||||||
boolPtr := func(val bool) *bool { return &val }
|
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
doc, name string
|
doc, name string
|
||||||
flags []string
|
flags []string
|
||||||
@@ -205,19 +203,19 @@ func TestNetworkCreateIPv4(t *testing.T) {
|
|||||||
doc: "IPv4 enabled",
|
doc: "IPv4 enabled",
|
||||||
name: "ipv4-enabled",
|
name: "ipv4-enabled",
|
||||||
flags: []string{"--ipv4=true"},
|
flags: []string{"--ipv4=true"},
|
||||||
expected: boolPtr(true),
|
expected: new(true),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
doc: "IPv4 enabled (shorthand)",
|
doc: "IPv4 enabled (shorthand)",
|
||||||
name: "ipv4-enabled-shorthand",
|
name: "ipv4-enabled-shorthand",
|
||||||
flags: []string{"--ipv4"},
|
flags: []string{"--ipv4"},
|
||||||
expected: boolPtr(true),
|
expected: new(true),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
doc: "IPv4 disabled",
|
doc: "IPv4 disabled",
|
||||||
name: "ipv4-disabled",
|
name: "ipv4-disabled",
|
||||||
flags: []string{"--ipv4=false"},
|
flags: []string{"--ipv4=false"},
|
||||||
expected: boolPtr(false),
|
expected: new(false),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,8 +241,6 @@ func TestNetworkCreateIPv4(t *testing.T) {
|
|||||||
// TestNetworkCreateIPv6 verifies behavior of the "--ipv6" option. This option
|
// TestNetworkCreateIPv6 verifies behavior of the "--ipv6" option. This option
|
||||||
// is an optional bool, and must default to "nil", not "true" or "false".
|
// is an optional bool, and must default to "nil", not "true" or "false".
|
||||||
func TestNetworkCreateIPv6(t *testing.T) {
|
func TestNetworkCreateIPv6(t *testing.T) {
|
||||||
strPtr := func(val bool) *bool { return &val }
|
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
doc, name string
|
doc, name string
|
||||||
flags []string
|
flags []string
|
||||||
@@ -259,19 +255,19 @@ func TestNetworkCreateIPv6(t *testing.T) {
|
|||||||
doc: "IPV6 enabled",
|
doc: "IPV6 enabled",
|
||||||
name: "ipv6-enabled",
|
name: "ipv6-enabled",
|
||||||
flags: []string{"--ipv6=true"},
|
flags: []string{"--ipv6=true"},
|
||||||
expected: strPtr(true),
|
expected: new(true),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
doc: "IPV6 enabled (shorthand)",
|
doc: "IPV6 enabled (shorthand)",
|
||||||
name: "ipv6-enabled-shorthand",
|
name: "ipv6-enabled-shorthand",
|
||||||
flags: []string{"--ipv6"},
|
flags: []string{"--ipv6"},
|
||||||
expected: strPtr(true),
|
expected: new(true),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
doc: "IPV6 disabled",
|
doc: "IPV6 disabled",
|
||||||
name: "ipv6-disabled",
|
name: "ipv6-disabled",
|
||||||
flags: []string{"--ipv6=false"},
|
flags: []string{"--ipv6=false"},
|
||||||
expected: strPtr(false),
|
expected: new(false),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package network
|
package network
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package network
|
package network
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package network
|
package network
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
|
//go:build go1.26
|
||||||
|
|
||||||
package network
|
package network
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"sort"
|
"slices"
|
||||||
|
|
||||||
"github.com/docker/cli/cli"
|
"github.com/docker/cli/cli"
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
@@ -10,6 +13,7 @@ import (
|
|||||||
flagsHelper "github.com/docker/cli/cli/flags"
|
flagsHelper "github.com/docker/cli/cli/flags"
|
||||||
"github.com/docker/cli/opts"
|
"github.com/docker/cli/opts"
|
||||||
"github.com/fvbommel/sortorder"
|
"github.com/fvbommel/sortorder"
|
||||||
|
"github.com/moby/moby/api/types/network"
|
||||||
"github.com/moby/moby/client"
|
"github.com/moby/moby/client"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@@ -61,8 +65,8 @@ func runList(ctx context.Context, dockerCLI command.Cli, options listOptions) er
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Slice(res.Items, func(i, j int) bool {
|
slices.SortFunc(res.Items, func(a, b network.Summary) int {
|
||||||
return sortorder.NaturalLess(res.Items[i].Name, res.Items[j].Name)
|
return sortorder.NaturalCompare(a.Name, b.Name)
|
||||||
})
|
})
|
||||||
|
|
||||||
networksCtx := formatter.Context{
|
networksCtx := formatter.Context{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package node
|
package node
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package node
|
package node
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
|
//go:build go1.26
|
||||||
|
|
||||||
package node
|
package node
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"sort"
|
"slices"
|
||||||
|
|
||||||
"github.com/docker/cli/cli"
|
"github.com/docker/cli/cli"
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
@@ -10,6 +13,7 @@ import (
|
|||||||
flagsHelper "github.com/docker/cli/cli/flags"
|
flagsHelper "github.com/docker/cli/cli/flags"
|
||||||
"github.com/docker/cli/opts"
|
"github.com/docker/cli/opts"
|
||||||
"github.com/fvbommel/sortorder"
|
"github.com/fvbommel/sortorder"
|
||||||
|
"github.com/moby/moby/api/types/swarm"
|
||||||
"github.com/moby/moby/client"
|
"github.com/moby/moby/client"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@@ -73,8 +77,8 @@ func runList(ctx context.Context, dockerCLI command.Cli, options listOptions) er
|
|||||||
Output: dockerCLI.Out(),
|
Output: dockerCLI.Out(),
|
||||||
Format: newFormat(format, options.quiet),
|
Format: newFormat(format, options.quiet),
|
||||||
}
|
}
|
||||||
sort.Slice(res.Items, func(i, j int) bool {
|
slices.SortFunc(res.Items, func(a, b swarm.Node) int {
|
||||||
return sortorder.NaturalLess(res.Items[i].Description.Hostname, res.Items[j].Description.Hostname)
|
return sortorder.NaturalCompare(a.Description.Hostname, b.Description.Hostname)
|
||||||
})
|
})
|
||||||
return formatWrite(nodesCtx, res, info)
|
return formatWrite(nodesCtx, res, info)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package node
|
package node
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package plugin
|
package plugin
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package plugin
|
package plugin
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
|
//go:build go1.26
|
||||||
|
|
||||||
package plugin
|
package plugin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"sort"
|
"slices"
|
||||||
|
|
||||||
"github.com/docker/cli/cli"
|
"github.com/docker/cli/cli"
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
@@ -10,6 +13,7 @@ import (
|
|||||||
flagsHelper "github.com/docker/cli/cli/flags"
|
flagsHelper "github.com/docker/cli/cli/flags"
|
||||||
"github.com/docker/cli/opts"
|
"github.com/docker/cli/opts"
|
||||||
"github.com/fvbommel/sortorder"
|
"github.com/fvbommel/sortorder"
|
||||||
|
"github.com/moby/moby/api/types/plugin"
|
||||||
"github.com/moby/moby/client"
|
"github.com/moby/moby/client"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@@ -54,8 +58,8 @@ func runList(ctx context.Context, dockerCli command.Cli, options listOptions) er
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Slice(resp.Items, func(i, j int) bool {
|
slices.SortFunc(resp.Items, func(a, b plugin.Plugin) int {
|
||||||
return sortorder.NaturalLess(resp.Items[i].Name, resp.Items[j].Name)
|
return sortorder.NaturalCompare(a.Name, b.Name)
|
||||||
})
|
})
|
||||||
|
|
||||||
format := options.format
|
format := options.format
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package secret
|
package secret
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package secret
|
package secret
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
|
//go:build go1.26
|
||||||
|
|
||||||
package secret
|
package secret
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"sort"
|
"slices"
|
||||||
|
|
||||||
"github.com/docker/cli/cli"
|
"github.com/docker/cli/cli"
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
@@ -10,6 +13,7 @@ import (
|
|||||||
flagsHelper "github.com/docker/cli/cli/flags"
|
flagsHelper "github.com/docker/cli/cli/flags"
|
||||||
"github.com/docker/cli/opts"
|
"github.com/docker/cli/opts"
|
||||||
"github.com/fvbommel/sortorder"
|
"github.com/fvbommel/sortorder"
|
||||||
|
"github.com/moby/moby/api/types/swarm"
|
||||||
"github.com/moby/moby/client"
|
"github.com/moby/moby/client"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@@ -59,8 +63,8 @@ func runSecretList(ctx context.Context, dockerCLI command.Cli, options listOptio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Slice(res.Items, func(i, j int) bool {
|
slices.SortFunc(res.Items, func(a, b swarm.Secret) int {
|
||||||
return sortorder.NaturalLess(res.Items[i].Spec.Name, res.Items[j].Spec.Name)
|
return sortorder.NaturalCompare(a.Spec.Name, b.Spec.Name)
|
||||||
})
|
})
|
||||||
|
|
||||||
secretCtx := formatter.Context{
|
secretCtx := formatter.Context{
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
|
//go:build go1.26
|
||||||
|
|
||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"cmp"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -615,8 +619,8 @@ func NewListFormat(source string, quiet bool) formatter.Format {
|
|||||||
// ListFormatWrite writes the context
|
// ListFormatWrite writes the context
|
||||||
func ListFormatWrite(ctx formatter.Context, services client.ServiceListResult) error {
|
func ListFormatWrite(ctx formatter.Context, services client.ServiceListResult) error {
|
||||||
render := func(format func(subContext formatter.SubContext) error) error {
|
render := func(format func(subContext formatter.SubContext) error) error {
|
||||||
sort.Slice(services.Items, func(i, j int) bool {
|
slices.SortFunc(services.Items, func(a, b swarm.Service) int {
|
||||||
return sortorder.NaturalLess(services.Items[i].Spec.Name, services.Items[j].Spec.Name)
|
return sortorder.NaturalCompare(a.Spec.Name, b.Spec.Name)
|
||||||
})
|
})
|
||||||
for _, service := range services.Items {
|
for _, service := range services.Items {
|
||||||
serviceCtx := &serviceContext{service: service}
|
serviceCtx := &serviceContext{service: service}
|
||||||
@@ -775,17 +779,16 @@ func (c *serviceContext) Ports() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
pr := portRange{}
|
// Sort by protocol first, then by published port.
|
||||||
ports := []string{}
|
slices.SortFunc(c.service.Endpoint.Ports, func(a, b swarm.PortConfig) int {
|
||||||
|
return cmp.Or(
|
||||||
servicePorts := c.service.Endpoint.Ports
|
cmp.Compare(a.Protocol, b.Protocol),
|
||||||
sort.Slice(servicePorts, func(i, j int) bool {
|
cmp.Compare(a.PublishedPort, b.PublishedPort),
|
||||||
if servicePorts[i].Protocol == servicePorts[j].Protocol {
|
)
|
||||||
return servicePorts[i].PublishedPort < servicePorts[j].PublishedPort
|
|
||||||
}
|
|
||||||
return servicePorts[i].Protocol < servicePorts[j].Protocol
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
var pr portRange
|
||||||
|
var ports []string
|
||||||
for _, p := range c.service.Endpoint.Ports {
|
for _, p := range c.service.Endpoint.Ports {
|
||||||
if p.PublishMode == swarm.PortConfigPublishModeIngress {
|
if p.PublishMode == swarm.PortConfigPublishModeIngress {
|
||||||
prIsRange := pr.tEnd != pr.tStart
|
prIsRange := pr.tEnd != pr.tStart
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package service
|
package service
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package service
|
package service
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package service
|
package service
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
// Package genericresource is a local fork of SwarmKit's [genericresource] package,
|
// Package genericresource is a local fork of SwarmKit's [genericresource] package,
|
||||||
// without protobuf dependencies.
|
// without protobuf dependencies.
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
|
//go:build go1.26
|
||||||
|
|
||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -6,7 +9,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"sort"
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -314,7 +317,7 @@ func (lw *logWriter) Write(buf []byte) (int, error) {
|
|||||||
d = append(d, k+"="+details[k])
|
d = append(d, k+"="+details[k])
|
||||||
}
|
}
|
||||||
// then sort em
|
// then sort em
|
||||||
sort.Strings(d)
|
slices.Sort(d)
|
||||||
// then join and append
|
// then join and append
|
||||||
output = append(output, []byte(strings.Join(d, ","))...)
|
output = append(output, []byte(strings.Join(d, ","))...)
|
||||||
output = append(output, ' ')
|
output = append(output, ' ')
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"cmp"
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
"slices"
|
"slices"
|
||||||
"sort"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -737,15 +737,15 @@ func (options *serviceOptions) ToService(ctx context.Context, apiClient client.N
|
|||||||
}
|
}
|
||||||
|
|
||||||
networks := convertNetworks(options.networks)
|
networks := convertNetworks(options.networks)
|
||||||
for i, net := range networks {
|
for i := range networks {
|
||||||
nwID, err := resolveNetworkID(ctx, apiClient, net.Target)
|
nwID, err := resolveNetworkID(ctx, apiClient, networks[i].Target)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return service, err
|
return service, err
|
||||||
}
|
}
|
||||||
networks[i].Target = nwID
|
networks[i].Target = nwID
|
||||||
}
|
}
|
||||||
sort.Slice(networks, func(i, j int) bool {
|
slices.SortFunc(networks, func(a, b swarm.NetworkAttachmentConfig) int {
|
||||||
return networks[i].Target < networks[j].Target
|
return cmp.Compare(a.Target, b.Target)
|
||||||
})
|
})
|
||||||
|
|
||||||
resources, err := options.resources.ToResourceRequirements(flags)
|
resources, err := options.resources.ToResourceRequirements(flags)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package progress
|
package progress
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||||
//go:build go1.25
|
//go:build go1.26
|
||||||
|
|
||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"cmp"
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"maps"
|
"maps"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
"slices"
|
"slices"
|
||||||
"sort"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -352,8 +352,10 @@ func updateService(ctx context.Context, apiClient client.NetworkAPIClient, flags
|
|||||||
if err := updateIsolation(flagIsolation, &cspec.Isolation); err != nil {
|
if err := updateIsolation(flagIsolation, &cspec.Isolation); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := updateMounts(flags, &cspec.Mounts); err != nil {
|
if anyChanged(flags, flagMountAdd, flagMountRemove) {
|
||||||
return err
|
if err := updateMounts(flags, &cspec.Mounts); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSysCtls(flags, &task.ContainerSpec.Sysctls)
|
updateSysCtls(flags, &task.ContainerSpec.Sysctls)
|
||||||
@@ -635,7 +637,7 @@ func updatePlacementConstraints(flags *pflag.FlagSet, placement *swarm.Placement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Sort so that result is predictable.
|
// Sort so that result is predictable.
|
||||||
sort.Strings(newConstraints)
|
slices.Sort(newConstraints)
|
||||||
|
|
||||||
placement.Constraints = newConstraints
|
placement.Constraints = newConstraints
|
||||||
}
|
}
|
||||||
@@ -720,7 +722,7 @@ func updateSysCtls(flags *pflag.FlagSet, field *map[string]string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func updateUlimits(flags *pflag.FlagSet, ulimits []*container.Ulimit) []*container.Ulimit {
|
func updateUlimits(flags *pflag.FlagSet, ulimits []*container.Ulimit) []*container.Ulimit {
|
||||||
newUlimits := make(map[string]*container.Ulimit)
|
newUlimits := make(map[string]*container.Ulimit, len(ulimits))
|
||||||
|
|
||||||
for _, ulimit := range ulimits {
|
for _, ulimit := range ulimits {
|
||||||
newUlimits[ulimit.Name] = ulimit
|
newUlimits[ulimit.Name] = ulimit
|
||||||
@@ -737,17 +739,9 @@ func updateUlimits(flags *pflag.FlagSet, ulimits []*container.Ulimit) []*contain
|
|||||||
newUlimits[ulimit.Name] = ulimit
|
newUlimits[ulimit.Name] = ulimit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(newUlimits) == 0 {
|
return slices.SortedFunc(maps.Values(newUlimits), func(a, b *container.Ulimit) int {
|
||||||
return nil
|
return cmp.Compare(a.Name, b.Name)
|
||||||
}
|
|
||||||
limits := make([]*container.Ulimit, 0, len(newUlimits))
|
|
||||||
for _, ulimit := range newUlimits {
|
|
||||||
limits = append(limits, ulimit)
|
|
||||||
}
|
|
||||||
sort.SliceStable(limits, func(i, j int) bool {
|
|
||||||
return limits[i].Name < limits[j].Name
|
|
||||||
})
|
})
|
||||||
return limits
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateEnvironment(flags *pflag.FlagSet, field *[]string) {
|
func updateEnvironment(flags *pflag.FlagSet, field *[]string) {
|
||||||
@@ -953,14 +947,12 @@ func updateMounts(flags *pflag.FlagSet, mounts *[]mount.Mount) error {
|
|||||||
newMounts = append(newMounts, mnt)
|
newMounts = append(newMounts, mnt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sort.Slice(newMounts, func(i, j int) bool {
|
// Sort mounts by source, then by target.
|
||||||
a, b := newMounts[i], newMounts[j]
|
slices.SortFunc(newMounts, func(a, b mount.Mount) int {
|
||||||
|
return cmp.Or(
|
||||||
if a.Source == b.Source {
|
cmp.Compare(a.Source, b.Source),
|
||||||
return a.Target < b.Target
|
cmp.Compare(a.Target, b.Target),
|
||||||
}
|
)
|
||||||
|
|
||||||
return a.Source < b.Source
|
|
||||||
})
|
})
|
||||||
*mounts = newMounts
|
*mounts = newMounts
|
||||||
return nil
|
return nil
|
||||||
@@ -980,7 +972,7 @@ func updateGroups(flags *pflag.FlagSet, groups *[]string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Sort so that result is predictable.
|
// Sort so that result is predictable.
|
||||||
sort.Strings(newGroups)
|
slices.Sort(newGroups)
|
||||||
|
|
||||||
*groups = newGroups
|
*groups = newGroups
|
||||||
return nil
|
return nil
|
||||||
@@ -1039,7 +1031,7 @@ func updateDNSConfig(flags *pflag.FlagSet, config **swarm.DNSConfig) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Sort so that result is predictable.
|
// Sort so that result is predictable.
|
||||||
sort.Strings(newConfig.Search)
|
slices.Sort(newConfig.Search)
|
||||||
|
|
||||||
options := (*config).Options
|
options := (*config).Options
|
||||||
if flags.Changed(flagDNSOptionAdd) {
|
if flags.Changed(flagDNSOptionAdd) {
|
||||||
@@ -1054,7 +1046,7 @@ func updateDNSConfig(flags *pflag.FlagSet, config **swarm.DNSConfig) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Sort so that result is predictable.
|
// Sort so that result is predictable.
|
||||||
sort.Strings(newConfig.Options)
|
slices.Sort(newConfig.Options)
|
||||||
|
|
||||||
*config = newConfig
|
*config = newConfig
|
||||||
return nil
|
return nil
|
||||||
@@ -1107,12 +1099,8 @@ portLoop:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort the PortConfig to avoid unnecessary updates
|
// Sort the PortConfig to avoid unnecessary updates.
|
||||||
sort.Slice(newPorts, func(i, j int) bool {
|
slices.SortFunc(newPorts, swarm.PortConfig.Compare)
|
||||||
// We convert PortConfig into `port/protocol`, e.g., `80/tcp`
|
|
||||||
// In updatePorts we already filter out with map so there is duplicate entries
|
|
||||||
return portConfigToString(&newPorts[i]) < portConfigToString(&newPorts[j])
|
|
||||||
})
|
|
||||||
*portConfig = newPorts
|
*portConfig = newPorts
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -1348,8 +1336,8 @@ func updateNetworks(ctx context.Context, apiClient client.NetworkAPIClient, flag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Slice(newNetworks, func(i, j int) bool {
|
slices.SortFunc(newNetworks, func(a, b swarm.NetworkAttachmentConfig) int {
|
||||||
return newNetworks[i].Target < newNetworks[j].Target
|
return cmp.Compare(a.Target, b.Target)
|
||||||
})
|
})
|
||||||
|
|
||||||
spec.TaskTemplate.Networks = newNetworks
|
spec.TaskTemplate.Networks = newNetworks
|
||||||
@@ -1523,10 +1511,6 @@ func capsList(caps map[string]bool) []string {
|
|||||||
if caps[opts.AllCapabilities] {
|
if caps[opts.AllCapabilities] {
|
||||||
return []string{opts.AllCapabilities}
|
return []string{opts.AllCapabilities}
|
||||||
}
|
}
|
||||||
out := make([]string, 0, len(caps))
|
|
||||||
for c := range caps {
|
return slices.Sorted(maps.Keys(caps))
|
||||||
out = append(out, c)
|
|
||||||
}
|
|
||||||
sort.Strings(out)
|
|
||||||
return out
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
"sort"
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@@ -141,7 +141,7 @@ func TestUpdateEnvironment(t *testing.T) {
|
|||||||
updateEnvironment(flags, &envs)
|
updateEnvironment(flags, &envs)
|
||||||
assert.Assert(t, is.Len(envs, 2))
|
assert.Assert(t, is.Len(envs, 2))
|
||||||
// Order has been removed in updateEnvironment (map)
|
// Order has been removed in updateEnvironment (map)
|
||||||
sort.Strings(envs)
|
slices.Sort(envs)
|
||||||
assert.Check(t, is.Equal("toadd=newenv", envs[0]))
|
assert.Check(t, is.Equal("toadd=newenv", envs[0]))
|
||||||
assert.Check(t, is.Equal("tokeep=value", envs[1]))
|
assert.Check(t, is.Equal("tokeep=value", envs[1]))
|
||||||
}
|
}
|
||||||
@@ -250,6 +250,32 @@ func TestUpdateMounts(t *testing.T) {
|
|||||||
assert.Check(t, is.Equal("/tokeep", mounts[1].Target))
|
assert.Check(t, is.Equal("/tokeep", mounts[1].Target))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUpdateServiceForcePreservesMountOrder(t *testing.T) {
|
||||||
|
flags := newUpdateCommand(nil).Flags()
|
||||||
|
assert.NilError(t, flags.Set("force", "true"))
|
||||||
|
|
||||||
|
spec := &swarm.ServiceSpec{
|
||||||
|
TaskTemplate: swarm.TaskSpec{
|
||||||
|
ContainerSpec: &swarm.ContainerSpec{
|
||||||
|
Mounts: []mount.Mount{
|
||||||
|
{Type: mount.TypeVolume, Source: "z-volume", Target: "/data/z"},
|
||||||
|
{Type: mount.TypeVolume, Source: "a-volume", Target: "/data/a"},
|
||||||
|
{Type: mount.TypeVolume, Source: "m-volume", Target: "/data/m"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
err := updateService(context.Background(), nil, flags, spec)
|
||||||
|
assert.NilError(t, err)
|
||||||
|
assert.Equal(t, spec.TaskTemplate.ForceUpdate, uint64(1))
|
||||||
|
assert.DeepEqual(t, spec.TaskTemplate.ContainerSpec.Mounts, []mount.Mount{
|
||||||
|
{Type: mount.TypeVolume, Source: "z-volume", Target: "/data/z"},
|
||||||
|
{Type: mount.TypeVolume, Source: "a-volume", Target: "/data/a"},
|
||||||
|
{Type: mount.TypeVolume, Source: "m-volume", Target: "/data/m"},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func TestUpdateMountsWithDuplicateMounts(t *testing.T) {
|
func TestUpdateMountsWithDuplicateMounts(t *testing.T) {
|
||||||
flags := newUpdateCommand(nil).Flags()
|
flags := newUpdateCommand(nil).Flags()
|
||||||
flags.Set("mount-add", "type=volume,source=vol4,target=/toadd")
|
flags.Set("mount-add", "type=volume,source=vol4,target=/toadd")
|
||||||
@@ -282,7 +308,7 @@ func TestUpdatePorts(t *testing.T) {
|
|||||||
assert.Assert(t, is.Len(portConfigs, 2))
|
assert.Assert(t, is.Len(portConfigs, 2))
|
||||||
// Do a sort to have the order (might have changed by map)
|
// Do a sort to have the order (might have changed by map)
|
||||||
targetPorts := []int{int(portConfigs[0].TargetPort), int(portConfigs[1].TargetPort)}
|
targetPorts := []int{int(portConfigs[0].TargetPort), int(portConfigs[1].TargetPort)}
|
||||||
sort.Ints(targetPorts)
|
slices.Sort(targetPorts)
|
||||||
assert.Check(t, is.Equal(555, targetPorts[0]))
|
assert.Check(t, is.Equal(555, targetPorts[0]))
|
||||||
assert.Check(t, is.Equal(1000, targetPorts[1]))
|
assert.Check(t, is.Equal(1000, targetPorts[1]))
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user