refactor: drop dead code and garden formatting
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
dc616fd3a0
commit
a8f30426ea
|
@ -2,14 +2,11 @@ package stack
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
abraClient "coopcloud.tech/abra/client"
|
||||
"coopcloud.tech/abra/client/convert"
|
||||
composetypes "github.com/docker/cli/cli/compose/types"
|
||||
"github.com/docker/cli/opts"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
|
@ -21,6 +18,14 @@ import (
|
|||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// Resolve image constants
|
||||
const (
|
||||
defaultNetworkDriver = "overlay"
|
||||
ResolveImageAlways = "always"
|
||||
ResolveImageChanged = "changed"
|
||||
ResolveImageNever = "never"
|
||||
)
|
||||
|
||||
type StackStatus struct {
|
||||
Services []swarm.Service
|
||||
Err error
|
||||
|
@ -36,12 +41,6 @@ func getStackServiceFilter(namespace string) filters.Args {
|
|||
return getStackFilter(namespace)
|
||||
}
|
||||
|
||||
func getStackFilterFromOpt(namespace string, opt opts.FilterOpt) filters.Args {
|
||||
filter := opt.Value()
|
||||
filter.Add("label", convert.LabelNamespace+"="+namespace)
|
||||
return filter
|
||||
}
|
||||
|
||||
func getAllStacksFilter() filters.Args {
|
||||
filter := filters.NewArgs()
|
||||
filter.Add("label", convert.LabelNamespace)
|
||||
|
@ -93,21 +92,6 @@ func GetAllDeployedServices(contextName string) StackStatus {
|
|||
return StackStatus{services, nil}
|
||||
}
|
||||
|
||||
// validateStackName checks if the provided string is a valid stack name (namespace).
|
||||
// It currently only does a rudimentary check if the string is empty, or consists
|
||||
// of only whitespace and quoting characters.
|
||||
func validateStackName(namespace string) error {
|
||||
v := strings.TrimFunc(namespace, quotesOrWhitespace)
|
||||
if v == "" {
|
||||
return fmt.Errorf("invalid stack name: %q", namespace)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func quotesOrWhitespace(r rune) bool {
|
||||
return unicode.IsSpace(r) || r == '"' || r == '\''
|
||||
}
|
||||
|
||||
// pruneServices removes services that are no longer referenced in the source
|
||||
func pruneServices(ctx context.Context, cl *dockerclient.Client, namespace convert.Namespace, services map[string]struct{}) {
|
||||
oldServices, err := getStackServices(ctx, cl, namespace.Name())
|
||||
|
@ -124,14 +108,6 @@ func pruneServices(ctx context.Context, cl *dockerclient.Client, namespace conve
|
|||
removeServices(ctx, cl, pruneServices)
|
||||
}
|
||||
|
||||
// Resolve image constants
|
||||
const (
|
||||
defaultNetworkDriver = "overlay"
|
||||
ResolveImageAlways = "always"
|
||||
ResolveImageChanged = "changed"
|
||||
ResolveImageNever = "never"
|
||||
)
|
||||
|
||||
// RunDeploy is the swarm implementation of docker stack deploy
|
||||
func RunDeploy(cl *dockerclient.Client, opts Deploy, cfg *composetypes.Config) error {
|
||||
ctx := context.Background()
|
||||
|
@ -307,8 +283,13 @@ func createNetworks(ctx context.Context, cl *dockerclient.Client, namespace conv
|
|||
return nil
|
||||
}
|
||||
|
||||
// nolint: gocyclo
|
||||
func deployServices(ctx context.Context, cl *dockerclient.Client, services map[string]swarm.ServiceSpec, namespace convert.Namespace, sendAuth bool, resolveImage string) error {
|
||||
func deployServices(
|
||||
ctx context.Context,
|
||||
cl *dockerclient.Client,
|
||||
services map[string]swarm.ServiceSpec,
|
||||
namespace convert.Namespace,
|
||||
sendAuth bool,
|
||||
resolveImage string) error {
|
||||
existingServices, err := getStackServices(ctx, cl, namespace.Name())
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue