Merge pull request #42176 from cpuguy83/20.10_testPushMultipleTags
[20.10] TestPushMultipleTags: Add support for 20.10 CLI
This commit is contained in:
commit
9f2f85c53b
4 changed files with 21 additions and 1 deletions
|
@ -26,6 +26,7 @@ type CmdOperator func(*icmd.Cmd) func()
|
|||
|
||||
// DockerCmd executes the specified docker command and expect a success
|
||||
func DockerCmd(t testing.TB, args ...string) *icmd.Result {
|
||||
t.Helper()
|
||||
return Docker(Args(args...)).Assert(t, icmd.Success)
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/docker/distribution/reference"
|
||||
"github.com/docker/docker/api/types/versions"
|
||||
"github.com/docker/docker/integration-cli/cli/build"
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/icmd"
|
||||
|
@ -81,7 +82,15 @@ func testPushMultipleTags(c *testing.T) {
|
|||
// tag the image and upload it to the private registry
|
||||
dockerCmd(c, "tag", "busybox", repoTag1)
|
||||
dockerCmd(c, "tag", "busybox", repoTag2)
|
||||
dockerCmd(c, "push", repoName)
|
||||
|
||||
args := []string{"push"}
|
||||
if versions.GreaterThanOrEqualTo(DockerCLIVersion(c), "20.10.0") {
|
||||
// 20.10 CLI removed implicit push all tags and requires the "--all" flag
|
||||
args = append(args, "--all-tags")
|
||||
}
|
||||
args = append(args, repoName)
|
||||
|
||||
dockerCmd(c, args...)
|
||||
|
||||
imageAlreadyExists := ": Image already exists"
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ func dockerCmdWithError(args ...string) (string, int, error) {
|
|||
|
||||
// Deprecated: use cli.Docker or cli.DockerCmd
|
||||
func dockerCmd(c testing.TB, args ...string) (string, int) {
|
||||
c.Helper()
|
||||
result := cli.DockerCmd(c, args...)
|
||||
return result.Combined(), result.ExitCode
|
||||
}
|
||||
|
|
|
@ -189,6 +189,15 @@ func TODOBuildkit() bool {
|
|||
return os.Getenv("DOCKER_BUILDKIT") == ""
|
||||
}
|
||||
|
||||
func DockerCLIVersion(t testing.TB) string {
|
||||
out, _ := dockerCmd(t, "--version")
|
||||
version := strings.Fields(out)
|
||||
if len(version) < 3 {
|
||||
t.Fatal("unknown version output", version)
|
||||
}
|
||||
return version[2]
|
||||
}
|
||||
|
||||
// testRequires checks if the environment satisfies the requirements
|
||||
// for the test to run or skips the tests.
|
||||
func testRequires(t *testing.T, requirements ...requirement.Test) {
|
||||
|
|
Loading…
Reference in a new issue