github.com/kubeshop/testkube@v1.17.23/cmd/kubectl-testkube/commands/common/uri.go (about) 1 package common 2 3 import ( 4 "fmt" 5 6 "github.com/kubeshop/testkube/cmd/kubectl-testkube/config" 7 ) 8 9 const ( 10 defaultAgentPort = 443 11 defaultLogsPort = 443 12 defaultAgentPrefix = "agent" 13 defaultUiPrefix = "app" 14 defaultLogsPrefix = "logs" 15 defaultApiPrefix = "api" 16 defaultRootDomain = "testkube.io" 17 ) 18 19 func NewMasterUris(apiPrefix, uiPrefix, agentPrefix, logsPrefix, agentURI, logsURI, rootDomain string, insecure bool) config.MasterURIs { 20 protocol := "https" 21 if insecure { 22 protocol = "http" 23 } 24 if apiPrefix == "" { 25 apiPrefix = defaultApiPrefix 26 } 27 if uiPrefix == "" { 28 uiPrefix = defaultUiPrefix 29 } 30 if agentPrefix == "" { 31 agentPrefix = defaultAgentPrefix 32 } 33 if logsPrefix == "" { 34 logsPrefix = defaultLogsPrefix 35 } 36 if rootDomain == "" { 37 rootDomain = defaultRootDomain 38 } 39 if agentURI == "" { 40 agentURI = fmt.Sprintf("%s.%s:%d", agentPrefix, rootDomain, defaultAgentPort) 41 } 42 if logsURI == "" { 43 logsURI = fmt.Sprintf("%s.%s:%d", logsPrefix, rootDomain, defaultLogsPort) 44 } 45 46 return config.MasterURIs{ 47 ApiPrefix: apiPrefix, 48 UiPrefix: uiPrefix, 49 RootDomain: rootDomain, 50 Api: fmt.Sprintf("%s://%s.%s", protocol, apiPrefix, rootDomain), 51 Agent: agentURI, 52 Logs: logsURI, 53 Ui: fmt.Sprintf("%s://%s.%s", protocol, uiPrefix, rootDomain), 54 Auth: fmt.Sprintf("%s://%s.%s/idp", protocol, apiPrefix, rootDomain), 55 } 56 }