Move trace and logs UI to Operator Console (#375)

Co-authored-by: Daniel Valdivia <hola@danielvaldivia.com>
This commit is contained in:
Cesar N
2020-11-04 21:45:48 -08:00
committed by GitHub
parent 3cd024ea2c
commit 06f333395e
23 changed files with 256 additions and 222 deletions

View File

@@ -21,6 +21,8 @@ import (
"encoding/json"
"fmt"
"log"
"net/http"
"regexp"
"strings"
"time"
@@ -93,3 +95,25 @@ func getLogTime(lt string) string {
}
return tm.Format(logTimeFormat)
}
// getConsoleLogOptionsFromReq return tenant name from url
// path come as : `/console/<namespace>/<tenantName>`
func getConsoleLogOptionsFromReq(req *http.Request) (namespace, tenant string) {
re := regexp.MustCompile(`(/console/)(.*?)/(.*?)(\?.*?$|$)`)
matches := re.FindAllSubmatch([]byte(req.URL.Path), -1)
// len matches is always 4
namespace = strings.TrimSpace(string(matches[0][2]))
tenant = strings.TrimSpace(string(matches[0][3]))
return namespace, tenant
}
// getTraceOptionsFromReq return tenant name from url
// path come as : `/trace/<namespace>/<tenantName>`
func getTraceOptionsFromReq(req *http.Request) (namespace, tenant string) {
re := regexp.MustCompile(`(/trace/)(.*?)/(.*?)(\?.*?$|$)`)
matches := re.FindAllSubmatch([]byte(req.URL.Path), -1)
// len matches is always 4
namespace = strings.TrimSpace(string(matches[0][2]))
tenant = strings.TrimSpace(string(matches[0][3]))
return namespace, tenant
}