forked from toolshed/abra
		
	| @ -10,7 +10,6 @@ import ( | ||||
| 	loader "coopcloud.tech/abra/client/stack" | ||||
| 	stack "coopcloud.tech/abra/client/stack" | ||||
| 	"coopcloud.tech/abra/config" | ||||
| 	"github.com/docker/cli/cli/command/stack/options" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
| @ -56,7 +55,7 @@ var appDeployCommand = &cli.Command{ | ||||
| 		} | ||||
| 		appEnv.Env["STACK_NAME"] = appEnv.StackName() | ||||
|  | ||||
| 		deployOpts := options.Deploy{ | ||||
| 		deployOpts := stack.Deploy{ | ||||
| 			Composefiles: composeFiles, | ||||
| 			Namespace:    appEnv.StackName(), | ||||
| 			Prune:        false, | ||||
|  | ||||
| @ -8,7 +8,6 @@ import ( | ||||
| 	"coopcloud.tech/abra/client" | ||||
| 	stack "coopcloud.tech/abra/client/stack" | ||||
| 	"coopcloud.tech/abra/config" | ||||
| 	"github.com/docker/cli/cli/command/stack/options" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
| @ -39,7 +38,7 @@ var appUndeployCommand = &cli.Command{ | ||||
| 			logrus.Fatal(err) | ||||
| 		} | ||||
|  | ||||
| 		rmOpts := options.Remove{Namespaces: []string{appEnv.StackName()}} | ||||
| 		rmOpts := stack.Remove{Namespaces: []string{appEnv.StackName()}} | ||||
| 		if err := stack.RunRemove(ctx, cl, rmOpts); err != nil { | ||||
| 			logrus.Fatal(err) | ||||
| 		} | ||||
|  | ||||
| @ -7,7 +7,6 @@ import ( | ||||
| 	"sort" | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/docker/cli/cli/command/stack/options" | ||||
| 	"github.com/docker/cli/cli/compose/loader" | ||||
| 	"github.com/docker/cli/cli/compose/schema" | ||||
| 	composetypes "github.com/docker/cli/cli/compose/types" | ||||
| @ -15,7 +14,7 @@ import ( | ||||
| ) | ||||
|  | ||||
| // LoadComposefile parse the composefile specified in the cli and returns its Config and version. | ||||
| func LoadComposefile(opts options.Deploy, appEnv map[string]string) (*composetypes.Config, error) { | ||||
| func LoadComposefile(opts Deploy, appEnv map[string]string) (*composetypes.Config, error) { | ||||
| 	configDetails, err := getConfigDetails(opts.Composefiles, appEnv) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
|  | ||||
							
								
								
									
										15
									
								
								client/stack/options.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								client/stack/options.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,15 @@ | ||||
| package stack | ||||
|  | ||||
| // Deploy holds docker stack deploy options | ||||
| type Deploy struct { | ||||
| 	Composefiles     []string | ||||
| 	Namespace        string | ||||
| 	ResolveImage     string | ||||
| 	SendRegistryAuth bool | ||||
| 	Prune            bool | ||||
| } | ||||
|  | ||||
| // Remove holds docker stack remove options | ||||
| type Remove struct { | ||||
| 	Namespaces []string | ||||
| } | ||||
| @ -6,7 +6,6 @@ import ( | ||||
| 	"sort" | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/docker/cli/cli/command/stack/options" | ||||
| 	"github.com/docker/docker/api/types" | ||||
| 	"github.com/docker/docker/api/types/swarm" | ||||
| 	"github.com/docker/docker/api/types/versions" | ||||
| @ -16,7 +15,7 @@ import ( | ||||
| ) | ||||
|  | ||||
| // RunRemove is the swarm implementation of docker stack remove | ||||
| func RunRemove(ctx context.Context, client *apiclient.Client, opts options.Remove) error { | ||||
| func RunRemove(ctx context.Context, client *apiclient.Client, opts Remove) error { | ||||
| 	var errs []string | ||||
| 	for _, namespace := range opts.Namespaces { | ||||
| 		services, err := getStackServices(ctx, client, namespace) | ||||
|  | ||||
| @ -7,8 +7,7 @@ import ( | ||||
| 	"unicode" | ||||
|  | ||||
| 	abraClient "coopcloud.tech/abra/client" | ||||
| 	"github.com/docker/cli/cli/command/stack/options" | ||||
| 	"github.com/docker/cli/cli/compose/convert" | ||||
| 	"coopcloud.tech/abra/client/convert" | ||||
| 	composetypes "github.com/docker/cli/cli/compose/types" | ||||
| 	"github.com/docker/cli/opts" | ||||
| 	"github.com/docker/docker/api/types" | ||||
| @ -161,7 +160,7 @@ const ( | ||||
| ) | ||||
|  | ||||
| // RunDeploy is the swarm implementation of docker stack deploy | ||||
| func RunDeploy(cl *apiclient.Client, opts options.Deploy, cfg *composetypes.Config) error { | ||||
| func RunDeploy(cl *apiclient.Client, opts Deploy, cfg *composetypes.Config) error { | ||||
| 	ctx := context.Background() | ||||
|  | ||||
| 	if err := validateResolveImageFlag(&opts); err != nil { | ||||
| @ -177,7 +176,7 @@ func RunDeploy(cl *apiclient.Client, opts options.Deploy, cfg *composetypes.Conf | ||||
| } | ||||
|  | ||||
| // validateResolveImageFlag validates the opts.resolveImage command line option | ||||
| func validateResolveImageFlag(opts *options.Deploy) error { | ||||
| func validateResolveImageFlag(opts *Deploy) error { | ||||
| 	switch opts.ResolveImage { | ||||
| 	case ResolveImageAlways, ResolveImageChanged, ResolveImageNever: | ||||
| 		return nil | ||||
| @ -186,7 +185,7 @@ func validateResolveImageFlag(opts *options.Deploy) error { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func deployCompose(ctx context.Context, cl *apiclient.Client, opts options.Deploy, config *composetypes.Config) error { | ||||
| func deployCompose(ctx context.Context, cl *apiclient.Client, opts Deploy, config *composetypes.Config) error { | ||||
| 	if err := checkDaemonIsSwarmManagerViaClient(ctx, cl); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| @ -10,9 +10,8 @@ import ( | ||||
| 	"strings" | ||||
|  | ||||
| 	"coopcloud.tech/abra/client/convert" | ||||
| 	"coopcloud.tech/abra/client/stack" | ||||
| 	loader "coopcloud.tech/abra/client/stack" | ||||
| 	"github.com/docker/cli/cli/command/stack/options" | ||||
| 	stack "coopcloud.tech/abra/client/stack" | ||||
| 	composetypes "github.com/docker/cli/cli/compose/types" | ||||
| 	"github.com/docker/distribution/reference" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| @ -236,7 +235,7 @@ func GetAppComposeFiles(recipe string, appEnv AppEnv) (*composetypes.Config, err | ||||
| 		return &composetypes.Config{}, err | ||||
| 	} | ||||
|  | ||||
| 	opts := options.Deploy{Composefiles: composeFiles} | ||||
| 	opts := stack.Deploy{Composefiles: composeFiles} | ||||
| 	compose, err := loader.LoadComposefile(opts, appEnv) | ||||
| 	if err != nil { | ||||
| 		return &composetypes.Config{}, err | ||||
| @ -253,7 +252,7 @@ func UpdateAppComposeTag(recipe, image, tag string, appEnv AppEnv) error { | ||||
| 	} | ||||
|  | ||||
| 	for _, composeFile := range composeFiles { | ||||
| 		opts := options.Deploy{Composefiles: []string{composeFile}} | ||||
| 		opts := stack.Deploy{Composefiles: []string{composeFile}} | ||||
| 		compose, err := loader.LoadComposefile(opts, appEnv) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| @ -306,7 +305,7 @@ func UpdateAppComposeLabel(recipe, serviceName, newLabel string, appEnv AppEnv) | ||||
| 	} | ||||
|  | ||||
| 	for _, composeFile := range composeFiles { | ||||
| 		opts := options.Deploy{Composefiles: []string{composeFile}} | ||||
| 		opts := stack.Deploy{Composefiles: []string{composeFile}} | ||||
| 		compose, err := loader.LoadComposefile(opts, appEnv) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
|  | ||||
							
								
								
									
										2
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.mod
									
									
									
									
									
								
							| @ -7,14 +7,12 @@ require ( | ||||
| 	github.com/AlecAivazis/survey/v2 v2.3.1 | ||||
| 	github.com/Autonomic-Cooperative/godotenv v1.3.1-0.20210731170023-c37c0920d1a4 | ||||
| 	github.com/containerd/containerd v1.5.5 // indirect | ||||
| 	github.com/coreos/etcd v3.3.25+incompatible // indirect | ||||
| 	github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect | ||||
| 	github.com/docker/cli v20.10.8+incompatible | ||||
| 	github.com/docker/distribution v2.7.1+incompatible | ||||
| 	github.com/docker/docker v20.10.8+incompatible | ||||
| 	github.com/docker/docker-credential-helpers v0.6.4 // indirect | ||||
| 	github.com/docker/go-units v0.4.0 | ||||
| 	github.com/docker/swarmkit v1.12.1-0.20210211175721-17d8d4e4d8bd // indirect | ||||
| 	github.com/fvbommel/sortorder v1.0.2 // indirect | ||||
| 	github.com/go-git/go-git/v5 v5.4.2 | ||||
| 	github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect | ||||
|  | ||||
							
								
								
									
										5
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								go.sum
									
									
									
									
									
								
							| @ -244,8 +244,6 @@ github.com/containers/ocicrypt v1.1.0/go.mod h1:b8AOe0YR67uU8OqfVNcznfFpAzu3rdgU | ||||
| github.com/containers/ocicrypt v1.1.1/go.mod h1:Dm55fwWm1YZAjYRaJ94z2mfZikIyIN4B0oB3dj3jFxY= | ||||
| github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= | ||||
| github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= | ||||
| github.com/coreos/etcd v3.3.25+incompatible h1:0GQEw6h3YnuOVdtwygkIfJ+Omx0tZ8/QkVyXI4LkbeY= | ||||
| github.com/coreos/etcd v3.3.25+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= | ||||
| github.com/coreos/go-iptables v0.4.5/go.mod h1:/mVI274lEDI2ns62jHCDnCyBF9Iwsmekav8Dbxlm1MU= | ||||
| github.com/coreos/go-iptables v0.5.0/go.mod h1:/mVI274lEDI2ns62jHCDnCyBF9Iwsmekav8Dbxlm1MU= | ||||
| github.com/coreos/go-oidc v2.1.0+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= | ||||
| @ -297,7 +295,6 @@ github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c/go.mod h1:CADgU4DSXK | ||||
| github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= | ||||
| github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= | ||||
| github.com/docker/go-events v0.0.0-20170721190031-9461782956ad/go.mod h1:Uw6UezgYA44ePAFQYUehOuCzmy5zmg/+nl2ZfMWGkpA= | ||||
| github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c h1:+pKlWGMw7gf6bQ+oDZB4KHQFypsfjYlq/C4rfL7D3g8= | ||||
| github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c/go.mod h1:Uw6UezgYA44ePAFQYUehOuCzmy5zmg/+nl2ZfMWGkpA= | ||||
| github.com/docker/go-metrics v0.0.0-20180209012529-399ea8c73916/go.mod h1:/u0gXw0Gay3ceNrsHubL3BtdOL2fHf93USgMTe0W5dI= | ||||
| github.com/docker/go-metrics v0.0.1 h1:AgB/0SvBxihN0X8OR4SjsblXkbMvalQ8cjmtKQ2rQV8= | ||||
| @ -308,8 +305,6 @@ github.com/docker/libtrust v0.0.0-20150114040149-fa567046d9b1/go.mod h1:cyGadeNE | ||||
| github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 h1:UhxFibDNY/bfvqU5CAUmr9zpesgbU6SWc8/B4mflAE4= | ||||
| github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE= | ||||
| github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= | ||||
| github.com/docker/swarmkit v1.12.1-0.20210211175721-17d8d4e4d8bd h1:dXzP1rNMBwmZpvCH+FsQ9lEG1mv2+uJFxGo05+Eq78k= | ||||
| github.com/docker/swarmkit v1.12.1-0.20210211175721-17d8d4e4d8bd/go.mod h1:n3Z4lIEl7g261ptkGDBcYi/3qBMDl9csaAhwi2MPejs= | ||||
| github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= | ||||
| github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= | ||||
| github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= | ||||
|  | ||||
		Reference in New Issue
	
	Block a user