mirror of https://github.com/harness/drone.git
feat: [AH-713]: add method to get base UI url (#3103)
* feat: [AH-713]: add method to get base UI urlpull/3597/head
parent
26408533e1
commit
ed2597bdcc
|
@ -78,6 +78,8 @@ type Provider interface {
|
|||
GetAPIProto(ctx context.Context) string
|
||||
|
||||
RegistryURL(ctx context.Context, params ...string) string
|
||||
|
||||
GetUIBaseURL(ctx context.Context) string
|
||||
}
|
||||
|
||||
// Provider provides the URLs of the Harness system.
|
||||
|
@ -250,6 +252,10 @@ func (p *provider) RegistryURL(_ context.Context, params ...string) string {
|
|||
return strings.TrimRight(u.String(), "/")
|
||||
}
|
||||
|
||||
func (p *provider) GetUIBaseURL(_ context.Context) string {
|
||||
return p.uiURL.String()
|
||||
}
|
||||
|
||||
func BuildGITCloneSSHURL(user string, sshURL *url.URL, repoPath string) string {
|
||||
repoPath = path.Clean(repoPath)
|
||||
if !strings.HasSuffix(repoPath, GITSuffix) {
|
||||
|
|
|
@ -45,6 +45,18 @@ func GetHost(urlStr string) string {
|
|||
return u.Host
|
||||
}
|
||||
|
||||
func GetHostName(urlStr string) string {
|
||||
if !strings.Contains(urlStr, "://") {
|
||||
urlStr = "https://" + urlStr
|
||||
}
|
||||
u, err := url.Parse(urlStr)
|
||||
if err != nil {
|
||||
log.Warn().Msgf("Failed to parse URL: %s", urlStr)
|
||||
return ""
|
||||
}
|
||||
return u.Hostname()
|
||||
}
|
||||
|
||||
func TrimURLScheme(urlStr string) string {
|
||||
u, err := url.Parse(urlStr)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue