fix: kubeconfig server host

Signed-off-by: hongming <talonwan@yunify.com>
This commit is contained in:
hongming
2019-06-28 14:55:55 +08:00
committed by zryfish
parent 4778a8a7d2
commit 2a3e97b709
3 changed files with 30 additions and 7 deletions

View File

@@ -19,6 +19,7 @@ package resources
import (
"github.com/emicklei/go-restful"
"github.com/golang/glog"
k8serr "k8s.io/apimachinery/pkg/api/errors"
"net/http"
@@ -34,6 +35,7 @@ func GetKubectl(req *restful.Request, resp *restful.Response) {
kubectlPod, err := kubectl.GetKubectlPod(user)
if err != nil {
glog.Error(err)
resp.WriteHeaderAndEntity(http.StatusInternalServerError, errors.Wrap(err))
return
}
@@ -48,14 +50,14 @@ func GetKubeconfig(req *restful.Request, resp *restful.Response) {
kubectlConfig, err := kubeconfig.GetKubeConfig(user)
if err != nil {
glog.Error(err)
if k8serr.IsNotFound(err) {
// recreate
kubeconfig.CreateKubeConfig(user)
resp.WriteHeaderAndEntity(http.StatusNotFound, errors.Wrap(err))
resp.WriteHeaderAndJson(http.StatusNotFound, errors.Wrap(err), restful.MIME_JSON)
} else {
resp.WriteHeaderAndEntity(http.StatusInternalServerError, errors.Wrap(err))
resp.WriteHeaderAndJson(http.StatusInternalServerError, errors.Wrap(err), restful.MIME_JSON)
}
return
}