Documentation ¶
Overview ¶
Package metadata define config related metadata
Index ¶
- Constants
- Variables
- type AuthModeType
- type BoolType
- type CfgMetaData
- type ConfigureValue
- func (c *ConfigureValue) GetAnyType() (interface{}, error)
- func (c *ConfigureValue) GetBool() bool
- func (c *ConfigureValue) GetDuration() time.Duration
- func (c *ConfigureValue) GetFloat64() float64
- func (c *ConfigureValue) GetInt() int
- func (c *ConfigureValue) GetInt64() int64
- func (c *ConfigureValue) GetName() string
- func (c *ConfigureValue) GetPassword() string
- func (c *ConfigureValue) GetString() string
- func (c *ConfigureValue) GetStringToStringMap() map[string]string
- func (c *ConfigureValue) Set(name, value string) error
- func (c *ConfigureValue) Validate() error
- type DurationType
- type Float64Type
- type Int64Type
- type IntType
- type Item
- type LdapScopeType
- type MapType
- type NonEmptyStringType
- type PasswordType
- type PortType
- type ProjectCreationRestrictionType
- type QuotaType
- type StringToStringMapType
- type StringType
- type Type
Constants ¶
const ( // Scope UserScope = "user" SystemScope = "system" // Group LdapBasicGroup = "ldapbasic" LdapGroupGroup = "ldapgroup" UAAGroup = "uaa" HTTPAuthGroup = "http_auth" OIDCGroup = "oidc" DatabaseGroup = "database" QuotaGroup = "quota" // Put all config items do not belong a existing group into basic BasicGroup = "basic" TrivyGroup = "trivy" GDPRGroup = "gdpr" )
Constant for configure item
Variables ¶
var ( // ErrNotDefined ... ErrNotDefined = errors.New("configure item is not defined in metadata") // ErrTypeNotMatch ... ErrTypeNotMatch = errors.New("the required value doesn't matched with metadata defined") // ErrInvalidData ... ErrInvalidData = errors.New("the data provided is invalid") // ErrValueNotSet ... ErrValueNotSet = errors.New("the configure value is not set") // ErrStringValueIsEmpty ... ErrStringValueIsEmpty = errors.New("the configure value can not be empty") )
var ( // ConfigList - All configure items used in harbor // Steps to onboard a new setting // 1. Add configure item in metadatalist.go // 2. Get/Set config settings by CfgManager // 3. CfgManager.Load()/CfgManager.Save() to load/save from configure storage. ConfigList = []Item{}/* 109 elements not displayed */ )
Functions ¶
This section is empty.
Types ¶
type CfgMetaData ¶
type CfgMetaData struct {
// contains filtered or unexported fields
}
CfgMetaData ...
func Instance ¶
func Instance() *CfgMetaData
Instance - Get Instance, make it singleton because there is only one copy of metadata in an env
func (*CfgMetaData) GetAll ¶
func (c *CfgMetaData) GetAll() []Item
GetAll - Get all metadata in current env
type ConfigureValue ¶
type ConfigureValue struct { Name string `json:"name,omitempty"` Value string `json:"value,omitempty"` }
ConfigureValue - struct to hold a actual value, also include the name of config metadata.
func NewCfgValue ¶
func NewCfgValue(name, value string) (*ConfigureValue, error)
NewCfgValue ... Create checked config value
func (*ConfigureValue) GetAnyType ¶
func (c *ConfigureValue) GetAnyType() (interface{}, error)
GetAnyType get the interface{} of current value
func (*ConfigureValue) GetBool ¶
func (c *ConfigureValue) GetBool() bool
GetBool - return the bool value of current setting
func (*ConfigureValue) GetDuration ¶
func (c *ConfigureValue) GetDuration() time.Duration
GetDuration - return the time.Duration value of current value
func (*ConfigureValue) GetFloat64 ¶
func (c *ConfigureValue) GetFloat64() float64
GetFloat64 - return the float64 value of current value
func (*ConfigureValue) GetInt ¶
func (c *ConfigureValue) GetInt() int
GetInt - return the int value of current value
func (*ConfigureValue) GetInt64 ¶
func (c *ConfigureValue) GetInt64() int64
GetInt64 - return the int64 value of current value
func (*ConfigureValue) GetString ¶
func (c *ConfigureValue) GetString() string
GetString - Get the string value of current configure
func (*ConfigureValue) GetStringToStringMap ¶
func (c *ConfigureValue) GetStringToStringMap() map[string]string
GetStringToStringMap - return the string to string map of current value
func (*ConfigureValue) Set ¶
func (c *ConfigureValue) Set(name, value string) error
Set - set this configure item to configure store
func (*ConfigureValue) Validate ¶
func (c *ConfigureValue) Validate() error
Validate - to validate configure items, if passed, return nil, else return error
type Float64Type ¶
type Float64Type struct{}
type Item ¶
type Item struct { // The Scope of this configuration item: eg: SystemScope, UserScope Scope string `json:"scope,omitempty"` // ldapbasic, ldapgroup, uaa settings, used to retieve configure items by group Group string `json:"group,omitempty"` // environment key to retrieves this value when initialize, for example: POSTGRESQL_HOST, only used for system settings, for user settings no EnvKey EnvKey string `json:"environment_key,omitempty"` // The default string value for this key DefaultValue string `json:"default_value,omitempty"` // The key for current configure settings in database or rest api Name string `json:"name,omitempty"` // It can be &IntType{}, &StringType{}, &BoolType{}, &PasswordType{}, &MapType{} etc, any type interface implementation ItemType Type // Editable means it can updated by configure api, For system configure, the editable is always false, for user configure, it may depends Editable bool `json:"editable,omitempty"` // Description - Describle the usage of the configure item Description string }
Item - Configure item include default value, type, env name
type LdapScopeType ¶
type LdapScopeType struct {
IntType
}
LdapScopeType - The LDAP scope is a int type, but its is limit to 0, 1, 2
type ProjectCreationRestrictionType ¶
type ProjectCreationRestrictionType struct {
StringType
}
ProjectCreationRestrictionType ...