Fix `docker context ls` that was not displaying legacy context endpoints

This commit is contained in:
Guillaume Tardif 2020-06-11 10:41:51 +02:00
parent 667cdfcbf8
commit d0b2bfbf52
3 changed files with 9 additions and 7 deletions

View File

@ -94,7 +94,7 @@ func getEndpoint(name string, meta map[string]interface{}) string {
if !ok { if !ok {
return "" return ""
} }
data, ok := endpoints.(store.Endpoint) data, ok := endpoints.(*store.Endpoint)
if !ok { if !ok {
return "" return ""
} }

View File

@ -211,12 +211,14 @@ func toTypedEndpoints(endpoints map[string]interface{}) (map[string]interface{},
return nil, err return nil, err
} }
typeGetters := getters() typeGetters := getters()
if _, ok := typeGetters[k]; !ok { typeGetter, ok := typeGetters[k];
result[k] = v if !ok {
continue typeGetter = func() interface{} {
return &Endpoint{}
}
} }
val := typeGetters[k]() val := typeGetter()
err = json.Unmarshal(bytes, &val) err = json.Unmarshal(bytes, &val)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -58,10 +58,10 @@ func dockerDefaultContext() (*DockerContext, error) {
meta := DockerContext{ meta := DockerContext{
Name: "default", Name: "default",
Endpoints: map[string]interface{}{ Endpoints: map[string]interface{}{
"docker": Endpoint{ "docker": &Endpoint{
Host: defaultCtx.Endpoints.Docker.Host, Host: defaultCtx.Endpoints.Docker.Host,
}, },
"kubernetes": Endpoint{ "kubernetes": &Endpoint{
Host: defaultCtx.Endpoints.Kubernetes.Host, Host: defaultCtx.Endpoints.Kubernetes.Host,
DefaultNamespace: defaultCtx.Endpoints.Kubernetes.DefaultNamespace, DefaultNamespace: defaultCtx.Endpoints.Kubernetes.DefaultNamespace,
}, },