aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Rothberg <vrothberg@redhat.com>2022-03-18 15:18:30 +0100
committerValentin Rothberg <vrothberg@redhat.com>2022-03-23 15:49:02 +0100
commit9a77b70de3ca24c151f7329d55539078ced26516 (patch)
treec3c32c560e85c7dcf1c7a522ad72a92a00ab64b2
parent19c80199a9973be16cc7c8a5c664a18b179f0179 (diff)
downloadpodman-9a77b70de3ca24c151f7329d55539078ced26516.tar.gz
podman-9a77b70de3ca24c151f7329d55539078ced26516.tar.bz2
podman-9a77b70de3ca24c151f7329d55539078ced26516.zip
vendor c/common@v0.47.5
Update the login tests to reflect the latest changes to allow http{s} prefixes (again) to address bugzilla.redhat.com/show_bug.cgi?id=2062072. Backport of commit 57cdc21b0057. Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
-rw-r--r--go.mod2
-rw-r--r--go.sum4
-rw-r--r--test/e2e/login_logout_test.go6
-rw-r--r--vendor/github.com/containers/common/pkg/auth/auth.go50
-rw-r--r--vendor/github.com/containers/common/version/version.go2
-rw-r--r--vendor/modules.txt2
6 files changed, 31 insertions, 35 deletions
diff --git a/go.mod b/go.mod
index 79880469b..60730b4c0 100644
--- a/go.mod
+++ b/go.mod
@@ -12,7 +12,7 @@ require (
github.com/containernetworking/cni v1.0.1
github.com/containernetworking/plugins v1.0.1
github.com/containers/buildah v1.24.1
- github.com/containers/common v0.47.4
+ github.com/containers/common v0.47.5
github.com/containers/conmon v2.0.20+incompatible
github.com/containers/image/v5 v5.19.1
github.com/containers/ocicrypt v1.1.2
diff --git a/go.sum b/go.sum
index b291e068e..005950c81 100644
--- a/go.sum
+++ b/go.sum
@@ -326,8 +326,8 @@ github.com/containernetworking/plugins v1.0.1/go.mod h1:QHCfGpaTwYTbbH+nZXKVTxNB
github.com/containers/buildah v1.24.1 h1:PlvU0hbUsm1x4H9kPcsmqjViqDGnBpSZT3QtZ00RtgI=
github.com/containers/buildah v1.24.1/go.mod h1:sE7AaoPQYwAB7dleOOKOpzOO3bA8lRUvZRiZcn/RYi0=
github.com/containers/common v0.47.3/go.mod h1:/VAV4ibC27Lfyb9cxXM4uTYrJFa/7s+utNB052MJdzY=
-github.com/containers/common v0.47.4 h1:kS202Z/bTQIM/pwyuJ+lF8143Uli6AB9Q9OVR0xa9CM=
-github.com/containers/common v0.47.4/go.mod h1:HgX0mFXyB0Tbe2REEIp9x9CxET6iSzmHfwR6S/t2LZc=
+github.com/containers/common v0.47.5 h1:Qm9o+wVPO9sbggTKubN3xYMtPRaPv7dmcrJQgongHHw=
+github.com/containers/common v0.47.5/go.mod h1:HgX0mFXyB0Tbe2REEIp9x9CxET6iSzmHfwR6S/t2LZc=
github.com/containers/conmon v2.0.20+incompatible h1:YbCVSFSCqFjjVwHTPINGdMX1F6JXHGTUje2ZYobNrkg=
github.com/containers/conmon v2.0.20+incompatible/go.mod h1:hgwZ2mtuDrppv78a/cOBNiCm6O0UMWGx1mu7P00nu5I=
github.com/containers/image/v5 v5.19.1 h1:g4/+XIuh1kRoRn2MfLDhfHhkNOIO9JtqhSyo55tjpfE=
diff --git a/test/e2e/login_logout_test.go b/test/e2e/login_logout_test.go
index 1280b3e83..77549a9a8 100644
--- a/test/e2e/login_logout_test.go
+++ b/test/e2e/login_logout_test.go
@@ -417,12 +417,12 @@ var _ = Describe("Podman login and logout", func() {
Expect(authInfo).NotTo(HaveKey(testRepos[1]))
})
- It("podman login with repository invalid arguments", func() {
+ It("podman login with http{s} prefix", func() {
authFile := filepath.Join(podmanTest.TempDir, "auth.json")
for _, invalidArg := range []string{
"https://" + server + "/podmantest",
- server + "/podmantest/image:latest",
+ "http://" + server + "/podmantest/image:latest",
} {
session := podmanTest.Podman([]string{
"login",
@@ -432,7 +432,7 @@ var _ = Describe("Podman login and logout", func() {
invalidArg,
})
session.WaitWithDefaultTimeout()
- Expect(session).Should(ExitWithError())
+ Expect(session).To(Exit(0))
}
})
diff --git a/vendor/github.com/containers/common/pkg/auth/auth.go b/vendor/github.com/containers/common/pkg/auth/auth.go
index af3c8f803..6765c9e5b 100644
--- a/vendor/github.com/containers/common/pkg/auth/auth.go
+++ b/vendor/github.com/containers/common/pkg/auth/auth.go
@@ -4,6 +4,7 @@ import (
"bufio"
"context"
"fmt"
+ "net/url"
"os"
"path/filepath"
"strings"
@@ -165,20 +166,21 @@ func Login(ctx context.Context, systemContext *types.SystemContext, opts *LoginO
// parseCredentialsKey turns the provided argument into a valid credential key
// and computes the registry part.
func parseCredentialsKey(arg string, acceptRepositories bool) (key, registry string, err error) {
- if !acceptRepositories {
- registry = getRegistryName(arg)
- key = registry
- return key, registry, nil
+ // URL arguments are replaced with their host[:port] parts.
+ key, err = replaceURLByHostPort(arg)
+ if err != nil {
+ return "", "", err
}
- key = trimScheme(arg)
- if key != arg {
- return "", "", errors.New("credentials key has https[s]:// prefix")
+ split := strings.Split(key, "/")
+ registry = split[0]
+
+ if !acceptRepositories {
+ return registry, registry, nil
}
- registry = getRegistryName(key)
+ // Return early if the key isn't namespaced or uses an http{s} prefix.
if registry == key {
- // The key is not namespaced
return key, registry, nil
}
@@ -202,24 +204,18 @@ func parseCredentialsKey(arg string, acceptRepositories bool) (key, registry str
return key, registry, nil
}
-// getRegistryName scrubs and parses the input to get the server name
-func getRegistryName(server string) string {
- // removes 'http://' or 'https://' from the front of the
- // server/registry string if either is there. This will be mostly used
- // for user input from 'Buildah login' and 'Buildah logout'.
- server = trimScheme(server)
- // gets the registry from the input. If the input is of the form
- // quay.io/myuser/myimage, it will parse it and just return quay.io
- split := strings.Split(server, "/")
- return split[0]
-}
-
-// trimScheme removes the HTTP(s) scheme from the provided repository.
-func trimScheme(repository string) string {
- // removes 'http://' or 'https://' from the front of the
- // server/registry string if either is there. This will be mostly used
- // for user input from 'Buildah login' and 'Buildah logout'.
- return strings.TrimPrefix(strings.TrimPrefix(repository, "https://"), "http://")
+// If the specified string starts with http{s} it is replaced with it's
+// host[:port] parts; everything else is stripped. Otherwise, the string is
+// returned as is.
+func replaceURLByHostPort(repository string) (string, error) {
+ if !strings.HasPrefix(repository, "https://") && !strings.HasPrefix(repository, "http://") {
+ return repository, nil
+ }
+ u, err := url.Parse(repository)
+ if err != nil {
+ return "", fmt.Errorf("trimming http{s} prefix: %v", err)
+ }
+ return u.Host, nil
}
// getUserAndPass gets the username and password from STDIN if not given
diff --git a/vendor/github.com/containers/common/version/version.go b/vendor/github.com/containers/common/version/version.go
index eac64b077..2088e9552 100644
--- a/vendor/github.com/containers/common/version/version.go
+++ b/vendor/github.com/containers/common/version/version.go
@@ -1,4 +1,4 @@
package version
// Version is the version of the build.
-const Version = "0.47.4"
+const Version = "0.47.5"
diff --git a/vendor/modules.txt b/vendor/modules.txt
index f6042a041..af990cab3 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -109,7 +109,7 @@ github.com/containers/buildah/pkg/rusage
github.com/containers/buildah/pkg/sshagent
github.com/containers/buildah/pkg/util
github.com/containers/buildah/util
-# github.com/containers/common v0.47.4
+# github.com/containers/common v0.47.5
## explicit
github.com/containers/common/libimage
github.com/containers/common/libimage/manifests