asconfig

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyName = "name"

	SectionNameStartChar = '{'
	SectionNameEndChar   = '}'

	// Enum values for Operation
	Add    Operation = "add"
	Remove Operation = "remove"
	Update Operation = "update"
)

All the aerospike config related keys

View Source
const (
	FSPATH  sysproptype = "FSPATH"
	NETADDR sysproptype = "NETADDR"
	DEVICE  sysproptype = "DEVICE"
	NONE    sysproptype = "NONE"
)

types of system properties

Variables

View Source
var BenchmarkConfigs = []string{
	"enable-benchmarks-batch-sub", "enable-benchmarks-read",
	"enable-benchmarks-udf", "enable-benchmarks-write",
	"enable-benchmarks-udf-sub", "enable-benchmarks-storage",
	"enable-benchmarks-fabric", "enable-benchmarks-ops-sub",
}
View Source
var ErrConfigKeyInvalid = fmt.Errorf("invalid config key")

ErrConfigKeyInvalid is invalid config key error

View Source
var ErrConfigParse = fmt.Errorf("config parse error")

ErrConfigParse is config parse error

View Source
var ErrConfigSchema = fmt.Errorf("config schema error")

ErrConfigSchema is config schema error

View Source
var ErrConfigTransformUnsupported = fmt.Errorf("unsupported config transform")

ErrConfigTransformUnsupported is unsupported config transform

View Source
var ErrConfigVersionInvalid = fmt.Errorf("invalid config version")

ErrConfigVersionInvalid is invalid config version

View Source
var ErrConfigVersionUnsupported = fmt.Errorf("unsupported config version")

ErrConfigVersionUnsupported is unsupported config version

View Source
var ReCurlyBraces = regexp.MustCompile(`^\{.*\}$`)

Functions

func BaseKey

func BaseKey(k string) (baseKey string)

func BaseVersion

func BaseVersion(ver string) (string, error)

BaseVersion returns base-version for ver

func ContextKey

func ContextKey(k string) string

func CreateSetConfigCmdList

func CreateSetConfigCmdList(log logr.Logger, configMap DynamicConfigMap, conn deployment.ASConnInterface,
	aerospikePolicy *aero.ClientPolicy,
) ([]string, error)

CreateSetConfigCmdList creates set-config commands for given config.

func GetASConfig

func GetASConfig(path *string, conn *deployment.ASConn, aerospikePolicy *aero.ClientPolicy) (
	confToReturn interface{}, err error)

GetASConfig returns the value of the given path from the aerospike config from given host.

func GetDefault

func GetDefault(ver string) (map[string]interface{}, error)

GetDefault return the map of default values.

func GetDynamic

func GetDynamic(ver string) (sets.Set[string], error)

GetDynamic return the map of values which are dynamic values.

func GetFlatKey

func GetFlatKey(tokens []string) string

func Init

func Init(log logr.Logger, schemaDir string) error

Init initializes aerospike schemas. Init needs to be called before using this package.

schemaDir is the path to directory having the aerospike config schemas.

func InitFromMap

func InitFromMap(log logr.Logger, schemaMap map[string]string)

InitFromMap init schema map from a map. Map key format -> 4.1.0 Map value format -> string of json schema

func IsAllDynamicConfig

func IsAllDynamicConfig(log logr.Logger, configMap DynamicConfigMap, version string) (bool, error)

IsAllDynamicConfig returns true if all the fields in the given configMap are dynamically configured.

func IsDynamicConfig

func IsDynamicConfig(log logr.Logger, dynamic sets.Set[string], conf string,
	valueMap map[Operation]interface{}) bool

IsDynamicConfig returns true if the given field is dynamically configured.

func IsSupportedVersion

func IsSupportedVersion(ver string) (bool, error)

IsSupportedVersion returns true if version supported else false

func IsUpgrade

func IsUpgrade(fromVersion, toVersion string) (bool, error)

IsUpgrade returns true if it is upgrade else false

func IsValidUpgrade

func IsValidUpgrade(fromVersion, toVersion string) error

IsValidUpgrade validates fromVersion and toVersion for all upgrade/downgrade restrictions

func PluralOf

func PluralOf(noun string) string

PluralOf returns the plural of the input noun.

func SingularOf

func SingularOf(noun string) string

SingularOf returns the singular of the input noun.

func SplitKey

func SplitKey(log logr.Logger, key, sep string) []string

SplitKey splits key by using sep it ignores sep inside sectionNameStartChar and sectionNameEndChar

func ToPlural

func ToPlural(k string, v any, m Conf)

Types

type AsConfig

type AsConfig struct {
	// contains filtered or unexported fields
}

AsConfig is wrapper over Conf

func FromConfFile

func FromConfFile(log logr.Logger, in io.Reader) (*AsConfig, error)

FromConfFile unmarshales the aerospike config text in "in" into a new *AsConfig

func New

func New(log logr.Logger, bconf *Conf) *AsConfig

func NewMapAsConfig

func NewMapAsConfig(
	log logr.Logger, configMap map[string]interface{},
) (*AsConfig, error)

NewMapAsConfig creates AsConfig. Typically, an unmarshalled yaml file is passed in

func (*AsConfig) GetFlatMap

func (cfg *AsConfig) GetFlatMap() *Conf

GetFlatMap returns a pointer to the copy of the flattened config stored in cfg

func (*AsConfig) IsValid

func (cfg *AsConfig) IsValid(log logr.Logger, version string) (
	bool, []*ValidationErr, error,
)

IsValid checks validity of config

func (*AsConfig) ToConfFile

func (cfg *AsConfig) ToConfFile() DotConf

ToConfFile returns DotConf

func (*AsConfig) ToMap

func (cfg *AsConfig) ToMap() *Conf

ToMap returns a pointer to the expanded map form of AsConfig

type CfgValue

type CfgValue struct {
	Value   interface{}
	Context string
	Name    string
}

CfgValue is config details

type Conf

type Conf = lib.Stats

Conf is format for configs It has list for named sections like namespace, set, dc, tls, logging file

type ConfGetter

type ConfGetter interface {
	AllConfigs() (Conf, error)
	GetAsInfo(cmdList ...string) (Conf, error)
}

ConfGetter is an interface that defines methods for retrieving configurations.

type DotConf

type DotConf = string

DotConf is string of aerospike.conf content

type DynamicConfigMap

type DynamicConfigMap map[string]map[Operation]interface{}

DynamicConfigMap is a map of config flatten keys and their operations and values for eg: "xdr.dcs.{DC3}.node-address-ports": {Remove: []string{"1.1.2.1 3000"}}

func ConfDiff

func ConfDiff(
	log logr.Logger, desiredConf, currentConf Conf, isFlat bool, ver string,
) (DynamicConfigMap, error)

ConfDiff find diff between two configs;

	diff = desired - current
 if any config parameter is present in current but not in desired,
 result map will contain the corresponding default value for
 that config parameter.

It returns a map of flatten conf key and value(which is another map of added and removed fields, mostly helps in the case of list of string fields)

type GenConf

type GenConf struct {
	Conf    Conf
	Version string
}

func GenerateConf

func GenerateConf(log logr.Logger, confGetter ConfGetter, removeDefaults bool) (*GenConf, error)

GenerateConf generates the config based on the provided log and ConfGetter. If removeDefaults is true, it will remove default values from the config. Without removeDefaults, the config that is generate will not be valid. Many default values are out of the acceptable range required by the server.

type GetConfigStep

type GetConfigStep struct {
	// contains filtered or unexported fields
}

GetConfigStep is a pipeline step that retrieves the configs and metadata.

type GetFlatSchemaStep

type GetFlatSchemaStep struct {
	// contains filtered or unexported fields
}

GetFlatSchema

type Operation

type Operation string

type ServerVersionCheckStep

type ServerVersionCheckStep struct {
	// contains filtered or unexported fields
}

ServerVersionCheckStep is a pipeline step that checks if the server version is supported.

type ValidationErr

type ValidationErr struct {
	Value       interface{}
	ErrType     string
	Context     string
	Description string
	Field       string
}

ValidationErr represents version validation error

func ConfValuesValid

func ConfValuesValid(flatConf *Conf) []*ValidationErr

Jump to

Keyboard shortcuts

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