mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-13 21:56:38 +01:00
chore(deps): update go version to 1.18 (#1363)
Co-authored-by: nils måsén <nils@piksel.se>
This commit is contained in:
parent
964879d228
commit
e04a107694
10 changed files with 60 additions and 334 deletions
|
|
@ -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"])
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue