config

package
v0.0.0-...-0d9dc4b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// SessionCookieName is the name of the cookie for session ID
	SessionCookieName = "sid"
)

Variables

View Source
var (
	// DefaultCfgManager the default change manager, default is DBCfgManager. If InMemoryConfigManager is used, need to set to InMemoryCfgManager in test code
	DefaultCfgManager = common.DBCfgManager
)
View Source
var (
	// SecretStore manages secrets
	SecretStore *secret.Store
)

Functions

func AuditLogForwardEndpoint

func AuditLogForwardEndpoint(ctx context.Context) string

AuditLogForwardEndpoint returns the audit log forward endpoint

func AuthMode

func AuthMode(ctx context.Context) (string, error)

AuthMode ...

func BannerMessage

func BannerMessage(ctx context.Context) string

BannerMessage returns the customized banner message

func CacheEnabled

func CacheEnabled() bool

CacheEnabled returns whether enable cache layer.

func CacheExpireHours

func CacheExpireHours() int

CacheExpireHours returns the cache expire hours for cache layer.

func CoreSecret

func CoreSecret() string

CoreSecret returns a secret to mark harbor-core when communicate with other component

func Database

func Database() (*models.Database, error)

Database returns database settings

func ExtEndpoint

func ExtEndpoint() (string, error)

ExtEndpoint returns the external URL of Harbor: protocol://host:port

func ExtURL

func ExtURL() (string, error)

ExtURL returns the external URL: host:port

func GDPRSetting

func GDPRSetting(ctx context.Context) (*cfgModels.GDPRSetting, error)

GDPRSetting returns the setting of GDPR

func GetBeegoMaxMemoryBytes

func GetBeegoMaxMemoryBytes() int64

GetBeegoMaxMemoryBytes returns the max memory bytes of beego config

func GetBeegoMaxUploadSizeBytes

func GetBeegoMaxUploadSizeBytes() int64

GetBeegoMaxUploadSizeBytes returns the max upload size bytes of beego config

func GetCoreURL

func GetCoreURL() string

GetCoreURL returns the url of core from env

func GetExecutionStatusRefreshIntervalSeconds

func GetExecutionStatusRefreshIntervalSeconds() int64

GetExecutionStatusRefreshIntervalSeconds returns the interval seconds for the refresh of execution status.

func GetGCTimeWindow

func GetGCTimeWindow() int64

GetGCTimeWindow returns the reserve time window of blob.

func GetPermittedRegistryTypesForProxyCache

func GetPermittedRegistryTypesForProxyCache() []string

GetPermittedRegistryTypesForProxyCache returns the permitted registry types for proxy cache

func GetPortalURL

func GetPortalURL() string

GetPortalURL returns the URL of portal

func GetQuotaUpdateProvider

func GetQuotaUpdateProvider() string

GetQuotaUpdateProvider returns the provider for updating quota.

func GetRegistryCtlURL

func GetRegistryCtlURL() string

GetRegistryCtlURL returns the URL of registryctl

func GetSystemCfg

func GetSystemCfg(ctx context.Context) (map[string]interface{}, error)

GetSystemCfg returns the all configurations

func HTTPAuthProxySetting

func HTTPAuthProxySetting(ctx context.Context) (*cfgModels.HTTPAuthProxy, error)

HTTPAuthProxySetting returns the setting of HTTP Auth proxy. the settings are only meaningful when the auth_mode is set to http_auth

func Init

func Init()

Init configurations need to import following package before calling it _ "github.com/goharbor/harbor/src/pkg/config/db"

func InitTraceConfig

func InitTraceConfig(ctx context.Context)

func InitWithSettings

func InitWithSettings(cfgs map[string]interface{}, kp ...encrypt.KeyProvider)

InitWithSettings init config with predefined configs, and optionally overwrite the keyprovider need to import following package before calling it _ "github.com/goharbor/harbor/src/pkg/config/inmemory"

func InitialAdminPassword

func InitialAdminPassword() (string, error)

InitialAdminPassword returns the initial password for administrator

func InternalCoreURL

func InternalCoreURL() string

InternalCoreURL returns the local harbor core url

func InternalJobServiceURL

func InternalJobServiceURL() string

InternalJobServiceURL returns jobservice URL for internal communication between Harbor containers

func InternalTokenServiceEndpoint

func InternalTokenServiceEndpoint() string

InternalTokenServiceEndpoint returns token service endpoint for internal communication between Harbor containers

func JobserviceSecret

func JobserviceSecret() string

JobserviceSecret returns a secret to mark Jobservice when communicate with other component TODO replace it with method of SecretStore

func LDAPConf

func LDAPConf(ctx context.Context) (*cfgModels.LdapConf, error)

LDAPConf returns the setting of ldap server

func LDAPGroupConf

func LDAPGroupConf(ctx context.Context) (*cfgModels.GroupConf, error)

LDAPGroupConf returns the setting of ldap group search

func Load

func Load(ctx context.Context) error

Load configurations

func LocalCoreURL

func LocalCoreURL() string

LocalCoreURL returns the local harbor core url

func Metric

func Metric() *models.Metric

Metric returns the overall metric settings

func NewContext

func NewContext(ctx context.Context, m Manager) context.Context

NewContext returns context with CfgManager

func NotificationEnable

func NotificationEnable(ctx context.Context) bool

NotificationEnable returns a bool to indicates if notification enabled in harbor

func OIDCSetting

func OIDCSetting(ctx context.Context) (*cfgModels.OIDCSetting, error)

OIDCSetting returns the setting of OIDC provider, currently there's only one OIDC provider allowed for Harbor and it's only effective when auth_mode is set to oidc_auth

func OnlyAdminCreateProject

func OnlyAdminCreateProject(ctx context.Context) (bool, error)

OnlyAdminCreateProject returns the flag to restrict that only sys admin can create project

func PullAuditLogDisable

func PullAuditLogDisable(ctx context.Context) bool

PullAuditLogDisable returns a bool to indicate if pull audit log is disable for pull request.

func PullCountUpdateDisable

func PullCountUpdateDisable(ctx context.Context) bool

PullCountUpdateDisable returns a bool to indicate if pull count is disable for pull request.

func PullTimeUpdateDisable

func PullTimeUpdateDisable(ctx context.Context) bool

PullTimeUpdateDisable returns a bool to indicate if pull time is disable for pull request.

func QuotaPerProjectEnable

func QuotaPerProjectEnable(ctx context.Context) bool

QuotaPerProjectEnable returns a bool to indicates if quota per project enabled in harbor

func QuotaSetting

func QuotaSetting(ctx context.Context) (*cfgModels.QuotaSetting, error)

QuotaSetting returns the setting of quota.

func ReadOnly

func ReadOnly(ctx context.Context) bool

ReadOnly returns a bool to indicates if Harbor is in read only mode.

func Register

func Register(name string, mgr Manager)

Register register the config manager

func RegistryCredential

func RegistryCredential() (string, string)

RegistryCredential returns the username and password the core uses to access registry

func RegistryURL

func RegistryURL() (string, error)

RegistryURL ...

func RobotPrefix

func RobotPrefix(ctx context.Context) string

RobotPrefix user defined robot name prefix.

func RobotTokenDuration

func RobotTokenDuration(ctx context.Context) int

RobotTokenDuration returns the token expiration time of robot account (in minute)

func ScannerRobotPrefix

func ScannerRobotPrefix(ctx context.Context) string

ScannerRobotPrefix returns the scanner of robot account prefix.

func ScannerSkipUpdatePullTime

func ScannerSkipUpdatePullTime(ctx context.Context) bool

ScannerSkipUpdatePullTime returns the scanner skip update pull time setting

func SecretKey

func SecretKey() (string, error)

SecretKey returns the secret key to encrypt the password of target

func SelfRegistration

func SelfRegistration(ctx context.Context) (bool, error)

SelfRegistration returns the enablement of self registration

func SessionTimeout

func SessionTimeout(ctx context.Context) int64

SessionTimeout returns the session timeout for web (in minute).

func SkipAuditLogDatabase

func SkipAuditLogDatabase(ctx context.Context) bool

SkipAuditLogDatabase returns the audit log forward endpoint

func SplitAndTrim

func SplitAndTrim(s, sep string) []string

SplitAndTrim ...

func TokenExpiration

func TokenExpiration(ctx context.Context) (int, error)

TokenExpiration returns the token expiration time (in minute)

func TokenPrivateKeyPath

func TokenPrivateKeyPath() string

TokenPrivateKeyPath returns the path to the key for signing token for registry

func TrivyAdapterURL

func TrivyAdapterURL() string

TrivyAdapterURL returns the endpoint URL of a Trivy adapter instance, by default it's the one deployed within Harbor.

func UAASettings

func UAASettings(ctx context.Context) (*models.UAASettings, error)

UAASettings returns the UAASettings to access UAA service.

func Upload

func Upload(cfg map[string]interface{}) error

Upload save all configurations, used by testing

func WithTrivy

func WithTrivy() bool

WithTrivy returns a bool value to indicate if Harbor's deployed with Trivy.

Types

type Manager

type Manager interface {
	Load(ctx context.Context) error
	Set(ctx context.Context, key string, value interface{})
	Save(ctx context.Context) error
	Get(ctx context.Context, key string) *metadata.ConfigureValue
	UpdateConfig(ctx context.Context, cfgs map[string]interface{}) error
	GetUserCfgs(ctx context.Context) map[string]interface{}
	ValidateCfg(ctx context.Context, cfgs map[string]interface{}) error
	GetAll(ctx context.Context) map[string]interface{}
	GetDatabaseCfg() *comModels.Database
}

Manager defines the operation for config

func DefaultMgr

func DefaultMgr() Manager

DefaultMgr get default config manager

func FromContext

func FromContext(ctx context.Context) (Manager, bool)

FromContext returns CfgManager from context

func GetCfgManager

func GetCfgManager(_ context.Context) Manager

GetCfgManager return the current config manager

func GetManager

func GetManager(name string) (Manager, error)

GetManager get the configure manager by name

Directories

Path Synopsis
Package metadata define config related metadata
Package metadata define config related metadata

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL