From 2cf8923d9580410fbf5d8efae718b1b24e5686df Mon Sep 17 00:00:00 2001 From: pb Date: Fri, 4 Apr 2025 18:20:12 +0200 Subject: [PATCH] more logs --- controllers/admiralty.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/controllers/admiralty.go b/controllers/admiralty.go index e9b3f5a..8acfaf1 100644 --- a/controllers/admiralty.go +++ b/controllers/admiralty.go @@ -10,6 +10,8 @@ import ( "slices" "time" + oclib "cloud.o-forge.io/core/oc-lib" + beego "github.com/beego/beego/v2/server/web" jwt "github.com/golang-jwt/jwt/v5" "gopkg.in/yaml.v2" @@ -315,7 +317,6 @@ func (c *AdmiraltyController) CreateKubeSecret() { // @router /node/:execution [get] func (c *AdmiraltyController) GetNodeReady(){ var secret v1.Secret - execution := c.Ctx.Input.Param(":execution") @@ -339,7 +340,7 @@ func (c *AdmiraltyController) GetNodeReady(){ if node == nil { c.Ctx.Output.SetStatus(404) c.Data["json"] = map[string]string{ - "error" : "the node for " + execution + " can't be found, make sure both target and source resources are set up on local and remote hosts", + "node" : "the node for " + execution + " can't be found, make sure both target and source resources are set up on local and remote hosts", } c.ServeJSON() return @@ -428,6 +429,8 @@ func retrieveTokenFromKonfig(editedKubeconfig map[string]interface{}) (string,er } func isTokenExpired(token string) (*bool, error){ + logger := oclib.GetLogger() + t, _, err := new(jwt.Parser).ParseUnverified(token, jwt.MapClaims{}) if err != nil { fmt.Println("couldn't decode token") @@ -439,7 +442,11 @@ func isTokenExpired(token string) (*bool, error){ fmt.Println("Error while checking token's expiration time") return nil, err } - fmt.Println("Expiration date : " + expiration.UTC().Format("2006-01-02T15:04:05")) + + logger.Debug().Msg("Expiration date : " + expiration.UTC().Format("2006-01-02T15:04:05")) + logger.Debug().Msg(fmt.Sprint("Now : ", time.Now().Unix())) + logger.Debug().Msg(fmt.Sprint("Token : ", expiration.Unix())) + expired := expiration.Unix() < time.Now().Unix()