Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Commit

Permalink
Update docker/cli with upstream changes
Browse files Browse the repository at this point in the history
This is still depending on a fork, but with way less differents
commits (several changes have been already upstreamed) and with an
up-to-date `docker/cli`.

One big change to notice is the `enabled` becomes
`x-enabled` (using *extras* field of the composefile format), and thus
does not require any change to the composefile struct.

Signed-off-by: Vincent Demeester <[email protected]>
  • Loading branch information
vdemeester committed Jul 2, 2018
1 parent 1b51074 commit de108fd
Show file tree
Hide file tree
Showing 310 changed files with 27,468 additions and 17,022 deletions.
99 changes: 82 additions & 17 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 7 additions & 9 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
Expand Down Expand Up @@ -30,14 +29,9 @@ required = ["github.com/wadey/gocovmerge"]
name = "gopkg.in/yaml.v2"
version = "2.2.1"

[[override]]
[[constraint]]
name = "github.com/docker/cli"
branch = "master"
source = "github.com/mnottale/cli"

[[override]]
name = "github.com/spf13/pflag"
revision = "3ebe029320b2676d667ae88da602a5f854788a8a"

[[constraint]]
name = "github.com/sirupsen/logrus"
Expand All @@ -59,13 +53,17 @@ required = ["github.com/wadey/gocovmerge"]
name = "github.com/docker/go-metrics"
revision = "d466d4f6fd960e01820085bd7e1a24426ee7ef18"

[[override]]
name = "github.com/docker/docker"
revision = "c752b0991e31ba9869ab6a0661af57e9423874fb"

[[override]]
name = "github.com/docker/distribution"
revision = "edc3ab29cdff8694dd6feb85cfeb4b5f1b38ed9c"
revision = "83389a148052d74ac602f5f1d62f86ff2f3c4aa5"

[[override]]
name = "github.com/docker/swarmkit"
revision = "49a9d7f6ba3c1925262641e694c18eb43575f74b"
revision = "edd5641391926a50bc5f7040e20b7efc05003c26"

[[override]]
name = "google.golang.org/grpc"
Expand Down
43 changes: 9 additions & 34 deletions cmd/docker-app/deploy.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
package main

import (
"context"
"fmt"
"os"

"github.com/docker/app/internal"
"github.com/docker/app/internal/packager"
"github.com/docker/app/internal/renderer"
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/command/stack/kubernetes"
"github.com/docker/cli/cli/command/stack"
"github.com/docker/cli/cli/command/stack/options"
"github.com/docker/cli/cli/command/stack/swarm"
cliflags "github.com/docker/cli/cli/flags"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

type deployOptions struct {
Expand All @@ -37,7 +32,7 @@ func deployCmd(dockerCli *command.DockerCli) *cobra.Command {
Long: `Deploy the application on either Swarm or Kubernetes.`,
Args: cli.RequiresMaxArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
return runDeploy(dockerCli, firstOrEmpty(args), opts)
return runDeploy(dockerCli, cmd.Flags(), firstOrEmpty(args), opts)
},
}

Expand All @@ -53,18 +48,15 @@ func deployCmd(dockerCli *command.DockerCli) *cobra.Command {
return cmd
}

func runDeploy(dockerCli *command.DockerCli, appname string, opts deployOptions) error {
func runDeploy(dockerCli *command.DockerCli, flags *pflag.FlagSet, appname string, opts deployOptions) error {
appname, cleanup, err := packager.Extract(appname)
if err != nil {
return err
}
defer cleanup()
deployOrchestrator := opts.deployOrchestrator
if do, ok := os.LookupEnv("DOCKER_ORCHESTRATOR"); ok {
deployOrchestrator = do
}
if deployOrchestrator != "swarm" && deployOrchestrator != "kubernetes" {
return fmt.Errorf("orchestrator must be either 'swarm' or 'kubernetes'")
deployOrchestrator, err := command.GetStackOrchestrator(opts.deployOrchestrator, dockerCli.ConfigFile().StackOrchestrator, dockerCli.Err())
if err != nil {
return err
}
d, err := parseSettings(opts.deployEnv)
if err != nil {
Expand All @@ -74,28 +66,11 @@ func runDeploy(dockerCli *command.DockerCli, appname string, opts deployOptions)
if err != nil {
return err
}
dockerCli.Initialize(&cliflags.ClientOptions{
Common: &cliflags.CommonOptions{
Orchestrator: deployOrchestrator,
},
})
stackName := opts.deployStackName
if stackName == "" {
stackName = internal.AppNameFromDir(appname)
}
if deployOrchestrator == "swarm" {
ctx := context.Background()
return swarm.DeployCompose(ctx, dockerCli, rendered, options.Deploy{
Namespace: stackName,
})
}
// kube mode
kubeCli, err := kubernetes.WrapCli(dockerCli, kubernetes.Options{
Namespace: opts.deployNamespace,
Config: opts.deployKubeConfig,
return stack.RunDeploy(dockerCli, flags, rendered, deployOrchestrator, options.Deploy{
Namespace: stackName,
})
if err != nil {
return err
}
return kubernetes.DeployStack(kubeCli, options.Deploy{Namespace: stackName}, rendered)
}
Loading

0 comments on commit de108fd

Please sign in to comment.