quick

package
v0.1.0-cvefix.3 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckData

func CheckData(data interface{}) error

CheckData - checks the validity of config data. Data should be of type struct and contain a string type field called "Version".

func FormatJSONSyntaxError

func FormatJSONSyntaxError(data io.Reader, offset int64) (highlight string)

FormatJSONSyntaxError generates a pretty printed json syntax error since golang doesn't provide an easy way to report the location of the error

func GetVersion

func GetVersion(filename string, clnt *etcd.Client) (version string, err error)

GetVersion - extracts the version information.

func SaveConfig

func SaveConfig(data interface{}, filename string, clnt *etcd.Client) (err error)

SaveConfig - saves given configuration data into given file as JSON.

Types

type Config

type Config interface {
	String() string
	Version() string
	Save(string) error
	Load(string) error
	Data() interface{}
	Diff(Config) ([]structs.Field, error)
	DeepDiff(Config) ([]structs.Field, error)
}

Config - generic config interface functions

func LoadConfig

func LoadConfig(filename string, clnt *etcd.Client, data interface{}) (qc Config, err error)

LoadConfig - loads json config from filename for the a given struct data

func NewConfig

func NewConfig(data interface{}, clnt *etcd.Client) (cfg Config, err error)

NewConfig loads config from etcd client if provided, otherwise loads from a local filename. fails when all else fails.

type ConfigEncoding

type ConfigEncoding interface {
	Unmarshal([]byte, interface{}) error
	Marshal(interface{}) ([]byte, error)
}

ConfigEncoding is a generic interface which marshal/unmarshal configuration.

Jump to

Keyboard shortcuts

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