-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request moby#47866 from cncal/return_container_annotations
api/server: ContainerList returns container annotations
- Loading branch information
Showing
7 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package container | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
typecontainer "github.com/docker/docker/api/types/container" | ||
"github.com/docker/docker/api/types/filters" | ||
"github.com/docker/docker/client" | ||
"github.com/docker/docker/integration/internal/container" | ||
"github.com/docker/docker/testutil/request" | ||
"gotest.tools/v3/assert" | ||
is "gotest.tools/v3/assert/cmp" | ||
) | ||
|
||
func TestListAnnotations(t *testing.T) { | ||
ctx := setupTest(t) | ||
|
||
annotations := map[string]string{ | ||
"foo": "bar", | ||
"io.kubernetes.docker.type": "container", | ||
} | ||
testcases := []struct { | ||
apiVersion string | ||
expectedAnnotations map[string]string | ||
}{ | ||
{apiVersion: "1.44", expectedAnnotations: nil}, | ||
{apiVersion: "1.46", expectedAnnotations: annotations}, | ||
} | ||
|
||
for _, tc := range testcases { | ||
t.Run(fmt.Sprintf("run with version v%s", tc.apiVersion), func(t *testing.T) { | ||
apiClient := request.NewAPIClient(t, client.WithVersion(tc.apiVersion)) | ||
id := container.Create(ctx, t, apiClient, container.WithAnnotations(annotations)) | ||
defer container.Remove(ctx, t, apiClient, id, typecontainer.RemoveOptions{Force: true}) | ||
|
||
containers, err := apiClient.ContainerList( | ||
ctx, | ||
typecontainer.ListOptions{ | ||
All: true, | ||
Filters: filters.NewArgs(filters.Arg("id", id)), | ||
}, | ||
) | ||
assert.NilError(t, err) | ||
assert.Assert(t, is.Len(containers, 1)) | ||
assert.Equal(t, containers[0].ID, id) | ||
assert.Check(t, is.DeepEqual(containers[0].HostConfig.Annotations, tc.expectedAnnotations)) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters