cli/command/context: remove newContextMetadata() utility

Inlining what it does

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-03-30 19:05:21 +02:00
parent 5ed92699f3
commit 049811fef0
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 13 additions and 16 deletions

View File

@ -92,17 +92,24 @@ func createNewContext(o *CreateOptions, cli command.Cli, s store.Writer) error {
if o.Docker == nil { if o.Docker == nil {
return errors.New("docker endpoint configuration is required") 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) dockerEP, dockerTLS, err := getDockerEndpointMetadataAndTLS(cli, o.Docker)
if err != nil { if err != nil {
return errors.Wrap(err, "unable to create docker endpoint config") 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 { if dockerTLS != nil {
contextTLSData.Endpoints[docker.DockerEndpoint] = *dockerTLS contextTLSData.Endpoints = map[string]store.EndpointTLSData{
docker.DockerEndpoint: *dockerTLS,
}
} }
if err := validateEndpoints(contextMetadata); err != nil { if err := validateEndpoints(contextMetadata); err != nil {
return err return err
@ -161,13 +168,3 @@ func (d *descriptionDecorator) GetMetadata(name string) (store.Metadata, error)
c.Metadata = typedContext c.Metadata = typedContext
return c, nil 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,
}
}