From 049811fef0436cd4c5808a983d7626fe9dd636d3 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 30 Mar 2022 19:05:21 +0200 Subject: [PATCH] cli/command/context: remove newContextMetadata() utility Inlining what it does Signed-off-by: Sebastiaan van Stijn --- cli/command/context/create.go | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/cli/command/context/create.go b/cli/command/context/create.go index 794a8a7227..647295e308 100644 --- a/cli/command/context/create.go +++ b/cli/command/context/create.go @@ -92,17 +92,24 @@ func createNewContext(o *CreateOptions, cli command.Cli, s store.Writer) error { if o.Docker == nil { return errors.New("docker endpoint configuration is required") } - contextMetadata := newContextMetadata(o) - contextTLSData := store.ContextTLSData{ - Endpoints: make(map[string]store.EndpointTLSData), - } dockerEP, dockerTLS, err := getDockerEndpointMetadataAndTLS(cli, o.Docker) if err != nil { return errors.Wrap(err, "unable to create docker endpoint config") } - contextMetadata.Endpoints[docker.DockerEndpoint] = dockerEP + contextMetadata := store.Metadata{ + Endpoints: map[string]interface{}{ + docker.DockerEndpoint: dockerEP, + }, + Metadata: command.DockerContext{ + Description: o.Description, + }, + Name: o.Name, + } + contextTLSData := store.ContextTLSData{} if dockerTLS != nil { - contextTLSData.Endpoints[docker.DockerEndpoint] = *dockerTLS + contextTLSData.Endpoints = map[string]store.EndpointTLSData{ + docker.DockerEndpoint: *dockerTLS, + } } if err := validateEndpoints(contextMetadata); err != nil { return err @@ -161,13 +168,3 @@ func (d *descriptionDecorator) GetMetadata(name string) (store.Metadata, error) c.Metadata = typedContext return c, nil } - -func newContextMetadata(o *CreateOptions) store.Metadata { - return store.Metadata{ - Endpoints: make(map[string]interface{}), - Metadata: command.DockerContext{ - Description: o.Description, - }, - Name: o.Name, - } -}