Merge pull request #4036 from ywk253100/180116_s3

Propagate registry storage driver name to adminserver and return it in /api/systeminfo
This commit is contained in:
Wenkai Yin 2018-01-16 18:41:08 +08:00 committed by GitHub
commit 8cda2d8d65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 89 additions and 81 deletions

View File

@ -51,3 +51,4 @@ UAA_CLIENTSECRET=$uaa_clientsecret
UAA_VERIFY_CERT=$uaa_verify_cert UAA_VERIFY_CERT=$uaa_verify_cert
UI_URL=http://ui:8080 UI_URL=http://ui:8080
JOBSERVICE_URL=http://jobservice:8080 JOBSERVICE_URL=http://jobservice:8080
REGISTRY_STORAGE_PROVIDER_NAME=$storage_provider_name

View File

@ -262,6 +262,9 @@ if rcp.has_option("configuration", "redis_url"):
else: else:
redis_url = "" redis_url = ""
storage_provider_name = rcp.get("configuration", "registry_storage_provider_name").strip()
storage_provider_config = rcp.get("configuration", "registry_storage_provider_config").strip()
ui_secret = ''.join(random.choice(string.ascii_letters+string.digits) for i in range(16)) ui_secret = ''.join(random.choice(string.ascii_letters+string.digits) for i in range(16))
jobservice_secret = ''.join(random.choice(string.ascii_letters+string.digits) for i in range(16)) jobservice_secret = ''.join(random.choice(string.ascii_letters+string.digits) for i in range(16))
@ -349,7 +352,8 @@ render(os.path.join(templates_dir, "adminserver", "env"),
uaa_endpoint=uaa_endpoint, uaa_endpoint=uaa_endpoint,
uaa_clientid=uaa_clientid, uaa_clientid=uaa_clientid,
uaa_clientsecret=uaa_clientsecret, uaa_clientsecret=uaa_clientsecret,
uaa_verify_cert=uaa_verify_cert uaa_verify_cert=uaa_verify_cert,
storage_provider_name=storage_provider_name
) )
render(os.path.join(templates_dir, "ui", "env"), render(os.path.join(templates_dir, "ui", "env"),
@ -360,8 +364,6 @@ render(os.path.join(templates_dir, "ui", "env"),
) )
registry_config_file = "config_ha.yml" if args.ha_mode else "config.yml" registry_config_file = "config_ha.yml" if args.ha_mode else "config.yml"
storage_provider_name = rcp.get("configuration", "registry_storage_provider_name").strip()
storage_provider_config = rcp.get("configuration", "registry_storage_provider_config").strip()
if storage_provider_name == "filesystem": if storage_provider_name == "filesystem":
if not storage_provider_config: if not storage_provider_config:
storage_provider_config = "rootdirectory: /storage" storage_provider_config = "rootdirectory: /storage"

View File

@ -141,8 +141,9 @@ var (
env: "UAA_VERIFY_CERT", env: "UAA_VERIFY_CERT",
parse: parseStringToBool, parse: parseStringToBool,
}, },
common.UIURL: "UI_URL", common.UIURL: "UI_URL",
common.JobServiceURL: "JOBSERVICE_URL", common.JobServiceURL: "JOBSERVICE_URL",
common.RegistryStorageProviderName: "REGISTRY_STORAGE_PROVIDER_NAME",
} }
// configurations need read from environment variables // configurations need read from environment variables
@ -175,6 +176,7 @@ var (
env: "UAA_VERIFY_CERT", env: "UAA_VERIFY_CERT",
parse: parseStringToBool, parse: parseStringToBool,
}, },
common.RegistryStorageProviderName: "REGISTRY_STORAGE_PROVIDER_NAME",
} }
) )

View File

@ -29,58 +29,59 @@ const (
RoleDeveloper = 2 RoleDeveloper = 2
RoleGuest = 3 RoleGuest = 3
ExtEndpoint = "ext_endpoint" ExtEndpoint = "ext_endpoint"
AUTHMode = "auth_mode" AUTHMode = "auth_mode"
DatabaseType = "database_type" DatabaseType = "database_type"
MySQLHost = "mysql_host" MySQLHost = "mysql_host"
MySQLPort = "mysql_port" MySQLPort = "mysql_port"
MySQLUsername = "mysql_username" MySQLUsername = "mysql_username"
MySQLPassword = "mysql_password" MySQLPassword = "mysql_password"
MySQLDatabase = "mysql_database" MySQLDatabase = "mysql_database"
SQLiteFile = "sqlite_file" SQLiteFile = "sqlite_file"
SelfRegistration = "self_registration" SelfRegistration = "self_registration"
UIURL = "ui_url" UIURL = "ui_url"
JobServiceURL = "jobservice_url" JobServiceURL = "jobservice_url"
LDAPURL = "ldap_url" LDAPURL = "ldap_url"
LDAPSearchDN = "ldap_search_dn" LDAPSearchDN = "ldap_search_dn"
LDAPSearchPwd = "ldap_search_password" LDAPSearchPwd = "ldap_search_password"
LDAPBaseDN = "ldap_base_dn" LDAPBaseDN = "ldap_base_dn"
LDAPUID = "ldap_uid" LDAPUID = "ldap_uid"
LDAPFilter = "ldap_filter" LDAPFilter = "ldap_filter"
LDAPScope = "ldap_scope" LDAPScope = "ldap_scope"
LDAPTimeout = "ldap_timeout" LDAPTimeout = "ldap_timeout"
LDAPVerifyCert = "ldap_verify_cert" LDAPVerifyCert = "ldap_verify_cert"
TokenServiceURL = "token_service_url" TokenServiceURL = "token_service_url"
RegistryURL = "registry_url" RegistryURL = "registry_url"
EmailHost = "email_host" EmailHost = "email_host"
EmailPort = "email_port" EmailPort = "email_port"
EmailUsername = "email_username" EmailUsername = "email_username"
EmailPassword = "email_password" EmailPassword = "email_password"
EmailFrom = "email_from" EmailFrom = "email_from"
EmailSSL = "email_ssl" EmailSSL = "email_ssl"
EmailIdentity = "email_identity" EmailIdentity = "email_identity"
EmailInsecure = "email_insecure" EmailInsecure = "email_insecure"
ProjectCreationRestriction = "project_creation_restriction" ProjectCreationRestriction = "project_creation_restriction"
MaxJobWorkers = "max_job_workers" MaxJobWorkers = "max_job_workers"
TokenExpiration = "token_expiration" TokenExpiration = "token_expiration"
CfgExpiration = "cfg_expiration" CfgExpiration = "cfg_expiration"
JobLogDir = "job_log_dir" JobLogDir = "job_log_dir"
AdminInitialPassword = "admin_initial_password" AdminInitialPassword = "admin_initial_password"
AdmiralEndpoint = "admiral_url" AdmiralEndpoint = "admiral_url"
WithNotary = "with_notary" WithNotary = "with_notary"
WithClair = "with_clair" WithClair = "with_clair"
ScanAllPolicy = "scan_all_policy" ScanAllPolicy = "scan_all_policy"
ClairDBPassword = "clair_db_password" ClairDBPassword = "clair_db_password"
ClairDBHost = "clair_db_host" ClairDBHost = "clair_db_host"
ClairDBPort = "clair_db_port" ClairDBPort = "clair_db_port"
ClairDB = "clair_db" ClairDB = "clair_db"
ClairDBUsername = "clair_db_username" ClairDBUsername = "clair_db_username"
UAAEndpoint = "uaa_endpoint" UAAEndpoint = "uaa_endpoint"
UAAClientID = "uaa_client_id" UAAClientID = "uaa_client_id"
UAAClientSecret = "uaa_client_secret" UAAClientSecret = "uaa_client_secret"
UAAVerifyCert = "uaa_verify_cert" UAAVerifyCert = "uaa_verify_cert"
DefaultClairEndpoint = "http://clair:6060" DefaultClairEndpoint = "http://clair:6060"
CfgDriverDB = "db" CfgDriverDB = "db"
CfgDriverJSON = "json" CfgDriverJSON = "json"
NewHarborAdminName = "admin@harbor.local" NewHarborAdminName = "admin@harbor.local"
RegistryStorageProviderName = "registry_storage_provider_name"
) )

View File

@ -86,18 +86,19 @@ var (
//GeneralInfo wraps common systeminfo for anonymous request //GeneralInfo wraps common systeminfo for anonymous request
type GeneralInfo struct { type GeneralInfo struct {
WithNotary bool `json:"with_notary"` WithNotary bool `json:"with_notary"`
WithClair bool `json:"with_clair"` WithClair bool `json:"with_clair"`
WithAdmiral bool `json:"with_admiral"` WithAdmiral bool `json:"with_admiral"`
AdmiralEndpoint string `json:"admiral_endpoint"` AdmiralEndpoint string `json:"admiral_endpoint"`
AuthMode string `json:"auth_mode"` AuthMode string `json:"auth_mode"`
RegistryURL string `json:"registry_url"` RegistryURL string `json:"registry_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"`
HarborVersion string `json:"harbor_version"` HarborVersion string `json:"harbor_version"`
NextScanAll int64 `json:"next_scan_all"` NextScanAll int64 `json:"next_scan_all"`
ClairVulnStatus *models.ClairVulnerabilityStatus `json:"clair_vulnerability_status,omitempty"` ClairVulnStatus *models.ClairVulnerabilityStatus `json:"clair_vulnerability_status,omitempty"`
RegistryStorageProviderName string `json:"registry_storage_provider_name"`
} }
// validate for validating user if an admin. // validate for validating user if an admin.
@ -165,16 +166,17 @@ func (sia *SystemInfoAPI) GetGeneralInfo() {
_, caStatErr := os.Stat(defaultRootCert) _, caStatErr := os.Stat(defaultRootCert)
harborVersion := sia.getVersion() harborVersion := sia.getVersion()
info := GeneralInfo{ info := GeneralInfo{
AdmiralEndpoint: cfg[common.AdmiralEndpoint].(string), AdmiralEndpoint: cfg[common.AdmiralEndpoint].(string),
WithAdmiral: config.WithAdmiral(), WithAdmiral: config.WithAdmiral(),
WithNotary: config.WithNotary(), WithNotary: config.WithNotary(),
WithClair: config.WithClair(), WithClair: config.WithClair(),
AuthMode: cfg[common.AUTHMode].(string), AuthMode: cfg[common.AUTHMode].(string),
ProjectCreationRestrict: cfg[common.ProjectCreationRestriction].(string), ProjectCreationRestrict: cfg[common.ProjectCreationRestriction].(string),
SelfRegistration: cfg[common.SelfRegistration].(bool), SelfRegistration: cfg[common.SelfRegistration].(bool),
RegistryURL: registryURL, RegistryURL: registryURL,
HasCARoot: caStatErr == nil, HasCARoot: caStatErr == nil,
HarborVersion: harborVersion, HarborVersion: harborVersion,
RegistryStorageProviderName: cfg[common.RegistryStorageProviderName].(string),
} }
if info.WithClair { if info.WithClair {
info.ClairVulnStatus = getClairVulnStatus() info.ClairVulnStatus = getClairVulnStatus()