Changed the return of the /kubeconfig to encoded kubeconfig
This commit is contained in:
@@ -12,8 +12,8 @@ import (
|
||||
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
jwt "github.com/golang-jwt/jwt/v5"
|
||||
"gopkg.in/yaml.v2"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/util/yaml"
|
||||
)
|
||||
|
||||
type KubeInfo struct {
|
||||
@@ -462,7 +462,19 @@ func (c *AdmiraltyController) GetAdmiraltyKubeconfig() {
|
||||
return
|
||||
}
|
||||
|
||||
c.Data["json"] = kubeconfig
|
||||
b, err := yaml.Marshal(kubeconfig)
|
||||
if err != nil {
|
||||
fmt.Println("Error while marshalling kubeconfig")
|
||||
c.Ctx.Output.SetStatus(500)
|
||||
c.Data["json"] = map[string]string{"error": err.Error()}
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
encodedKubeconfig := base64.StdEncoding.EncodeToString(b)
|
||||
c.Data["json"] = map[string]string{
|
||||
"data": encodedKubeconfig,
|
||||
}
|
||||
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user