corrected how the kubeconfig info are stored in /admiralty/kubeconfig (POST)

This commit is contained in:
pb 2025-04-04 18:01:14 +02:00
parent 3ae9f69525
commit bb03307b9e
2 changed files with 24 additions and 24 deletions

View File

@ -484,7 +484,7 @@ func (c *AdmiraltyController) GetAdmiraltyKubeconfig() {
return return
} }
b, err := yaml.Marshal(kubeconfig) b, err := json.Marshal(kubeconfig)
if err != nil { if err != nil {
fmt.Println("Error while marshalling kubeconfig") fmt.Println("Error while marshalling kubeconfig")
c.Ctx.Output.SetStatus(500) c.Ctx.Output.SetStatus(500)
@ -517,7 +517,7 @@ func NewHostKubeWithToken(token string) (*models.KubeConfigValue, error){
{ {
Name: "default", Name: "default",
Cluster: models.KubeconfigCluster{ Cluster: models.KubeconfigCluster{
Server: conf.GetConfig().KubeHost, Server: "https://" + conf.GetConfig().KubeHost + ":6443",
CertificateAuthorityData: encodedCA, CertificateAuthorityData: encodedCA,
}, },
}, },

View File

@ -2,55 +2,55 @@ package models
// KubeConfigValue is a struct used to create a kubectl configuration YAML file. // KubeConfigValue is a struct used to create a kubectl configuration YAML file.
type KubeConfigValue struct { type KubeConfigValue struct {
APIVersion string `yaml:"apiVersion"` APIVersion string `yaml:"apiVersion" json:"apiVersion"`
Kind string `yaml:"kind"` Kind string `yaml:"kind" json:"kind"`
Clusters []KubeconfigNamedCluster `yaml:"clusters"` Clusters []KubeconfigNamedCluster `yaml:"clusters" json:"clusters"`
Users []KubeconfigUser `yaml:"users"` Users []KubeconfigUser `yaml:"users" json:"users"`
Contexts []KubeconfigNamedContext `yaml:"contexts"` Contexts []KubeconfigNamedContext `yaml:"contexts" json:"contexts"`
CurrentContext string `yaml:"current-context"` CurrentContext string `yaml:"current-context" json:"current-context"`
Preferences struct{} `yaml:"preferences"` Preferences struct{} `yaml:"preferences" json:"preferences"`
} }
// KubeconfigUser is a struct used to create a kubectl configuration YAML file // KubeconfigUser is a struct used to create a kubectl configuration YAML file
type KubeconfigUser struct { type KubeconfigUser struct {
Name string `yaml:"name"` Name string `yaml:"name" json:"name"`
User KubeconfigUserKeyPair `yaml:"user"` User KubeconfigUserKeyPair `yaml:"user" json:"user"`
} }
// KubeconfigUserKeyPair is a struct used to create a kubectl configuration YAML file // KubeconfigUserKeyPair is a struct used to create a kubectl configuration YAML file
type KubeconfigUserKeyPair struct { type KubeconfigUserKeyPair struct {
Token string `yaml:"token"` Token string `yaml:"token" json:"token"`
} }
// KubeconfigAuthProvider is a struct used to create a kubectl authentication provider // KubeconfigAuthProvider is a struct used to create a kubectl authentication provider
type KubeconfigAuthProvider struct { type KubeconfigAuthProvider struct {
Name string `yaml:"name"` Name string `yaml:"name" json:"name"`
Config map[string]string `yaml:"config"` Config map[string]string `yaml:"config" json:"config"`
} }
// KubeconfigNamedCluster is a struct used to create a kubectl configuration YAML file // KubeconfigNamedCluster is a struct used to create a kubectl configuration YAML file
type KubeconfigNamedCluster struct { type KubeconfigNamedCluster struct {
Name string `yaml:"name"` Name string `yaml:"name" json:"name"`
Cluster KubeconfigCluster `yaml:"cluster"` Cluster KubeconfigCluster `yaml:"cluster" json:"cluster"`
} }
// KubeconfigCluster is a struct used to create a kubectl configuration YAML file // KubeconfigCluster is a struct used to create a kubectl configuration YAML file
type KubeconfigCluster struct { type KubeconfigCluster struct {
Server string `yaml:"server"` Server string `yaml:"server" json:"server"`
CertificateAuthorityData string `yaml:"certificate-authority-data"` CertificateAuthorityData string `yaml:"certificate-authority-data" json:"certificate-authority-data"`
CertificateAuthority string `yaml:"certificate-authority"` CertificateAuthority string `yaml:"certificate-authority" json:"certificate-authority"`
} }
// KubeconfigNamedContext is a struct used to create a kubectl configuration YAML file // KubeconfigNamedContext is a struct used to create a kubectl configuration YAML file
type KubeconfigNamedContext struct { type KubeconfigNamedContext struct {
Name string `yaml:"name"` Name string `yaml:"name" json:"name"`
Context KubeconfigContext `yaml:"context"` Context KubeconfigContext `yaml:"context" json:"context"`
} }
// KubeconfigContext is a struct used to create a kubectl configuration YAML file // KubeconfigContext is a struct used to create a kubectl configuration YAML file
type KubeconfigContext struct { type KubeconfigContext struct {
Cluster string `yaml:"cluster"` Cluster string `yaml:"cluster" json:"cluster"`
Namespace string `yaml:"namespace,omitempty"` Namespace string `yaml:"namespace,omitempty" json:"namespace,omitempty"`
User string `yaml:"user"` User string `yaml:"user" json:"user"`
} }