chore(deps): bump go/stdlib to v1.23.x and update go modules

- Upgraded `go.mod` to use Go 1.23 and updated module dependencies to latest versions
- Refactored code to align with API changes in Docker and related modules:
  - Updated `ContainerListOptions` to `container.ListOptions` and related structs
  - Replaced `types.ImageDeleteResponseItem` with `image.DeleteResponse` for compatibility
  - Modified `ImagePullOptions` and `ContainerRemoveOptions` to updated package paths
This commit is contained in:
nemezo 2024-10-31 14:27:34 +01:00
parent 76f9cea516
commit e0cbe337d7
No known key found for this signature in database
GPG key ID: FC41783B3CB4CCE8
9 changed files with 216 additions and 169 deletions

View file

@ -1,38 +1,37 @@
package registry
import (
"context"
"github.com/containrrr/watchtower/pkg/registry/helpers"
watchtowerTypes "github.com/containrrr/watchtower/pkg/types"
ref "github.com/distribution/reference"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/image"
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
}
// 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(ctx context.Context) (string, error) {
log.Debug("Authentication request was rejected. Trying again without authentication")
return "", nil
}