Skip to content

Commit

Permalink
cli/command/context: remove newContextMetadata() utility
Browse files Browse the repository at this point in the history
Inlining what it does

Signed-off-by: Sebastiaan van Stijn <[email protected]>
  • Loading branch information
thaJeztah committed Mar 30, 2022
1 parent 72264bc commit 0e2e66d
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions cli/command/context/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,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
Expand Down Expand Up @@ -159,13 +166,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,
}
}

0 comments on commit 0e2e66d

Please sign in to comment.