Skip to content

Commit

Permalink
fix: update dep usage based on newer version
Browse files Browse the repository at this point in the history
Signed-off-by: Nianyu Shen <[email protected]>
  • Loading branch information
nianyush committed Mar 12, 2024
1 parent 625284e commit e4dfabc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"runtime"
"strings"

"github.com/docker/docker/api/types"
registrytypes "github.com/docker/docker/api/types/registry"
"github.com/docker/go-units"
"github.com/mudler/luet/pkg/api/core/image"
fileHelper "github.com/mudler/luet/pkg/helpers/file"
Expand Down Expand Up @@ -122,7 +122,7 @@ func NewUnpackCommand() *cobra.Command {
registryToken, _ := cmd.Flags().GetString("auth-registry-token")

util.DefaultContext.Info("Downloading", image, "to", destination)
auth := &types.AuthConfig{
auth := &registrytypes.AuthConfig{
Username: user,
Password: pass,
ServerAddress: server,
Expand Down
3 changes: 2 additions & 1 deletion pkg/api/core/image/digest.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import (
func Available(image string, opt ...crane.Option) bool {
// We use crane.insecure as we just check if the image is available
// It's the daemon duty to use it or not based on the host settings
transport := remote.DefaultTransport.Clone()

transport := remote.DefaultTransport.(*http.Transport).Clone()
transport.TLSClientConfig = &tls.Config{
InsecureSkipVerify: true, //nolint: gosec
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/helpers/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (

"github.com/docker/cli/cli/trust"
"github.com/docker/distribution/reference"
"github.com/docker/docker/api/types"
registrytypes "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/registry"
"github.com/google/go-containerregistry/pkg/authn"
"github.com/google/go-containerregistry/pkg/name"
Expand All @@ -53,7 +53,7 @@ const (

// See also https://github.com/docker/cli/blob/88c6089300a82d3373892adf6845a4fed1a4ba8d/cli/command/image/trust.go#L171

func verifyImage(image string, authConfig *types.AuthConfig) (string, error) {
func verifyImage(image string, authConfig *registrytypes.AuthConfig) (string, error) {
ref, err := reference.ParseAnyReference(image)
if err != nil {
return "", errors.Wrapf(err, "invalid reference %s", image)
Expand Down Expand Up @@ -82,7 +82,7 @@ func verifyImage(image string, authConfig *types.AuthConfig) (string, error) {
return "", nil
}

func trustedResolveDigest(ctx context.Context, ref reference.NamedTagged, authConfig *types.AuthConfig, useragent string) (reference.Canonical, error) {
func trustedResolveDigest(ctx context.Context, ref reference.NamedTagged, authConfig *registrytypes.AuthConfig, useragent string) (reference.Canonical, error) {
repoInfo, err := registry.ParseRepositoryInfo(ref)
if err != nil {
return nil, err
Expand Down Expand Up @@ -115,7 +115,7 @@ func trustedResolveDigest(ctx context.Context, ref reference.NamedTagged, authCo
}

type staticAuth struct {
auth *types.AuthConfig
auth *registrytypes.AuthConfig
}

func (s staticAuth) Authorization() (*authn.AuthConfig, error) {
Expand All @@ -138,7 +138,7 @@ type UnpackEventData struct {
}

// DownloadAndExtractDockerImage extracts a container image natively. It supports privileged/unprivileged mode
func DownloadAndExtractDockerImage(ctx luettypes.Context, image, dest string, auth *types.AuthConfig, verify bool) (*images.Image, error) {
func DownloadAndExtractDockerImage(ctx luettypes.Context, image, dest string, auth *registrytypes.AuthConfig, verify bool) (*images.Image, error) {
if verify {
img, err := verifyImage(image, auth)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/installer/client/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"path"
"path/filepath"

"github.com/docker/docker/api/types"
registrytypes "github.com/docker/docker/api/types/registry"
"github.com/docker/go-units"
luettypes "github.com/mudler/luet/pkg/api/core/types"
"github.com/pkg/errors"
Expand All @@ -40,13 +40,13 @@ const (

type DockerClient struct {
RepoData RepoData
auth *types.AuthConfig
auth *registrytypes.AuthConfig
Cache *artifact.ArtifactCache
context luettypes.Context
}

func NewDockerClient(r RepoData, ctx luettypes.Context) *DockerClient {
auth := &types.AuthConfig{}
auth := &registrytypes.AuthConfig{}

dat, _ := json.Marshal(r.Authentication)
json.Unmarshal(dat, auth)
Expand Down

0 comments on commit e4dfabc

Please sign in to comment.