diff --git a/go.mod b/go.mod index 7c5cc612..e9bc6e1e 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/containerd/containerd v1.7.1 github.com/containerd/continuity v0.3.1-0.20230206214859-2a963a2f56e8 // indirect github.com/daviddengcn/go-colortext v1.0.0 // indirect - github.com/docker/docker v23.0.3+incompatible + github.com/docker/docker v24.0.1+incompatible github.com/docker/go-connections v0.4.0 // indirect github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect github.com/fvbommel/sortorder v1.1.0 // indirect diff --git a/go.sum b/go.sum index 20bf5998..2e032c8b 100644 --- a/go.sum +++ b/go.sum @@ -123,8 +123,8 @@ github.com/daviddengcn/go-colortext v1.0.0 h1:ANqDyC0ys6qCSvuEK7l3g5RaehL/Xck9EX github.com/daviddengcn/go-colortext v1.0.0/go.mod h1:zDqEI5NVUop5QPpVJUxE9UO10hRnmkD5G4Pmri9+m4c= github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v23.0.3+incompatible h1:9GhVsShNWz1hO//9BNg/dpMnZW25KydO4wtVxWAIbho= -github.com/docker/docker v23.0.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v24.0.1+incompatible h1:NxN81beIxDlUaVt46iUQrYHD9/W3u9EGl52r86O/IGw= +github.com/docker/docker v24.0.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c h1:+pKlWGMw7gf6bQ+oDZB4KHQFypsfjYlq/C4rfL7D3g8= diff --git a/pkg/docker/auth.go b/pkg/docker/auth.go index 94875137..3db9760a 100644 --- a/pkg/docker/auth.go +++ b/pkg/docker/auth.go @@ -33,7 +33,7 @@ import ( authutil "github.com/containerd/containerd/remotes/docker/auth" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/registry" "github.com/moby/buildkit/session" "github.com/moby/buildkit/session/auth" "golang.org/x/crypto/nacl/sign" @@ -41,11 +41,11 @@ import ( ) type authenticator struct { - authConfig types.AuthConfig + authConfig registry.AuthConfig registryHost string } -func NewAuthenticator(registryHost string, authConfig types.AuthConfig) Authenticator { +func NewAuthenticator(registryHost string, authConfig registry.AuthConfig) Authenticator { return &authenticator{ authConfig: authConfig, registryHost: registryHost, diff --git a/pkg/docker/auth_test.go b/pkg/docker/auth_test.go index def23d43..5e29e8fe 100644 --- a/pkg/docker/auth_test.go +++ b/pkg/docker/auth_test.go @@ -26,13 +26,13 @@ import ( "context" "testing" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/registry" auth2 "github.com/moby/buildkit/session/auth" "github.com/stretchr/testify/require" ) func Test_Credentials(t *testing.T) { - auth := NewAuthenticator("use-auth.com", types.AuthConfig{ + auth := NewAuthenticator("use-auth.com", registry.AuthConfig{ Username: "user", Password: "password", }) diff --git a/pkg/docker/docker.go b/pkg/docker/docker.go index 6c3a612b..4739f90e 100644 --- a/pkg/docker/docker.go +++ b/pkg/docker/docker.go @@ -41,7 +41,7 @@ import ( ) type Client interface { - RegistryLogin(ctx context.Context, auth types.AuthConfig) (registry.AuthenticateOKBody, error) + RegistryLogin(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error) ImageBuild(ctx context.Context, buildContext io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error) ImagePush(ctx context.Context, image string, options types.ImagePushOptions) (io.ReadCloser, error) DialHijack(ctx context.Context, url, proto string, meta map[string][]string) (net.Conn, error) diff --git a/pkg/docker/testing.go b/pkg/docker/testing.go index 8d2d407c..5470d5ed 100644 --- a/pkg/docker/testing.go +++ b/pkg/docker/testing.go @@ -84,7 +84,7 @@ func (m *MockDocker) ImagePush(ctx context.Context, image string, options types. return io.NopCloser(strings.NewReader(*m.PushOutput)), nil } -func (m *MockDocker) RegistryLogin(ctx context.Context, auth types.AuthConfig) (registry.AuthenticateOKBody, error) { +func (m *MockDocker) RegistryLogin(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error) { m.Username = auth.Username m.Password = auth.Password m.ServerAddress = auth.ServerAddress diff --git a/pkg/push/push_test.go b/pkg/push/push_test.go index 5a4ecd9b..47cee5ac 100644 --- a/pkg/push/push_test.go +++ b/pkg/push/push_test.go @@ -40,7 +40,7 @@ import ( "github.com/buildtool/build-tools/pkg/vcs" "github.com/buildtool/build-tools/pkg/version" - "github.com/docker/docker/api/types" + types "github.com/docker/docker/api/types/registry" "github.com/stretchr/testify/assert" ) diff --git a/pkg/registry/dockerhub.go b/pkg/registry/dockerhub.go index 9b50d04d..32d4ab6a 100644 --- a/pkg/registry/dockerhub.go +++ b/pkg/registry/dockerhub.go @@ -28,7 +28,7 @@ import ( "encoding/json" "github.com/apex/log" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/registry" "github.com/buildtool/build-tools/pkg/docker" ) @@ -60,8 +60,8 @@ func (r Dockerhub) Login(client docker.Client) error { } } -func (r Dockerhub) GetAuthConfig() types.AuthConfig { - return types.AuthConfig{Username: r.Username, Password: r.Password} +func (r Dockerhub) GetAuthConfig() registry.AuthConfig { + return registry.AuthConfig{Username: r.Username, Password: r.Password} } func (r Dockerhub) GetAuthInfo() string { diff --git a/pkg/registry/ecr.go b/pkg/registry/ecr.go index 815fbcce..0dd2792e 100644 --- a/pkg/registry/ecr.go +++ b/pkg/registry/ecr.go @@ -37,7 +37,7 @@ import ( "github.com/aws/aws-sdk-go/service/ecr/ecriface" "github.com/aws/aws-sdk-go/service/sts" "github.com/aws/aws-sdk-go/service/sts/stsiface" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/registry" "github.com/buildtool/build-tools/pkg/docker" ) @@ -111,7 +111,7 @@ func (r *ECR) Login(client docker.Client) error { r.username = parts[0] r.password = parts[1] - if ok, err := client.RegistryLogin(context.Background(), types.AuthConfig{Username: r.username, Password: r.password, ServerAddress: r.Url}); err == nil { + if ok, err := client.RegistryLogin(context.Background(), registry.AuthConfig{Username: r.username, Password: r.password, ServerAddress: r.Url}); err == nil { log.Debugf("%s\n", ok.Status) return nil } else { @@ -119,8 +119,8 @@ func (r *ECR) Login(client docker.Client) error { } } -func (r *ECR) GetAuthConfig() types.AuthConfig { - return types.AuthConfig{Username: r.username, Password: r.password} +func (r *ECR) GetAuthConfig() registry.AuthConfig { + return registry.AuthConfig{Username: r.username, Password: r.password} } func (r *ECR) GetAuthInfo() string { diff --git a/pkg/registry/gcr.go b/pkg/registry/gcr.go index 082491a5..9207dd64 100644 --- a/pkg/registry/gcr.go +++ b/pkg/registry/gcr.go @@ -28,7 +28,7 @@ import ( "encoding/json" "github.com/apex/log" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/registry" "github.com/buildtool/build-tools/pkg/docker" ) @@ -49,7 +49,7 @@ func (r *GCR) Configured() bool { if len(r.Url) <= 0 || len(r.KeyFileContent) <= 0 { return false } - return r.GetAuthConfig() != types.AuthConfig{} + return r.GetAuthConfig() != registry.AuthConfig{} } func (r *GCR) Login(client docker.Client) error { @@ -63,12 +63,12 @@ func (r *GCR) Login(client docker.Client) error { } } -func (r *GCR) GetAuthConfig() types.AuthConfig { +func (r *GCR) GetAuthConfig() registry.AuthConfig { decoded, err := base64.StdEncoding.DecodeString(r.KeyFileContent) if err != nil { - return types.AuthConfig{} + return registry.AuthConfig{} } - return types.AuthConfig{Username: "_json_key", Password: string(decoded)} + return registry.AuthConfig{Username: "_json_key", Password: string(decoded)} } func (r *GCR) GetAuthInfo() string { diff --git a/pkg/registry/gcr_test.go b/pkg/registry/gcr_test.go index ec57c58c..902fc762 100644 --- a/pkg/registry/gcr_test.go +++ b/pkg/registry/gcr_test.go @@ -27,7 +27,7 @@ import ( "testing" "github.com/apex/log" - "github.com/docker/docker/api/types" + types "github.com/docker/docker/api/types/registry" "github.com/stretchr/testify/assert" mocks "gitlab.com/unboundsoftware/apex-mocks" diff --git a/pkg/registry/github.go b/pkg/registry/github.go index db56daf1..cfc8246a 100644 --- a/pkg/registry/github.go +++ b/pkg/registry/github.go @@ -29,7 +29,7 @@ import ( "fmt" "github.com/apex/log" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/registry" "github.com/buildtool/build-tools/pkg/docker" ) @@ -53,7 +53,7 @@ func (r Github) Configured() bool { } func (r Github) Login(client docker.Client) error { - if ok, err := client.RegistryLogin(context.Background(), types.AuthConfig{Username: r.Username, Password: r.password(), ServerAddress: "ghcr.io"}); err == nil { + if ok, err := client.RegistryLogin(context.Background(), registry.AuthConfig{Username: r.Username, Password: r.password(), ServerAddress: "ghcr.io"}); err == nil { log.Debugf("%s\n", ok.Status) return nil } else { @@ -67,8 +67,8 @@ func (r Github) password() string { } return r.Password } -func (r Github) GetAuthConfig() types.AuthConfig { - return types.AuthConfig{Username: r.Username, Password: r.password(), ServerAddress: "ghcr.io"} +func (r Github) GetAuthConfig() registry.AuthConfig { + return registry.AuthConfig{Username: r.Username, Password: r.password(), ServerAddress: "ghcr.io"} } func (r Github) GetAuthInfo() string { diff --git a/pkg/registry/gitlab.go b/pkg/registry/gitlab.go index 3540e435..57e4a22b 100644 --- a/pkg/registry/gitlab.go +++ b/pkg/registry/gitlab.go @@ -29,7 +29,7 @@ import ( "strings" "github.com/apex/log" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/registry" "github.com/buildtool/build-tools/pkg/docker" ) @@ -61,8 +61,8 @@ func (r Gitlab) Login(client docker.Client) error { } } -func (r Gitlab) GetAuthConfig() types.AuthConfig { - return types.AuthConfig{Username: r.User, Password: r.Token, ServerAddress: r.Registry} +func (r Gitlab) GetAuthConfig() registry.AuthConfig { + return registry.AuthConfig{Username: r.User, Password: r.Token, ServerAddress: r.Registry} } func (r Gitlab) GetAuthInfo() string { diff --git a/pkg/registry/no.go b/pkg/registry/no.go index 4c57bb89..74582d6b 100644 --- a/pkg/registry/no.go +++ b/pkg/registry/no.go @@ -26,7 +26,7 @@ import ( "fmt" "github.com/apex/log" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/registry" "github.com/buildtool/build-tools/pkg/docker" ) @@ -46,8 +46,8 @@ func (n NoDockerRegistry) Login(client docker.Client) error { return nil } -func (n NoDockerRegistry) GetAuthConfig() types.AuthConfig { - return types.AuthConfig{} +func (n NoDockerRegistry) GetAuthConfig() registry.AuthConfig { + return registry.AuthConfig{} } func (n NoDockerRegistry) GetAuthInfo() string { diff --git a/pkg/registry/quay.go b/pkg/registry/quay.go index 6e485b47..eb5d54fd 100644 --- a/pkg/registry/quay.go +++ b/pkg/registry/quay.go @@ -29,7 +29,7 @@ import ( "fmt" "github.com/apex/log" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/registry" "github.com/buildtool/build-tools/pkg/docker" ) @@ -60,8 +60,8 @@ func (r *Quay) Login(client docker.Client) error { } } -func (r Quay) GetAuthConfig() types.AuthConfig { - return types.AuthConfig{Username: r.Username, Password: r.Password, ServerAddress: "quay.io"} +func (r Quay) GetAuthConfig() registry.AuthConfig { + return registry.AuthConfig{Username: r.Username, Password: r.Password, ServerAddress: "quay.io"} } func (r Quay) GetAuthInfo() string { diff --git a/pkg/registry/registry.go b/pkg/registry/registry.go index 4c9f2db8..c7abdc70 100644 --- a/pkg/registry/registry.go +++ b/pkg/registry/registry.go @@ -30,6 +30,7 @@ import ( "github.com/apex/log" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/registry" "github.com/buildtool/build-tools/pkg/docker" ) @@ -38,7 +39,7 @@ type Registry interface { Configured() bool Name() string Login(client docker.Client) error - GetAuthConfig() types.AuthConfig + GetAuthConfig() registry.AuthConfig GetAuthInfo() string RegistryUrl() string Create(repository string) error