feat(config): swap viper and cobra for config (#684)

This commit is contained in:
nils måsén 2020-12-21 15:17:45 +01:00 committed by GitHub
parent cbe9ab87fa
commit ff8cb884a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 229 additions and 255 deletions

View file

@ -10,6 +10,7 @@ import (
"github.com/containrrr/watchtower/pkg/registry"
"github.com/containrrr/watchtower/pkg/registry/digest"
"github.com/containrrr/watchtower/internal/flags"
t "github.com/containrrr/watchtower/pkg/types"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
@ -41,7 +42,7 @@ type Client interface {
// * DOCKER_HOST the docker-engine host to send api requests to
// * DOCKER_TLS_VERIFY whether to verify tls certificates
// * DOCKER_API_VERSION the minimum docker api version to work with
func NewClient(pullImages bool, includeStopped bool, reviveStopped bool, removeVolumes bool, includeRestarting bool) Client {
func NewClient(config *flags.WatchConfig) Client {
cli, err := sdkClient.NewClientWithOpts(sdkClient.FromEnv)
if err != nil {
@ -50,11 +51,11 @@ func NewClient(pullImages bool, includeStopped bool, reviveStopped bool, removeV
return dockerClient{
api: cli,
pullImages: pullImages,
removeVolumes: removeVolumes,
includeStopped: includeStopped,
reviveStopped: reviveStopped,
includeRestarting: includeRestarting,
pullImages: !config.NoPull,
removeVolumes: config.RemoveVolumes,
includeStopped: config.IncludeStopped,
reviveStopped: config.ReviveStopped,
includeRestarting: config.IncludeRestarting,
}
}