Merge pull request #7593 from reasonerjt/ext-url-systeminfo

Add Ext URL to response of systeminfo API
This commit is contained in:
Daniel Jiang 2019-04-29 14:51:40 +08:00 committed by GitHub
commit 56c7d55c73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -3998,6 +3998,12 @@ definitions:
admiral_endpoint: admiral_endpoint:
type: string type: string
description: The url of the endpoint of admiral instance. 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: auth_mode:
type: string type: string
description: The auth mode of current Harbor instance. description: The auth mode of current Harbor instance.

View File

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