metadata

package
v0.0.0-...-a14a4d2 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Overview

Package metadata define config related metadata

Index

Constants

View Source
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

View Source
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")
)
View Source
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 AuthModeType

type AuthModeType struct {
	StringType
}

AuthModeType ...

type BoolType

type BoolType struct {
}

BoolType ...

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

func (*CfgMetaData) GetByName

func (c *CfgMetaData) GetByName(name string) (*Item, bool)

GetByName - Get current metadata of current name, if not defined, return false in second params

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) GetName

func (c *ConfigureValue) GetName() string

GetName ...

func (*ConfigureValue) GetPassword

func (c *ConfigureValue) GetPassword() string

GetPassword ...

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 DurationType

type DurationType struct {
}

DurationType ...

type Float64Type

type Float64Type struct{}

type Int64Type

type Int64Type struct {
}

Int64Type ...

type IntType

type IntType struct {
}

IntType ..

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 MapType

type MapType struct {
}

MapType ...

type NonEmptyStringType

type NonEmptyStringType struct {
	StringType
}

NonEmptyStringType ...

type PasswordType

type PasswordType struct {
}

PasswordType ...

type PortType

type PortType struct {
	IntType
}

PortType ...

type ProjectCreationRestrictionType

type ProjectCreationRestrictionType struct {
	StringType
}

ProjectCreationRestrictionType ...

type QuotaType

type QuotaType struct {
	Int64Type
}

QuotaType ...

type StringToStringMapType

type StringToStringMapType struct {
}

StringToStringMapType ...

type StringType

type StringType struct {
}

StringType ...

type Type

type Type interface {
	// contains filtered or unexported methods
}

Type - Use this interface to define and encapsulate the behavior of validation and transformation

Jump to

Keyboard shortcuts

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