mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-02 21:11:37 +01:00
Merge pull request #2529 from reasonerjt/clair-integration
add with_clair flag in systeminfo
This commit is contained in:
commit
ae77753bf2
@ -2150,6 +2150,9 @@ definitions:
|
||||
with_notary:
|
||||
type: boolean
|
||||
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:
|
||||
type: boolean
|
||||
description: If the Harbor instance is deployed with Admiral.
|
||||
|
@ -36,4 +36,5 @@ CFG_EXPIRATION=5
|
||||
GODEBUG=netdns=cgo
|
||||
ADMIRAL_URL=$admiral_url
|
||||
WITH_NOTARY=$with_notary
|
||||
WITH_CLAIR=$with_clair
|
||||
RESET=false
|
||||
|
@ -225,7 +225,7 @@ render(os.path.join(templates_dir, "adminserver", "env"),
|
||||
token_expiration=token_expiration,
|
||||
admiral_url=admiral_url,
|
||||
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"),
|
||||
|
@ -116,6 +116,10 @@ var (
|
||||
env: "WITH_NOTARY",
|
||||
parse: parseStringToBool,
|
||||
},
|
||||
common.WithClair: &parser{
|
||||
env: "WITH_CLAIR",
|
||||
parse: parseStringToBool,
|
||||
},
|
||||
}
|
||||
|
||||
// configurations need read from environment variables
|
||||
@ -136,6 +140,10 @@ var (
|
||||
env: "WITH_NOTARY",
|
||||
parse: parseStringToBool,
|
||||
},
|
||||
common.WithClair: &parser{
|
||||
env: "WITH_CLAIR",
|
||||
parse: parseStringToBool,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -64,4 +64,5 @@ const (
|
||||
AdminInitialPassword = "admin_initial_password"
|
||||
AdmiralEndpoint = "admiral_url"
|
||||
WithNotary = "with_notary"
|
||||
WithClair = "with_clair"
|
||||
)
|
||||
|
@ -59,6 +59,7 @@ var adminServerDefaultConfig = map[string]interface{}{
|
||||
common.AdminInitialPassword: "password",
|
||||
common.AdmiralEndpoint: "http://www.vmware.com",
|
||||
common.WithNotary: false,
|
||||
common.WithClair: false,
|
||||
}
|
||||
|
||||
// NewAdminserver returns a mock admin server
|
||||
|
@ -47,6 +47,7 @@ type Storage struct {
|
||||
//GeneralInfo wraps common systeminfo for anonymous request
|
||||
type GeneralInfo struct {
|
||||
WithNotary bool `json:"with_notary"`
|
||||
WithClair bool `json:"with_clair"`
|
||||
WithAdmiral bool `json:"with_admiral"`
|
||||
AdmiralEndpoint string `json:"admiral_endpoint"`
|
||||
AuthMode string `json:"auth_mode"`
|
||||
@ -125,6 +126,7 @@ func (sia *SystemInfoAPI) GetGeneralInfo() {
|
||||
AdmiralEndpoint: cfg[common.AdmiralEndpoint].(string),
|
||||
WithAdmiral: config.WithAdmiral(),
|
||||
WithNotary: config.WithNotary(),
|
||||
WithClair: config.WithClair(),
|
||||
AuthMode: cfg[common.AUTHMode].(string),
|
||||
ProjectCreationRestrict: cfg[common.ProjectCreationRestriction].(string),
|
||||
SelfRegistration: cfg[common.SelfRegistration].(bool),
|
||||
|
@ -313,6 +313,16 @@ func 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.
|
||||
func AdmiralEndpoint() string {
|
||||
cfg, err := mg.Get()
|
||||
|
@ -125,6 +125,9 @@ func TestConfig(t *testing.T) {
|
||||
if WithNotary() {
|
||||
t.Errorf("Withnotary should be false")
|
||||
}
|
||||
if WithClair() {
|
||||
t.Errorf("WithClair should be false")
|
||||
}
|
||||
if !WithAdmiral() {
|
||||
t.Errorf("WithAdmiral should be true")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user