|
@@ -9,7 +9,7 @@ import (
|
|
|
"strings"
|
|
|
"testing"
|
|
|
|
|
|
- "github.com/docker/docker/api/types"
|
|
|
+ "github.com/docker/docker/api/types/image"
|
|
|
"github.com/docker/docker/api/types/registry"
|
|
|
"github.com/docker/docker/errdefs"
|
|
|
"gotest.tools/v3/assert"
|
|
@@ -23,12 +23,12 @@ func TestImagePushReferenceError(t *testing.T) {
|
|
|
}),
|
|
|
}
|
|
|
// An empty reference is an invalid reference
|
|
|
- _, err := client.ImagePush(context.Background(), "", types.ImagePushOptions{})
|
|
|
+ _, err := client.ImagePush(context.Background(), "", image.PushOptions{})
|
|
|
if err == nil || !strings.Contains(err.Error(), "invalid reference format") {
|
|
|
t.Fatalf("expected an error, got %v", err)
|
|
|
}
|
|
|
// An canonical reference cannot be pushed
|
|
|
- _, err = client.ImagePush(context.Background(), "repo@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", types.ImagePushOptions{})
|
|
|
+ _, err = client.ImagePush(context.Background(), "repo@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", image.PushOptions{})
|
|
|
if err == nil || err.Error() != "cannot push a digest reference" {
|
|
|
t.Fatalf("expected an error, got %v", err)
|
|
|
}
|
|
@@ -38,7 +38,7 @@ func TestImagePushAnyError(t *testing.T) {
|
|
|
client := &Client{
|
|
|
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
|
|
}
|
|
|
- _, err := client.ImagePush(context.Background(), "myimage", types.ImagePushOptions{})
|
|
|
+ _, err := client.ImagePush(context.Background(), "myimage", image.PushOptions{})
|
|
|
assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
|
|
|
}
|
|
|
|
|
@@ -46,7 +46,7 @@ func TestImagePushStatusUnauthorizedError(t *testing.T) {
|
|
|
client := &Client{
|
|
|
client: newMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")),
|
|
|
}
|
|
|
- _, err := client.ImagePush(context.Background(), "myimage", types.ImagePushOptions{})
|
|
|
+ _, err := client.ImagePush(context.Background(), "myimage", image.PushOptions{})
|
|
|
assert.Check(t, is.ErrorType(err, errdefs.IsUnauthorized))
|
|
|
}
|
|
|
|
|
@@ -57,7 +57,7 @@ func TestImagePushWithUnauthorizedErrorAndPrivilegeFuncError(t *testing.T) {
|
|
|
privilegeFunc := func() (string, error) {
|
|
|
return "", fmt.Errorf("Error requesting privilege")
|
|
|
}
|
|
|
- _, err := client.ImagePush(context.Background(), "myimage", types.ImagePushOptions{
|
|
|
+ _, err := client.ImagePush(context.Background(), "myimage", image.PushOptions{
|
|
|
PrivilegeFunc: privilegeFunc,
|
|
|
})
|
|
|
if err == nil || err.Error() != "Error requesting privilege" {
|
|
@@ -72,7 +72,7 @@ func TestImagePushWithUnauthorizedErrorAndAnotherUnauthorizedError(t *testing.T)
|
|
|
privilegeFunc := func() (string, error) {
|
|
|
return "a-auth-header", nil
|
|
|
}
|
|
|
- _, err := client.ImagePush(context.Background(), "myimage", types.ImagePushOptions{
|
|
|
+ _, err := client.ImagePush(context.Background(), "myimage", image.PushOptions{
|
|
|
PrivilegeFunc: privilegeFunc,
|
|
|
})
|
|
|
assert.Check(t, is.ErrorType(err, errdefs.IsUnauthorized))
|
|
@@ -109,7 +109,7 @@ func TestImagePushWithPrivilegedFuncNoError(t *testing.T) {
|
|
|
privilegeFunc := func() (string, error) {
|
|
|
return "IAmValid", nil
|
|
|
}
|
|
|
- resp, err := client.ImagePush(context.Background(), "myimage:tag", types.ImagePushOptions{
|
|
|
+ resp, err := client.ImagePush(context.Background(), "myimage:tag", image.PushOptions{
|
|
|
RegistryAuth: "NotValid",
|
|
|
PrivilegeFunc: privilegeFunc,
|
|
|
})
|
|
@@ -179,7 +179,7 @@ func TestImagePushWithoutErrors(t *testing.T) {
|
|
|
}, nil
|
|
|
}),
|
|
|
}
|
|
|
- resp, err := client.ImagePush(context.Background(), tc.reference, types.ImagePushOptions{
|
|
|
+ resp, err := client.ImagePush(context.Background(), tc.reference, image.PushOptions{
|
|
|
All: tc.all,
|
|
|
})
|
|
|
if err != nil {
|