chore(deps): update go version to 1.18 (#1363)

Co-authored-by: nils måsén <nils@piksel.se>
This commit is contained in:
Jauder Ho 2022-09-04 04:56:29 -07:00 committed by GitHub
parent 964879d228
commit e04a107694
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 60 additions and 334 deletions

View file

@ -4,14 +4,15 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/containrrr/watchtower/pkg/registry/helpers"
"github.com/containrrr/watchtower/pkg/types"
"github.com/docker/distribution/reference"
"github.com/sirupsen/logrus"
"io/ioutil"
"net/http"
"net/url"
"strings"
"github.com/containrrr/watchtower/pkg/registry/helpers"
"github.com/containrrr/watchtower/pkg/types"
"github.com/docker/distribution/reference"
"github.com/sirupsen/logrus"
)
// ChallengeHeader is the HTTP Header containing challenge instructions
@ -54,7 +55,7 @@ func GetToken(container types.Container, registryAuth string) (string, error) {
return fmt.Sprintf("Basic %s", registryAuth), nil
}
if strings.HasPrefix(challenge, "bearer") {
return GetBearerHeader(challenge, container.ImageName(), err, registryAuth)
return GetBearerHeader(challenge, container.ImageName(), registryAuth)
}
return "", errors.New("unsupported challenge type from registry")
@ -72,7 +73,7 @@ func GetChallengeRequest(URL url.URL) (*http.Request, error) {
}
// GetBearerHeader tries to fetch a bearer token from the registry based on the challenge instructions
func GetBearerHeader(challenge string, img string, err error, registryAuth string) (string, error) {
func GetBearerHeader(challenge string, img string, registryAuth string) (string, error) {
client := http.Client{}
if strings.Contains(img, ":") {
img = strings.Split(img, ":")[0]
@ -136,7 +137,7 @@ func GetAuthURL(challenge string, img string) (*url.URL, error) {
return nil, fmt.Errorf("challenge header did not include all values needed to construct an auth url")
}
authURL, _ := url.Parse(fmt.Sprintf("%s", values["realm"]))
authURL, _ := url.Parse(values["realm"])
q := authURL.Query()
q.Add("service", values["service"])

View file

@ -41,7 +41,7 @@ func EncodedEnvAuth(ref string) (string, error) {
log.Tracef("Using auth password %s", auth.Password)
return EncodeAuth(auth)
}
return "", errors.New("Registry auth environment variables (REPO_USER, REPO_PASS) not set")
return "", errors.New("registry auth environment variables (REPO_USER, REPO_PASS) not set")
}
// EncodedConfigAuth returns an encoded auth config for the given registry