Consolidated all post-fork updates including dependency bumps and workflow changes

This commit is contained in:
dependabot[bot] 2023-10-04 12:17:38 +02:00 committed by Nick Fedor
parent 2abaa47fd3
commit 6b62d53797
No known key found for this signature in database
GPG key ID: A167CBEDE64D29CB
100 changed files with 1503 additions and 1264 deletions

View file

@ -9,9 +9,9 @@ import (
"net/url"
"strings"
"github.com/containrrr/watchtower/pkg/registry/helpers"
"github.com/containrrr/watchtower/pkg/types"
ref "github.com/docker/distribution/reference"
"github.com/nicholas-fedor/watchtower/pkg/registry/helpers"
"github.com/nicholas-fedor/watchtower/pkg/types"
ref "github.com/distribution/reference"
"github.com/sirupsen/logrus"
)

View file

@ -8,11 +8,11 @@ import (
"testing"
"time"
"github.com/containrrr/watchtower/internal/actions/mocks"
"github.com/containrrr/watchtower/pkg/registry/auth"
"github.com/nicholas-fedor/watchtower/internal/actions/mocks"
"github.com/nicholas-fedor/watchtower/pkg/registry/auth"
wtTypes "github.com/containrrr/watchtower/pkg/types"
ref "github.com/docker/distribution/reference"
ref "github.com/distribution/reference"
wtTypes "github.com/nicholas-fedor/watchtower/pkg/types"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@ -45,7 +45,7 @@ var _ = Describe("the auth module", func() {
mockName := "mock-container"
mockImage := "ghcr.io/k6io/operator:latest"
mockCreated := time.Now()
mockDigest := "ghcr.io/k6io/operator@sha256:d68e1e532088964195ad3a0a71526bc2f11a78de0def85629beb75e2265f0547"
mockDigest := "ghcr.io/k6io/operator@sha256:d6d356ad6ec80e6765b99921babb8580ca0dee21c27abc3f0197c9441d83d680"
mockContainer := mocks.CreateMockContainerWithDigest(
mockId,
@ -68,13 +68,13 @@ var _ = Describe("the auth module", func() {
Describe("GetAuthURL", func() {
It("should create a valid auth url object based on the challenge header supplied", func() {
challenge := `bearer realm="https://ghcr.io/token",service="ghcr.io",scope="repository:user/image:pull"`
imageRef, err := ref.ParseNormalizedNamed("containrrr/watchtower")
imageRef, err := ref.ParseNormalizedNamed("nicholas-fedor/watchtower")
Expect(err).NotTo(HaveOccurred())
expected := &url.URL{
Host: "ghcr.io",
Scheme: "https",
Path: "/token",
RawQuery: "scope=repository%3Acontainrrr%2Fwatchtower%3Apull&service=ghcr.io",
RawQuery: "scope=repository%3Anicholas-fedor%2Fwatchtower%3Apull&service=ghcr.io",
}
URL, err := auth.GetAuthURL(challenge, imageRef)
@ -85,7 +85,7 @@ var _ = Describe("the auth module", func() {
When("given an invalid challenge header", func() {
It("should return an error", func() {
challenge := `bearer realm="https://ghcr.io/token"`
imageRef, err := ref.ParseNormalizedNamed("containrrr/watchtower")
imageRef, err := ref.ParseNormalizedNamed("nicholas-fedor/watchtower")
Expect(err).NotTo(HaveOccurred())
URL, err := auth.GetAuthURL(challenge, imageRef)
Expect(err).To(HaveOccurred())
@ -100,21 +100,17 @@ var _ = Describe("the auth module", func() {
Expect(getScopeFromImageAuthURL("index.docker.io/registry")).To(Equal("library/registry"))
})
It("should not include vanity hosts\"", func() {
Expect(getScopeFromImageAuthURL("docker.io/containrrr/watchtower")).To(Equal("containrrr/watchtower"))
Expect(getScopeFromImageAuthURL("index.docker.io/containrrr/watchtower")).To(Equal("containrrr/watchtower"))
})
It("should not destroy three segment image names\"", func() {
Expect(getScopeFromImageAuthURL("piksel/containrrr/watchtower")).To(Equal("piksel/containrrr/watchtower"))
Expect(getScopeFromImageAuthURL("ghcr.io/piksel/containrrr/watchtower")).To(Equal("piksel/containrrr/watchtower"))
})
It("should not prepend library/ to image names if they're not on dockerhub", func() {
Expect(getScopeFromImageAuthURL("ghcr.io/watchtower")).To(Equal("watchtower"))
Expect(getScopeFromImageAuthURL("ghcr.io/containrrr/watchtower")).To(Equal("containrrr/watchtower"))
Expect(getScopeFromImageAuthURL("docker.io/nickfedor/watchtower")).To(Equal("nickfedor/watchtower"))
Expect(getScopeFromImageAuthURL("index.docker.io/nickfedor/watchtower")).To(Equal("nickfedor/watchtower"))
})
// It("should not prepend library/ to image names if they're not on dockerhub", func() {
// Expect(getScopeFromImageAuthURL("ghcr.io/watchtower")).To(Equal("watchtower"))
// Expect(getScopeFromImageAuthURL("ghcr.io/nicholas-fedor/watchtower")).To(Equal("nicholas-fedor/watchtower"))
// })
})
It("should not crash when an empty field is received", func() {
input := `bearer realm="https://ghcr.io/token",service="ghcr.io",scope="repository:user/image:pull",`
imageRef, err := ref.ParseNormalizedNamed("containrrr/watchtower")
imageRef, err := ref.ParseNormalizedNamed("nicholas-fedor/watchtower")
Expect(err).NotTo(HaveOccurred())
res, err := auth.GetAuthURL(input, imageRef)
Expect(err).NotTo(HaveOccurred())
@ -122,7 +118,7 @@ var _ = Describe("the auth module", func() {
})
It("should not crash when a field without a value is received", func() {
input := `bearer realm="https://ghcr.io/token",service="ghcr.io",scope="repository:user/image:pull",valuelesskey`
imageRef, err := ref.ParseNormalizedNamed("containrrr/watchtower")
imageRef, err := ref.ParseNormalizedNamed("nicholas-fedor/watchtower")
Expect(err).NotTo(HaveOccurred())
res, err := auth.GetAuthURL(input, imageRef)
Expect(err).NotTo(HaveOccurred())
@ -133,17 +129,17 @@ var _ = Describe("the auth module", func() {
Describe("GetChallengeURL", func() {
It("should create a valid challenge url object based on the image ref supplied", func() {
expected := url.URL{Host: "ghcr.io", Scheme: "https", Path: "/v2/"}
imageRef, _ := ref.ParseNormalizedNamed("ghcr.io/containrrr/watchtower:latest")
imageRef, _ := ref.ParseNormalizedNamed("ghcr.io/nicholas-fedor/watchtower:latest")
Expect(auth.GetChallengeURL(imageRef)).To(Equal(expected))
})
It("should assume Docker Hub for image refs with no explicit registry", func() {
expected := url.URL{Host: "index.docker.io", Scheme: "https", Path: "/v2/"}
imageRef, _ := ref.ParseNormalizedNamed("containrrr/watchtower:latest")
imageRef, _ := ref.ParseNormalizedNamed("nickfedor/watchtower:latest")
Expect(auth.GetChallengeURL(imageRef)).To(Equal(expected))
})
It("should use index.docker.io if the image ref specifies docker.io", func() {
expected := url.URL{Host: "index.docker.io", Scheme: "https", Path: "/v2/"}
imageRef, _ := ref.ParseNormalizedNamed("docker.io/containrrr/watchtower:latest")
imageRef, _ := ref.ParseNormalizedNamed("docker.io/nickfedor/watchtower:latest")
Expect(auth.GetChallengeURL(imageRef)).To(Equal(expected))
})
})

View file

@ -11,10 +11,10 @@ import (
"strings"
"time"
"github.com/containrrr/watchtower/internal/meta"
"github.com/containrrr/watchtower/pkg/registry/auth"
"github.com/containrrr/watchtower/pkg/registry/manifest"
"github.com/containrrr/watchtower/pkg/types"
"github.com/nicholas-fedor/watchtower/internal/meta"
"github.com/nicholas-fedor/watchtower/pkg/registry/auth"
"github.com/nicholas-fedor/watchtower/pkg/registry/manifest"
"github.com/nicholas-fedor/watchtower/pkg/types"
"github.com/sirupsen/logrus"
)

View file

@ -2,9 +2,9 @@ package digest_test
import (
"fmt"
"github.com/containrrr/watchtower/internal/actions/mocks"
"github.com/containrrr/watchtower/pkg/registry/digest"
wtTypes "github.com/containrrr/watchtower/pkg/types"
"github.com/nicholas-fedor/watchtower/internal/actions/mocks"
"github.com/nicholas-fedor/watchtower/pkg/registry/digest"
wtTypes "github.com/nicholas-fedor/watchtower/pkg/types"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/ghttp"

View file

@ -1,7 +1,7 @@
package helpers
import (
"github.com/docker/distribution/reference"
"github.com/distribution/reference"
)
// domains for Docker Hub, the default registry

View file

@ -20,18 +20,18 @@ var _ = Describe("the helpers", func() {
})
It("should return index.docker.io for image refs with no explicit registry", func() {
Expect(GetRegistryAddress("watchtower")).To(Equal("index.docker.io"))
Expect(GetRegistryAddress("containrrr/watchtower")).To(Equal("index.docker.io"))
Expect(GetRegistryAddress("nickfedor/watchtower")).To(Equal("index.docker.io"))
})
It("should return index.docker.io for image refs with docker.io domain", func() {
Expect(GetRegistryAddress("docker.io/watchtower")).To(Equal("index.docker.io"))
Expect(GetRegistryAddress("docker.io/containrrr/watchtower")).To(Equal("index.docker.io"))
Expect(GetRegistryAddress("docker.io/nickfedor/watchtower")).To(Equal("index.docker.io"))
})
It("should return the host if passed an image name containing a local host", func() {
Expect(GetRegistryAddress("henk:80/watchtower")).To(Equal("henk:80"))
Expect(GetRegistryAddress("localhost/watchtower")).To(Equal("localhost"))
})
It("should return the server address if passed a fully qualified image name", func() {
Expect(GetRegistryAddress("github.com/containrrr/config")).To(Equal("github.com"))
Expect(GetRegistryAddress("github.com/nicholas-fedor/config")).To(Equal("github.com"))
})
})
})

View file

@ -5,9 +5,9 @@ import (
"fmt"
url2 "net/url"
"github.com/containrrr/watchtower/pkg/registry/helpers"
"github.com/containrrr/watchtower/pkg/types"
ref "github.com/docker/distribution/reference"
"github.com/nicholas-fedor/watchtower/pkg/registry/helpers"
"github.com/nicholas-fedor/watchtower/pkg/types"
ref "github.com/distribution/reference"
"github.com/sirupsen/logrus"
)

View file

@ -4,9 +4,9 @@ import (
"testing"
"time"
"github.com/containrrr/watchtower/internal/actions/mocks"
"github.com/containrrr/watchtower/pkg/registry/manifest"
apiTypes "github.com/docker/docker/api/types"
"github.com/nicholas-fedor/watchtower/internal/actions/mocks"
"github.com/nicholas-fedor/watchtower/pkg/registry/manifest"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@ -19,24 +19,24 @@ func TestManifest(t *testing.T) {
var _ = Describe("the manifest module", func() {
Describe("BuildManifestURL", func() {
It("should return a valid url given a fully qualified image", func() {
imageRef := "ghcr.io/containrrr/watchtower:mytag"
expected := "https://ghcr.io/v2/containrrr/watchtower/manifests/mytag"
imageRef := "ghcr.io/nicholas-fedor/watchtower:mytag"
expected := "https://ghcr.io/v2/nicholas-fedor/watchtower/manifests/mytag"
URL, err := buildMockContainerManifestURL(imageRef)
Expect(err).NotTo(HaveOccurred())
Expect(URL).To(Equal(expected))
})
It("should assume Docker Hub for image refs with no explicit registry", func() {
imageRef := "containrrr/watchtower:latest"
expected := "https://index.docker.io/v2/containrrr/watchtower/manifests/latest"
imageRef := "nickfedor/watchtower:latest"
expected := "https://index.docker.io/v2/nickfedor/watchtower/manifests/latest"
URL, err := buildMockContainerManifestURL(imageRef)
Expect(err).NotTo(HaveOccurred())
Expect(URL).To(Equal(expected))
})
It("should assume latest for image refs with no explicit tag", func() {
imageRef := "containrrr/watchtower"
expected := "https://index.docker.io/v2/containrrr/watchtower/manifests/latest"
imageRef := "nickfedor/watchtower"
expected := "https://index.docker.io/v2/nickfedor/watchtower/manifests/latest"
URL, err := buildMockContainerManifestURL(imageRef)
Expect(err).NotTo(HaveOccurred())

View file

@ -1,29 +1,31 @@
package registry
import (
"github.com/containrrr/watchtower/pkg/registry/helpers"
watchtowerTypes "github.com/containrrr/watchtower/pkg/types"
ref "github.com/docker/distribution/reference"
"github.com/docker/docker/api/types"
"context"
ref "github.com/distribution/reference"
"github.com/docker/docker/api/types/image"
"github.com/nicholas-fedor/watchtower/pkg/registry/helpers"
watchtowerTypes "github.com/nicholas-fedor/watchtower/pkg/types"
log "github.com/sirupsen/logrus"
)
// GetPullOptions creates a struct with all options needed for pulling images from a registry
func GetPullOptions(imageName string) (types.ImagePullOptions, error) {
func GetPullOptions(imageName string) (image.PullOptions, error) {
auth, err := EncodedAuth(imageName)
log.Debugf("Got image name: %s", imageName)
if err != nil {
return types.ImagePullOptions{}, err
return image.PullOptions{}, err
}
if auth == "" {
return types.ImagePullOptions{}, nil
return image.PullOptions{}, nil
}
// CREDENTIAL: Uncomment to log docker config auth
// log.Tracef("Got auth value: %s", auth)
return types.ImagePullOptions{
return image.PullOptions{
RegistryAuth: auth,
PrivilegeFunc: DefaultAuthHandler,
}, nil
@ -32,7 +34,7 @@ func GetPullOptions(imageName string) (types.ImagePullOptions, error) {
// DefaultAuthHandler will be invoked if an AuthConfig is rejected
// It could be used to return a new value for the "X-Registry-Auth" authentication header,
// but there's no point trying again with the same value as used in AuthConfig
func DefaultAuthHandler() (string, error) {
func DefaultAuthHandler(context.Context) (string, error) {
log.Debug("Authentication request was rejected. Trying again without authentication")
return "", nil
}

View file

@ -1,8 +1,8 @@
package registry_test
import (
"github.com/containrrr/watchtower/internal/actions/mocks"
unit "github.com/containrrr/watchtower/pkg/registry"
"github.com/nicholas-fedor/watchtower/internal/actions/mocks"
unit "github.com/nicholas-fedor/watchtower/pkg/registry"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@ -13,7 +13,7 @@ var _ = Describe("Registry", func() {
Describe("WarnOnAPIConsumption", func() {
When("Given a container with an image from ghcr.io", func() {
It("should want to warn", func() {
Expect(testContainerWithImage("ghcr.io/containrrr/watchtower")).To(BeTrue())
Expect(testContainerWithImage("ghcr.io/nicholas-fedor/watchtower")).To(BeTrue())
})
})
When("Given a container with an image implicitly from dockerhub", func() {

View file

@ -6,7 +6,7 @@ import (
"errors"
"os"
"github.com/containrrr/watchtower/pkg/registry/helpers"
"github.com/nicholas-fedor/watchtower/pkg/registry/helpers"
cliconfig "github.com/docker/cli/cli/config"
"github.com/docker/cli/cli/config/configfile"
"github.com/docker/cli/cli/config/credentials"