diff --git a/controllers/admiralty.go b/controllers/admiralty.go index 6701fea..71116f6 100644 --- a/controllers/admiralty.go +++ b/controllers/admiralty.go @@ -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 } diff --git a/docs/admiralty_setup.puml b/docs/admiralty_setup.puml index cf418dd..490fd45 100644 --- a/docs/admiralty_setup.puml +++ b/docs/admiralty_setup.puml @@ -7,13 +7,15 @@ boundary "remote oc-datacenter" as rocdc workflow --> locdc : POST /booking/ {booking object} locdc --> locdc : create Namespace + ServiceAccount +workflow --> rocdc : POST /boking/ +rocdc --> rocdc : create \nNamespace + \nServiceAccount monitord --> monitord : retrieves a Workflow to execute monitord --> monitord : workflow needs repartited execution -monitord --> rocdc : POST /????? (route that use the same \nmethods as /booking/ to create NS & SA) +' monitord --> rocdc : POST /????? (route that use the same \nmethods as /booking/ to create NS & SA) monitord --> rocdc : POST /admiralty/source -monitord --> rodc : GET /admiralty/token/:execution_id +monitord --> rocdc : GET /admiralty/kubeconfig/:execution_id rocdc -> monitord : base64 encoded edited kubeconfig with token (**how to make it secure** ???) monitord --> locdc : POST /admiralty/secret/:execution_id monitord --> locdc : POST /admiralty/target/:execution_id -' locdc -> monitord : OK +monitord --> locdc : GET /admiralty/nodes/:execution_id \n(if the node is up it means ALL GOOD) @enduml \ No newline at end of file