Skip to content

Commit

Permalink
Drop support for (archived) Compose-on-Kubernetes
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
  • Loading branch information
ndeloof committed Jun 16, 2021
1 parent e3ade90 commit abb4bd1
Show file tree
Hide file tree
Showing 3,623 changed files with 11 additions and 1,137,203 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
3 changes: 0 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ linters:

run:
timeout: 5m
skip-dirs:
- cli/command/stack/kubernetes/api/openapi
- cli/command/stack/kubernetes/api/client
skip-files:
- cli/compose/schema/bindata.go
- .*generated.*
Expand Down
12 changes: 1 addition & 11 deletions cli/command/stack/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
"github.com/spf13/pflag"
)

var errUnsupportedAllOrchestrator = fmt.Errorf(`no orchestrator specified: use either "kubernetes" or "swarm"`)

type commonOptions struct {
orchestrator command.Orchestrator
}
Expand Down Expand Up @@ -67,9 +65,7 @@ func NewStackCommand(dockerCli command.Cli) *cobra.Command {
newServicesCommand(dockerCli, &opts),
)
flags := cmd.PersistentFlags()
flags.String("kubeconfig", "", "Kubernetes config file")
flags.SetAnnotation("kubeconfig", "kubernetes", nil)
flags.String("orchestrator", "", "Orchestrator to use (swarm|kubernetes|all)")
flags.String("orchestrator", "", "Orchestrator to use (swarm|all)")
return cmd
}

Expand All @@ -83,9 +79,6 @@ func getOrchestrator(dockerCli command.Cli, cmd *cobra.Command) (command.Orchest

func hideOrchestrationFlags(cmd *cobra.Command, orchestrator command.Orchestrator) {
cmd.Flags().VisitAll(func(f *pflag.Flag) {
if _, ok := f.Annotations["kubernetes"]; ok && !orchestrator.HasKubernetes() {
f.Hidden = true
}
if _, ok := f.Annotations["swarm"]; ok && !orchestrator.HasSwarm() {
f.Hidden = true
}
Expand All @@ -101,9 +94,6 @@ func checkSupportedFlag(cmd *cobra.Command, orchestrator command.Orchestrator) e
if !f.Changed {
return
}
if _, ok := f.Annotations["kubernetes"]; ok && !orchestrator.HasKubernetes() {
errs = append(errs, fmt.Sprintf(`"--%s" is only supported on a Docker cli with kubernetes features enabled`, f.Name))
}
if _, ok := f.Annotations["swarm"]; ok && !orchestrator.HasSwarm() {
errs = append(errs, fmt.Sprintf(`"--%s" is only supported on a Docker cli with swarm features enabled`, f.Name))
}
Expand Down
19 changes: 0 additions & 19 deletions cli/command/stack/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import (
"fmt"
"strings"
"unicode"

"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/command/stack/kubernetes"
"github.com/spf13/pflag"
)

// validateStackName checks if the provided string is a valid stack name (namespace).
Expand All @@ -33,18 +29,3 @@ func validateStackNames(namespaces []string) error {
func quotesOrWhitespace(r rune) bool {
return unicode.IsSpace(r) || r == '"' || r == '\''
}

func runOrchestratedCommand(dockerCli command.Cli, flags *pflag.FlagSet, commonOrchestrator command.Orchestrator, swarmCmd func() error, kubernetesCmd func(*kubernetes.KubeCli) error) error {
switch {
case commonOrchestrator.HasAll():
return errUnsupportedAllOrchestrator
case commonOrchestrator.HasKubernetes():
kli, err := kubernetes.WrapCli(dockerCli, kubernetes.NewOptions(flags, commonOrchestrator))
if err != nil {
return err
}
return kubernetesCmd(kli)
default:
return swarmCmd()
}
}
6 changes: 1 addition & 5 deletions cli/command/stack/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package stack
import (
"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/loader"
"github.com/docker/cli/cli/command/stack/options"
"github.com/docker/cli/cli/command/stack/swarm"
Expand Down Expand Up @@ -45,13 +44,10 @@ func newDeployCommand(dockerCli command.Cli, common *commonOptions) *cobra.Comma
`Query the registry to resolve image digest and supported platforms ("`+swarm.ResolveImageAlways+`"|"`+swarm.ResolveImageChanged+`"|"`+swarm.ResolveImageNever+`")`)
flags.SetAnnotation("resolve-image", "version", []string{"1.30"})
flags.SetAnnotation("resolve-image", "swarm", nil)
kubernetes.AddNamespaceFlag(flags)
return cmd
}

// RunDeploy performs a stack deploy against the specified orchestrator
func RunDeploy(dockerCli command.Cli, flags *pflag.FlagSet, config *composetypes.Config, commonOrchestrator command.Orchestrator, opts options.Deploy) error {
return runOrchestratedCommand(dockerCli, flags, commonOrchestrator,
func() error { return swarm.RunDeploy(dockerCli, opts, config) },
func(kli *kubernetes.KubeCli) error { return kubernetes.RunDeploy(kli, opts, config) })
return swarm.RunDeploy(dockerCli, opts, config)
}
11 changes: 0 additions & 11 deletions cli/command/stack/formatter/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@ import (
)

const (
// KubernetesStackTableFormat is the default Kubernetes stack format
KubernetesStackTableFormat formatter.Format = "table {{.Name}}\t{{.Services}}\t{{.Orchestrator}}\t{{.Namespace}}"

// SwarmStackTableFormat is the default Swarm stack format
SwarmStackTableFormat formatter.Format = "table {{.Name}}\t{{.Services}}\t{{.Orchestrator}}"

stackServicesHeader = "SERVICES"
stackOrchestrastorHeader = "ORCHESTRATOR"
stackNamespaceHeader = "NAMESPACE"

// TableFormatKey is an alias for formatter.TableFormatKey
TableFormatKey = formatter.TableFormatKey
Expand All @@ -35,8 +31,6 @@ type Stack struct {
Services int
// Orchestrator is the platform where the stack is deployed
Orchestrator string
// Namespace is the Kubernetes namespace assigned to the stack
Namespace string
}

// StackWrite writes formatted stacks using the Context
Expand All @@ -63,7 +57,6 @@ func newStackContext() *stackContext {
"Name": formatter.NameHeader,
"Services": stackServicesHeader,
"Orchestrator": stackOrchestrastorHeader,
"Namespace": stackNamespaceHeader,
}
return &stackCtx
}
Expand All @@ -83,7 +76,3 @@ func (s *stackContext) Services() string {
func (s *stackContext) Orchestrator() string {
return s.s.Orchestrator
}

func (s *stackContext) Namespace() string {
return s.s.Namespace
}
12 changes: 2 additions & 10 deletions cli/command/stack/formatter/formatter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ func TestStackContextWrite(t *testing.T) {
`NAME SERVICES ORCHESTRATOR
baz 2 orchestrator1
bar 1 orchestrator2
`,
},
// Kubernetes table format adds Namespace column
{
formatter.Context{Format: KubernetesStackTableFormat},
`NAME SERVICES ORCHESTRATOR NAMESPACE
baz 2 orchestrator1 namespace1
bar 1 orchestrator2 namespace2
`,
},
{
Expand All @@ -57,8 +49,8 @@ bar
}

stacks := []*Stack{
{Name: "baz", Services: 2, Orchestrator: "orchestrator1", Namespace: "namespace1"},
{Name: "bar", Services: 1, Orchestrator: "orchestrator2", Namespace: "namespace2"},
{Name: "baz", Services: 2, Orchestrator: "orchestrator1"},
{Name: "bar", Services: 1, Orchestrator: "orchestrator2"},
}
for _, tc := range cases {
tc := tc
Expand Down
144 changes: 0 additions & 144 deletions cli/command/stack/kubernetes/cli.go

This file was deleted.

0 comments on commit abb4bd1

Please sign in to comment.