Skip to content

Commit aa75635

Browse files
authored
Merge pull request #3139 from ndeloof/drop_kubernetes_support
Drop support for (archived) Compose-on-Kubernetes
2 parents cf8c4ba + 013a74f commit aa75635

1,432 files changed

Lines changed: 249 additions & 423717 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.golangci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ linters:
2828

2929
run:
3030
timeout: 5m
31-
skip-dirs:
32-
- cli/command/stack/kubernetes/api/openapi
33-
- cli/command/stack/kubernetes/api/client
3431
skip-files:
3532
- cli/compose/schema/bindata.go
3633
- .*generated.*

cli/command/cli.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ type Cli interface {
6060
ContentTrustEnabled() bool
6161
ContextStore() store.Store
6262
CurrentContext() string
63-
StackOrchestrator(flagValue string) (Orchestrator, error)
6463
DockerEndpoint() docker.Endpoint
6564
}
6665

@@ -367,25 +366,6 @@ func (cli *DockerCli) CurrentContext() string {
367366
return cli.currentContext
368367
}
369368

370-
// StackOrchestrator resolves which stack orchestrator is in use
371-
func (cli *DockerCli) StackOrchestrator(flagValue string) (Orchestrator, error) {
372-
currentContext := cli.CurrentContext()
373-
ctxRaw, err := cli.ContextStore().GetMetadata(currentContext)
374-
if store.IsErrContextDoesNotExist(err) {
375-
// case where the currentContext has been removed (CLI behavior is to fallback to using DOCKER_HOST based resolution)
376-
return GetStackOrchestrator(flagValue, "", cli.ConfigFile().StackOrchestrator, cli.Err())
377-
}
378-
if err != nil {
379-
return "", err
380-
}
381-
ctxMeta, err := GetDockerContext(ctxRaw)
382-
if err != nil {
383-
return "", err
384-
}
385-
ctxOrchestrator := string(ctxMeta.StackOrchestrator)
386-
return GetStackOrchestrator(flagValue, ctxOrchestrator, cli.ConfigFile().StackOrchestrator, cli.Err())
387-
}
388-
389369
// DockerEndpoint returns the current docker endpoint
390370
func (cli *DockerCli) DockerEndpoint() docker.Endpoint {
391371
return cli.dockerEndpoint

cli/command/context.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ import (
99

1010
// DockerContext is a typed representation of what we put in Context metadata
1111
type DockerContext struct {
12-
Description string
13-
StackOrchestrator Orchestrator
14-
AdditionalFields map[string]interface{}
12+
Description string
13+
AdditionalFields map[string]interface{}
1514
}
1615

1716
// MarshalJSON implements custom JSON marshalling
@@ -20,9 +19,6 @@ func (dc DockerContext) MarshalJSON() ([]byte, error) {
2019
if dc.Description != "" {
2120
s["Description"] = dc.Description
2221
}
23-
if dc.StackOrchestrator != "" {
24-
s["StackOrchestrator"] = dc.StackOrchestrator
25-
}
2622
if dc.AdditionalFields != nil {
2723
for k, v := range dc.AdditionalFields {
2824
s[k] = v
@@ -41,8 +37,6 @@ func (dc *DockerContext) UnmarshalJSON(payload []byte) error {
4137
switch k {
4238
case "Description":
4339
dc.Description = v.(string)
44-
case "StackOrchestrator":
45-
dc.StackOrchestrator = Orchestrator(v.(string))
4640
default:
4741
if dc.AdditionalFields == nil {
4842
dc.AdditionalFields = make(map[string]interface{})

cli/command/context/create.go

Lines changed: 27 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,22 @@ import (
88
"github.com/docker/cli/cli"
99
"github.com/docker/cli/cli/command"
1010
"github.com/docker/cli/cli/context/docker"
11-
"github.com/docker/cli/cli/context/kubernetes"
1211
"github.com/docker/cli/cli/context/store"
1312
"github.com/pkg/errors"
1413
"github.com/spf13/cobra"
1514
)
1615

1716
// CreateOptions are the options used for creating a context
1817
type CreateOptions struct {
19-
Name string
20-
Description string
18+
Name string
19+
Description string
20+
Docker map[string]string
21+
From string
22+
23+
// Deprecated
2124
DefaultStackOrchestrator string
22-
Docker map[string]string
23-
Kubernetes map[string]string
24-
From string
25+
// Deprecated
26+
Kubernetes map[string]string
2527
}
2628

2729
func longCreateDescription() string {
@@ -33,13 +35,6 @@ func longCreateDescription() string {
3335
fmt.Fprintf(tw, "%s\t%s\n", d.name, d.description)
3436
}
3537
tw.Flush()
36-
buf.WriteString("\nKubernetes endpoint config:\n\n")
37-
tw = tabwriter.NewWriter(buf, 20, 1, 3, ' ', 0)
38-
fmt.Fprintln(tw, "NAME\tDESCRIPTION")
39-
for _, d := range kubernetesConfigKeysDescriptions {
40-
fmt.Fprintf(tw, "%s\t%s\n", d.name, d.description)
41-
}
42-
tw.Flush()
4338
buf.WriteString("\nExample:\n\n$ docker context create my-context --description \"some description\" --docker \"host=tcp://myserver:2376,ca=~/ca-file,cert=~/cert-file,key=~/key-file\"\n")
4439
return buf.String()
4540
}
@@ -63,31 +58,30 @@ func newCreateCommand(dockerCli command.Cli) *cobra.Command {
6358
"default-stack-orchestrator", "",
6459
"Default orchestrator for stack operations to use with this context (swarm|kubernetes|all)")
6560
flags.SetAnnotation("default-stack-orchestrator", "deprecated", nil)
61+
flags.MarkDeprecated("default-stack-orchestrator", "option will be ignored")
6662
flags.StringToStringVar(&opts.Docker, "docker", nil, "set the docker endpoint")
6763
flags.StringToStringVar(&opts.Kubernetes, "kubernetes", nil, "set the kubernetes endpoint")
6864
flags.SetAnnotation("kubernetes", "kubernetes", nil)
6965
flags.SetAnnotation("kubernetes", "deprecated", nil)
66+
flags.MarkDeprecated("kubernetes", "option will be ignored")
7067
flags.StringVar(&opts.From, "from", "", "create context from a named context")
7168
return cmd
7269
}
7370

7471
// RunCreate creates a Docker context
7572
func RunCreate(cli command.Cli, o *CreateOptions) error {
7673
s := cli.ContextStore()
77-
if err := checkContextNameForCreation(s, o.Name); err != nil {
78-
return err
79-
}
80-
stackOrchestrator, err := command.NormalizeOrchestrator(o.DefaultStackOrchestrator)
74+
err := checkContextNameForCreation(s, o.Name)
8175
if err != nil {
82-
return errors.Wrap(err, "unable to parse default-stack-orchestrator")
76+
return err
8377
}
8478
switch {
8579
case o.From == "" && o.Docker == nil && o.Kubernetes == nil:
86-
err = createFromExistingContext(s, cli.CurrentContext(), stackOrchestrator, o)
80+
err = createFromExistingContext(s, cli.CurrentContext(), o)
8781
case o.From != "":
88-
err = createFromExistingContext(s, o.From, stackOrchestrator, o)
82+
err = createFromExistingContext(s, o.From, o)
8983
default:
90-
err = createNewContext(o, stackOrchestrator, cli, s)
84+
err = createNewContext(o, cli, s)
9185
}
9286
if err == nil {
9387
fmt.Fprintln(cli.Out(), o.Name)
@@ -96,11 +90,11 @@ func RunCreate(cli command.Cli, o *CreateOptions) error {
9690
return err
9791
}
9892

99-
func createNewContext(o *CreateOptions, stackOrchestrator command.Orchestrator, cli command.Cli, s store.Writer) error {
93+
func createNewContext(o *CreateOptions, cli command.Cli, s store.Writer) error {
10094
if o.Docker == nil {
10195
return errors.New("docker endpoint configuration is required")
10296
}
103-
contextMetadata := newContextMetadata(stackOrchestrator, o)
97+
contextMetadata := newContextMetadata(o)
10498
contextTLSData := store.ContextTLSData{
10599
Endpoints: make(map[string]store.EndpointTLSData),
106100
}
@@ -112,22 +106,7 @@ func createNewContext(o *CreateOptions, stackOrchestrator command.Orchestrator,
112106
if dockerTLS != nil {
113107
contextTLSData.Endpoints[docker.DockerEndpoint] = *dockerTLS
114108
}
115-
if o.Kubernetes != nil {
116-
kubernetesEP, kubernetesTLS, err := getKubernetesEndpointMetadataAndTLS(cli, o.Kubernetes)
117-
if err != nil {
118-
return errors.Wrap(err, "unable to create kubernetes endpoint config")
119-
}
120-
if kubernetesEP == nil && stackOrchestrator.HasKubernetes() {
121-
return errors.Errorf("cannot specify orchestrator %q without configuring a Kubernetes endpoint", stackOrchestrator)
122-
}
123-
if kubernetesEP != nil {
124-
contextMetadata.Endpoints[kubernetes.KubernetesEndpoint] = kubernetesEP
125-
}
126-
if kubernetesTLS != nil {
127-
contextTLSData.Endpoints[kubernetes.KubernetesEndpoint] = *kubernetesTLS
128-
}
129-
}
130-
if err := validateEndpointsAndOrchestrator(contextMetadata); err != nil {
109+
if err := validateEndpoints(contextMetadata); err != nil {
131110
return err
132111
}
133112
if err := s.CreateOrUpdate(contextMetadata); err != nil {
@@ -152,26 +131,24 @@ func checkContextNameForCreation(s store.Reader, name string) error {
152131
return nil
153132
}
154133

155-
func createFromExistingContext(s store.ReaderWriter, fromContextName string, stackOrchestrator command.Orchestrator, o *CreateOptions) error {
134+
func createFromExistingContext(s store.ReaderWriter, fromContextName string, o *CreateOptions) error {
156135
if len(o.Docker) != 0 || len(o.Kubernetes) != 0 {
157136
return errors.New("cannot use --docker or --kubernetes flags when --from is set")
158137
}
159-
reader := store.Export(fromContextName, &descriptionAndOrchestratorStoreDecorator{
160-
Reader: s,
161-
description: o.Description,
162-
orchestrator: stackOrchestrator,
138+
reader := store.Export(fromContextName, &descriptionDecorator{
139+
Reader: s,
140+
description: o.Description,
163141
})
164142
defer reader.Close()
165143
return store.Import(o.Name, s, reader)
166144
}
167145

168-
type descriptionAndOrchestratorStoreDecorator struct {
146+
type descriptionDecorator struct {
169147
store.Reader
170-
description string
171-
orchestrator command.Orchestrator
148+
description string
172149
}
173150

174-
func (d *descriptionAndOrchestratorStoreDecorator) GetMetadata(name string) (store.Metadata, error) {
151+
func (d *descriptionDecorator) GetMetadata(name string) (store.Metadata, error) {
175152
c, err := d.Reader.GetMetadata(name)
176153
if err != nil {
177154
return c, err
@@ -183,19 +160,15 @@ func (d *descriptionAndOrchestratorStoreDecorator) GetMetadata(name string) (sto
183160
if d.description != "" {
184161
typedContext.Description = d.description
185162
}
186-
if d.orchestrator != command.Orchestrator("") {
187-
typedContext.StackOrchestrator = d.orchestrator
188-
}
189163
c.Metadata = typedContext
190164
return c, nil
191165
}
192166

193-
func newContextMetadata(stackOrchestrator command.Orchestrator, o *CreateOptions) store.Metadata {
167+
func newContextMetadata(o *CreateOptions) store.Metadata {
194168
return store.Metadata{
195169
Endpoints: make(map[string]interface{}),
196170
Metadata: command.DockerContext{
197-
Description: o.Description,
198-
StackOrchestrator: stackOrchestrator,
171+
Description: o.Description,
199172
},
200173
Name: o.Name,
201174
}

0 commit comments

Comments
 (0)