Skip to content

Commit

Permalink
fix: deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
argoyle committed May 20, 2023
1 parent c256566 commit 840ec22
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 35 deletions.
6 changes: 3 additions & 3 deletions pkg/docker/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ 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"
"google.golang.org/grpc"
)

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,
Expand Down
4 changes: 2 additions & 2 deletions pkg/docker/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/docker/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/push/push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
6 changes: 3 additions & 3 deletions pkg/registry/dockerhub.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions pkg/registry/ecr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -111,16 +111,16 @@ 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 {
return err
}
}

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 {
Expand Down
10 changes: 5 additions & 5 deletions pkg/registry/gcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/gcr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 4 additions & 4 deletions pkg/registry/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions pkg/registry/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions pkg/registry/no.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions pkg/registry/quay.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion pkg/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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
Expand Down

0 comments on commit 840ec22

Please sign in to comment.