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 {
return ""
}
data, ok := endpoints.(store.Endpoint)
data, ok := endpoints.(*store.Endpoint)
if !ok {
return ""
}

View File

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

View File

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