config

package
v0.0.0-...-44f477e Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2021 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 AuthMode

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

AuthMode ...

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 Email

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

Email returns email server 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 GetChartMuseumEndpoint

func GetChartMuseumEndpoint() (string, error)

GetChartMuseumEndpoint returns the endpoint of the chartmuseum service otherwise an non nil error is returned

func GetCoreURL

func GetCoreURL() string

GetCoreURL returns the url of core from env

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 GetRedisOfRegURL

func GetRedisOfRegURL() string

GetRedisOfRegURL returns the URL of Redis used by registry

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 InternalNotaryEndpoint

func InternalNotaryEndpoint() string

InternalNotaryEndpoint returns notary server endpoint for internal communication between Harbor containers This is currently a conventional value and can be unaccessible when Harbor is not deployed with Notary.

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 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 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 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 WithChartMuseum

func WithChartMuseum() bool

WithChartMuseum returns a bool to indicate if chartmuseum is deployed with Harbor.

func WithNotary

func WithNotary() bool

WithNotary returns a bool value to indicate if Harbor's deployed with Notary

func WithTrivy

func WithTrivy() bool

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

Types

type InternalCfg

type InternalCfg map[string]*models.Value

InternalCfg internal configure response model

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 FromContext

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

FromContext returns CfgManager from context

func GetCfgManager

func GetCfgManager(ctx 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