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))
})
})