Add Ext URL to response of systeminfo API

Signed-off-by: Daniel Jiang <jiangd@vmware.com>
This commit is contained in:
Daniel Jiang 2019-04-29 12:53:56 +08:00
parent 2a463016a9
commit 02cf75c142
2 changed files with 10 additions and 1 deletions

View File

@ -3998,6 +3998,12 @@ definitions:
admiral_endpoint:
type: string
description: The url of the endpoint of admiral instance.
registry_url:
type: string
description: The url of registry against which the docker command should be issued.
external_url:
type: string
description: The external URL of Harbor, with protocol.
auth_mode:
type: string
description: The auth mode of current Harbor instance.

View File

@ -97,6 +97,7 @@ type GeneralInfo struct {
AuthMode string `json:"auth_mode"`
AuthProxySettings *models.HTTPAuthProxy `json:"authproxy_settings,omitempty"`
RegistryURL string `json:"registry_url"`
ExtURL string `json:"external_url"`
ProjectCreationRestrict string `json:"project_creation_restriction"`
SelfRegistration bool `json:"self_registration"`
HasCARoot bool `json:"has_ca_root"`
@ -162,8 +163,9 @@ func (sia *SystemInfoAPI) GetGeneralInfo() {
sia.SendInternalServerError(fmt.Errorf("Unexpected error: %v", err))
return
}
extURL := cfg[common.ExtEndpoint].(string)
var registryURL string
if l := strings.Split(cfg[common.ExtEndpoint].(string), "://"); len(l) > 1 {
if l := strings.Split(extURL, "://"); len(l) > 1 {
registryURL = l[1]
} else {
registryURL = l[0]
@ -178,6 +180,7 @@ func (sia *SystemInfoAPI) GetGeneralInfo() {
AuthMode: utils.SafeCastString(cfg[common.AUTHMode]),
ProjectCreationRestrict: utils.SafeCastString(cfg[common.ProjectCreationRestriction]),
SelfRegistration: utils.SafeCastBool(cfg[common.SelfRegistration]),
ExtURL: extURL,
RegistryURL: registryURL,
HasCARoot: caStatErr == nil,
HarborVersion: harborVersion,