Skip to content

Commit

Permalink
moby
Browse files Browse the repository at this point in the history
github.com/docker/docker redirects to github.com/moby/moby
  • Loading branch information
hilmarf committed Apr 18, 2024
1 parent d8b2531 commit a981317
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 124 deletions.
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ require (
github.com/cyberphone/json-canonicalization v0.0.0-20231217050601-ba74d44ecf5f
github.com/DataDog/gostackparse v0.7.0
github.com/distribution/reference v0.6.0
github.com/docker/cli v25.0.5+incompatible
github.com/docker/docker v25.0.5+incompatible
github.com/docker/cli v26.0.1+incompatible
github.com/docker/go-connections v0.5.0
github.com/drone/envsubst v1.0.3
github.com/fluxcd/cli-utils v0.36.0-flux.5
Expand All @@ -45,6 +44,7 @@ require (
github.com/Masterminds/semver/v3 v3.2.1
github.com/mitchellh/copystructure v1.2.0
github.com/mittwald/go-helm-client v0.12.9
github.com/moby/moby v26.0.1+incompatible
github.com/modern-go/reflect2 v1.0.2
github.com/onsi/ginkgo/v2 v2.17.1
github.com/onsi/gomega v1.32.0
Expand Down Expand Up @@ -146,6 +146,7 @@ require (
github.com/digitorus/timestamp v0.0.0-20231217203849-220c5c2851b7 // indirect
github.com/dimchansky/utfbom v1.1.1 // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/docker v25.0.3+incompatible // indirect
github.com/docker/docker-credential-helpers v0.8.1 // indirect
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c // indirect
github.com/docker/go-metrics v0.0.1 // indirect
Expand Down Expand Up @@ -235,6 +236,7 @@ require (
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/locker v1.0.1 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
Expand Down
12 changes: 8 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -309,13 +309,13 @@ github.com/distribution/distribution/v3 v3.0.0-20221208165359-362910506bc2 h1:aB
github.com/distribution/distribution/v3 v3.0.0-20221208165359-362910506bc2/go.mod h1:WHNsWjnIn2V1LYOrME7e8KxSeKunYHsxEm4am0BUtcI=
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
github.com/docker/cli v25.0.5+incompatible h1:3Llw3kcE1gOScEojA247iDD+p1l9hHeC7H3vf3Zd5fk=
github.com/docker/cli v25.0.5+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
github.com/docker/cli v26.0.1+incompatible h1:eZDuplk2jYqgUkNLDYwTBxqmY9cM3yHnmN6OIUEjL3U=
github.com/docker/cli v26.0.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v25.0.5+incompatible h1:UmQydMduGkrD5nQde1mecF/YnSbTOaPeFIeP5C4W+DE=
github.com/docker/docker v25.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v25.0.3+incompatible h1:D5fy/lYmY7bvZa0XTZ5/UJPljor41F+vdyJG5luQLfQ=
github.com/docker/docker v25.0.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker-credential-helpers v0.8.1 h1:j/eKUktUltBtMzKqmfLB0PAgqYyMHOp5vfsD1807oKo=
github.com/docker/docker-credential-helpers v0.8.1/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M=
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0=
Expand Down Expand Up @@ -709,8 +709,12 @@ github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zx
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/mittwald/go-helm-client v0.12.9 h1:tfI5ECgrbfAolA9TnlCeA5F2TEIvdsOxVmoSyW80lCI=
github.com/mittwald/go-helm-client v0.12.9/go.mod h1:ukR3Et5zbfBij7bFL1ZnLvPytsbBXCrI2qQYr2yVi9I=
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg=
github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc=
github.com/moby/moby v26.0.1+incompatible h1:vCKs/AM0lLYnMxFwpf8ycsOekPPPcGn0s0Iczqv3/ec=
github.com/moby/moby v26.0.1+incompatible/go.mod h1:fDXVQ6+S340veQPv35CzDahGBmHsiclFwfEygB/TWMc=
github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8=
github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c=
github.com/moby/sys/mountinfo v0.7.1 h1:/tTvQaSJRr2FshkhXiIpux6fQ2Zvc4j7tAhMTStAG2g=
Expand Down
100 changes: 8 additions & 92 deletions pkg/contexts/oci/repositories/docker/client.go
Original file line number Diff line number Diff line change
@@ -1,118 +1,34 @@
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors.
//
// SPDX-License-Identifier: Apache-2.0

// taken from "github.com/containers/image/v5", unfortunately this is private and cannot be used via import

package docker

import (
"os"

"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/config"
cliflags "github.com/docker/cli/cli/flags"
dockerclient "github.com/docker/docker/client"
"github.com/docker/cli/cli/flags"
"github.com/moby/moby/client"

Check failure on line 9 in pkg/contexts/oci/repositories/docker/client.go

View workflow job for this annotation

GitHub Actions / Lint

could not import github.com/moby/moby/client (-: # github.com/moby/moby/client
"github.com/spf13/pflag"
)

func newDockerClient(dockerhost string) (*dockerclient.Client, error) {
func newDockerClient(dockerhost string) (*client.Client, error) {
if dockerhost == "" {
opts := cliflags.NewClientOptions()
opts := flags.NewClientOptions()
// set defaults
opts.SetDefaultOptions(pflag.NewFlagSet("", pflag.ContinueOnError))
configfile := config.LoadDefaultConfigFile(os.Stderr)
c, err := command.NewAPIClientFromFlags(opts, configfile)
if err != nil {
return nil, err
}
return c.(*dockerclient.Client), nil
return c.(*client.Client), nil
}
c, err := dockerclient.NewClientWithOpts(dockerclient.FromEnv, dockerclient.WithHost(dockerhost))
c, err := client.NewClientWithOpts(client.FromEnv, client.WithHost(dockerhost))
if err != nil {
return nil, err
}
url, err := dockerclient.ParseHostURL(dockerhost)
url, err := client.ParseHostURL(dockerhost)
if err == nil && url.Scheme == "unix" {
dockerclient.WithScheme(url.Scheme)(c)
client.WithScheme(url.Scheme)(c)
}
return c, nil
}

/*
const (
// The default API version to be used in case none is explicitly specified.
defaultAPIVersion = "1.22"
)
// NewDockerClient initializes a new API client based on the passed SystemContext.
func newDockerClient2(host string) (*dockerclient.Client, error) {
if host == "" {
host = dockerclient.DefaultDockerHost
}
// Sadly, unix:// sockets don't work transparently with dockerclient.NewClient.
// They work fine with a nil httpClient; with a non-nil httpClient, the transport’s
// TLSClientConfig must be nil (or the client will try using HTTPS over the PF_UNIX socket
// regardless of the values in the *tls.Config), and we would have to call sockets.ConfigureTransport.
//
// We don't really want to configure anything for unix:// sockets, so just pass a nil *http.Client.
//
// Similarly, if we want to communicate over plain HTTP on a TCP socket, we also need to set
// TLSClientConfig to nil. This can be achieved by using the form `http://`
url, err := dockerclient.ParseHostURL(host)
if err != nil {
return nil, err
}
var httpClient *http.Client
if url.Scheme != "unix" {
if url.Scheme == "http" {
httpClient = httpConfig()
} else {
hc, err := tlsConfig(nil)
if err != nil {
return nil, err
}
httpClient = hc
}
}
return dockerclient.NewClient(host, defaultAPIVersion, httpClient, nil)
}
func tlsConfig(sys *types.SystemContext) (*http.Client, error) {
options := tlsconfig.Options{}
if sys != nil && sys.DockerDaemonInsecureSkipTLSVerify {
options.InsecureSkipVerify = true
}
if sys != nil && sys.DockerDaemonCertPath != "" {
options.CAFile = filepath.Join(sys.DockerDaemonCertPath, "ca.pem")
options.CertFile = filepath.Join(sys.DockerDaemonCertPath, "cert.pem")
options.KeyFile = filepath.Join(sys.DockerDaemonCertPath, "key.pem")
}
tlsc, err := tlsconfig.Client(options)
if err != nil {
return nil, err
}
return &http.Client{
Transport: &http.Transport{
TLSClientConfig: tlsc,
},
CheckRedirect: dockerclient.CheckRedirect,
}, nil
}
func httpConfig() *http.Client {
return &http.Client{
Transport: &http.Transport{
TLSClientConfig: nil,
},
CheckRedirect: dockerclient.CheckRedirect,
}
}
*/
8 changes: 2 additions & 6 deletions pkg/contexts/oci/repositories/docker/namespace.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors.
//
// SPDX-License-Identifier: Apache-2.0

package docker

import (
Expand All @@ -11,8 +7,8 @@ import (

"github.com/containers/image/v5/image"
"github.com/containers/image/v5/types"
dockertypes "github.com/docker/docker/api/types"
"github.com/mandelsoft/logging"
mobyImage "github.com/moby/moby/api/types/image"
"github.com/opencontainers/go-digest"

"github.com/open-component-model/ocm/pkg/blobaccess"
Expand Down Expand Up @@ -131,7 +127,7 @@ func (n *namespaceContainer) GetBlobDescriptor(digest digest.Digest) *cpi.Descri
}

func (n *namespaceHandler) ListTags() ([]string, error) {
opts := dockertypes.ImageListOptions{}
opts := mobyImage.ListOptions{}
list, err := n.repo.client.ImageList(dummyContext, opts)
if err != nil {
return nil, err
Expand Down
12 changes: 4 additions & 8 deletions pkg/contexts/oci/repositories/docker/repository.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors.
//
// SPDX-License-Identifier: Apache-2.0

package docker

import (
"strings"

"github.com/containers/image/v5/types"
dockertypes "github.com/docker/docker/api/types"
"github.com/docker/docker/client"
"github.com/moby/moby/api/types/image"
"github.com/moby/moby/client"

"github.com/open-component-model/ocm/pkg/contexts/oci/cpi"
)
Expand Down Expand Up @@ -75,7 +71,7 @@ func (r *RepositoryImpl) GetNamespaces(prefix string, closure bool) ([]string, e
}

func (r *RepositoryImpl) GetRepositories() ([]string, error) {
opts := dockertypes.ImageListOptions{}
opts := image.ListOptions{}
list, err := r.client.ImageList(dummyContext, opts)
if err != nil {
return nil, err
Expand Down Expand Up @@ -103,7 +99,7 @@ func (r *RepositoryImpl) ExistsArtifact(name string, version string) (bool, erro
if err != nil {
return false, err
}
opts := dockertypes.ImageListOptions{}
opts := image.ListOptions{}
opts.Filters.Add("reference", ref.StringWithinTransport())
list, err := r.client.ImageList(dummyContext, opts)
if err != nil {
Expand Down
14 changes: 7 additions & 7 deletions pkg/toi/drivers/docker/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import (

"github.com/distribution/reference"
"github.com/docker/cli/cli/command"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
registrytypes "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/client"
"github.com/docker/docker/pkg/jsonmessage"
"github.com/docker/docker/pkg/stdcopy"
"github.com/docker/docker/registry"
"github.com/mitchellh/copystructure"
"github.com/moby/moby/api/types"
"github.com/moby/moby/api/types/container"
registrytypes "github.com/moby/moby/api/types/registry"
"github.com/moby/moby/client"
"github.com/moby/moby/pkg/jsonmessage"
"github.com/moby/moby/pkg/stdcopy"
"github.com/moby/moby/registry"

"github.com/open-component-model/ocm/pkg/blobaccess"
"github.com/open-component-model/ocm/pkg/errors"
Expand Down
6 changes: 1 addition & 5 deletions pkg/toi/drivers/docker/opts.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and Open Component Model contributors.
//
// SPDX-License-Identifier: Apache-2.0

package docker

import (
"github.com/docker/docker/api/types/container"
"github.com/moby/moby/api/types/container"
)

func NetworkModeOpt(mode string) ConfigurationOption {
Expand Down

0 comments on commit a981317

Please sign in to comment.