mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-07 07:21:22 +01:00
add with_clair flag in systeminfo
This commit is contained in:
parent
6a85012dbd
commit
15384317e0
@ -2150,6 +2150,9 @@ definitions:
|
|||||||
with_notary:
|
with_notary:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: If the Harbor instance is deployed with nested notary.
|
description: If the Harbor instance is deployed with nested notary.
|
||||||
|
with_clair:
|
||||||
|
type: boolean
|
||||||
|
description: If the Harbor instance is deployed with nested clair.
|
||||||
with_admiral:
|
with_admiral:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: If the Harbor instance is deployed with Admiral.
|
description: If the Harbor instance is deployed with Admiral.
|
||||||
|
@ -36,4 +36,5 @@ CFG_EXPIRATION=5
|
|||||||
GODEBUG=netdns=cgo
|
GODEBUG=netdns=cgo
|
||||||
ADMIRAL_URL=$admiral_url
|
ADMIRAL_URL=$admiral_url
|
||||||
WITH_NOTARY=$with_notary
|
WITH_NOTARY=$with_notary
|
||||||
|
WITH_CLAIR=$with_clair
|
||||||
RESET=false
|
RESET=false
|
||||||
|
@ -225,7 +225,7 @@ render(os.path.join(templates_dir, "adminserver", "env"),
|
|||||||
token_expiration=token_expiration,
|
token_expiration=token_expiration,
|
||||||
admiral_url=admiral_url,
|
admiral_url=admiral_url,
|
||||||
with_notary=args.notary_mode,
|
with_notary=args.notary_mode,
|
||||||
scanner=args.clair_mode and "clair" or "none"
|
with_clair=args.clair_mode
|
||||||
)
|
)
|
||||||
|
|
||||||
render(os.path.join(templates_dir, "ui", "env"),
|
render(os.path.join(templates_dir, "ui", "env"),
|
||||||
|
@ -116,6 +116,10 @@ var (
|
|||||||
env: "WITH_NOTARY",
|
env: "WITH_NOTARY",
|
||||||
parse: parseStringToBool,
|
parse: parseStringToBool,
|
||||||
},
|
},
|
||||||
|
common.WithClair: &parser{
|
||||||
|
env: "WITH_CLAIR",
|
||||||
|
parse: parseStringToBool,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// configurations need read from environment variables
|
// configurations need read from environment variables
|
||||||
@ -136,6 +140,10 @@ var (
|
|||||||
env: "WITH_NOTARY",
|
env: "WITH_NOTARY",
|
||||||
parse: parseStringToBool,
|
parse: parseStringToBool,
|
||||||
},
|
},
|
||||||
|
common.WithClair: &parser{
|
||||||
|
env: "WITH_CLAIR",
|
||||||
|
parse: parseStringToBool,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -64,4 +64,5 @@ const (
|
|||||||
AdminInitialPassword = "admin_initial_password"
|
AdminInitialPassword = "admin_initial_password"
|
||||||
AdmiralEndpoint = "admiral_url"
|
AdmiralEndpoint = "admiral_url"
|
||||||
WithNotary = "with_notary"
|
WithNotary = "with_notary"
|
||||||
|
WithClair = "with_clair"
|
||||||
)
|
)
|
||||||
|
@ -59,6 +59,7 @@ var adminServerDefaultConfig = map[string]interface{}{
|
|||||||
common.AdminInitialPassword: "password",
|
common.AdminInitialPassword: "password",
|
||||||
common.AdmiralEndpoint: "http://www.vmware.com",
|
common.AdmiralEndpoint: "http://www.vmware.com",
|
||||||
common.WithNotary: false,
|
common.WithNotary: false,
|
||||||
|
common.WithClair: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewAdminserver returns a mock admin server
|
// NewAdminserver returns a mock admin server
|
||||||
|
@ -47,6 +47,7 @@ type Storage struct {
|
|||||||
//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"`
|
||||||
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"`
|
||||||
@ -125,6 +126,7 @@ func (sia *SystemInfoAPI) GetGeneralInfo() {
|
|||||||
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(),
|
||||||
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),
|
||||||
|
@ -313,6 +313,16 @@ func WithNotary() bool {
|
|||||||
return cfg[common.WithNotary].(bool)
|
return cfg[common.WithNotary].(bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithClair returns a bool value to indicate if Harbor's deployed with Clair
|
||||||
|
func WithClair() bool {
|
||||||
|
cfg, err := mg.Get()
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Failed to get configuration, will return WithClair == false")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return cfg[common.WithClair].(bool)
|
||||||
|
}
|
||||||
|
|
||||||
// AdmiralEndpoint returns the URL of admiral, if Harbor is not deployed with admiral it should return an empty string.
|
// AdmiralEndpoint returns the URL of admiral, if Harbor is not deployed with admiral it should return an empty string.
|
||||||
func AdmiralEndpoint() string {
|
func AdmiralEndpoint() string {
|
||||||
cfg, err := mg.Get()
|
cfg, err := mg.Get()
|
||||||
|
@ -125,6 +125,9 @@ func TestConfig(t *testing.T) {
|
|||||||
if WithNotary() {
|
if WithNotary() {
|
||||||
t.Errorf("Withnotary should be false")
|
t.Errorf("Withnotary should be false")
|
||||||
}
|
}
|
||||||
|
if WithClair() {
|
||||||
|
t.Errorf("WithClair should be false")
|
||||||
|
}
|
||||||
if !WithAdmiral() {
|
if !WithAdmiral() {
|
||||||
t.Errorf("WithAdmiral should be true")
|
t.Errorf("WithAdmiral should be true")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user