osdconfig

package
v4.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2018 License: Apache-2.0 Imports: 10 Imported by: 40

README

osdconfig

osdconfig is a library to work with distributed configuration parameters. It defines an interface and provides an implementation against KVDB backend.

General purpose of this package is as follows:

  • Allow users to register their callback functions on updates to backend
  • Allow users to set/get config parameters

installation

osdconfig is written in go (golang). It can be installed using go get

$ go get github.com/libopenstorage/openstorage/osdconfig/...

example

Create an instance of kvdb

kv, err := kvdb.New(mem.Name, "", []string{}, nil, nil)
if err != nil {
    logrus.Fatal(err)
}

Create an instance of osdconfig manager

manager, err := osdconfig.NewManager(kv)
if err != nil {
	// do something
}
defer manager.Close()

Define a function literal that can be registered to watch for changes

f := func(config *osdconfig.Config) error {
	// do something with config (say print)
	fmt.Println(config)
	return nil
}

Register this function literal to watch on kvdb changes

if err := manager.WatchCluster("watcher", f); err != nil {
	// do something
}

Update cluster config on kvdb

conf := new(osdconfig.ClusterConfig)
conf.ClusterID = "myID"
if err := manager.SetClusterConf(conf); err != nil {
	// do something
	return
}

once updates are pushed to backend (kvdb in this implementation), callback function is called

Documentation

Overview

osdconfig is a package to work with distributed config parameters

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotImplemented is returned when any of the ConfigCaller APIs is not
	// implemented
	ErrNotImplemented = errors.New("configCaller API not implemented")
)

Functions

This section is empty.

Types

type AWSConfig

type AWSConfig struct {
	AccessKeyId     string `json:"aws_access_key_id,omitempty" yaml:"aws_access_key_id,omitempty" enable:"true" hidden:"false" usage:"AWS access key ID"`
	SecretAccessKey string `` /* 136-byte string literal not displayed */
	SecretTokenKey  string `` /* 133-byte string literal not displayed */
	Cmk             string `json:"aws_cmk,omitempty" yaml:"aws_cmk,omitempty" enable:"true" hidden:"false" usage:"AWS CMK"`
	Region          string `json:"aws_region,omitempty" yaml:"aws_region,omitempty" enable:"true" hidden:"false" usage:"AWS region"`
}

AWS configuration parameters struct swagger:model

func (*AWSConfig) Init

func (conf *AWSConfig) Init() *AWSConfig

type CallbackClusterConfigFunc

type CallbackClusterConfigFunc func(config *ClusterConfig) error

type for callback func for cluster

type CallbackNodeConfigFunc

type CallbackNodeConfigFunc func(config *NodeConfig) error

type ClusterConfig

type ClusterConfig struct {
	Description string         `json:"description,omitempty" yaml:"description,omitempty" enable:"true" hidden:"false" usage:"Cluster description"`
	Mode        string         `json:"mode,omitempty" yaml:"mode,omitempty" enable:"true" hidden:"false" usage:"Mode for cluster"`
	Version     string         `json:"version,omitempty" yaml:"version,omitempty" enable:"true" hidden:"false" usage:"Version info for cluster"`
	Created     time.Time      `json:"created,omitempty" yaml:"created,omitempty" enable:"true" hidden:"false" usage:"Creation info for cluster"`
	ClusterId   string         `json:"cluster_id,omitempty" yaml:"cluster_id,omitempty" enable:"true" hidden:"false" usage:"Cluster ID info"`
	Domain      string         `json:"domain,omitempty" yaml:"domain,omitempty" enable:"true" hidden:"false" usage:"usage to be added"`
	Secrets     *SecretsConfig `` /* 142-byte string literal not displayed */
	Kvdb        *KvdbConfig    `` /* 137-byte string literal not displayed */
	Private     interface{}    `json:"private,omitempty" yaml:"private,omitempty" enable:"true" hidden:"false" usage:"usage to be added"`
}

ClusterConfig is a cluster level config parameter struct swagger:model

func (*ClusterConfig) Init

func (conf *ClusterConfig) Init() *ClusterConfig

type ConfigCaller

type ConfigCaller interface {
	// GetClusterConf fetches cluster configuration data from a backend such as kvdb
	GetClusterConf() (*ClusterConfig, error)

	// GetNodeConf fetches node configuration data using node id
	GetNodeConf(nodeID string) (*NodeConfig, error)

	// EnumerateNodeConf fetches data for all nodes
	EnumerateNodeConf() (*NodesConfig, error)

	// SetClusterConf pushes cluster configuration data to the backend
	// It is assumed that the backend will notify the implementor of this interface
	// when a change is triggered
	SetClusterConf(config *ClusterConfig) error

	// SetNodeConf pushes node configuration data to the backend
	// It is assumed that the backend will notify the implementor of this interface
	// when a change is triggered
	SetNodeConf(config *NodeConfig) error

	// DeleteNodeConf removes node config for a particular node
	DeleteNodeConf(nodeID string) error
}

ConfigCaller interface defines the setters/getters for osdconfig

type ConfigManager

type ConfigManager interface {
	ConfigCaller
	ConfigWatcher
}

ConfigManager is the overall osdconfig interface including callers and watchers

func NewManager

func NewManager(kv kvdb.Kvdb) (ConfigManager, error)

NewManager can be used to instantiate ConfigManager Users of this function are expected to manage the execution via context github.com/sirupsen/logrus package is used for logging internally

type ConfigWatcher

type ConfigWatcher interface {
	// WatchCluster registers a user defined function as callback watching for changes
	// in the cluster configuration
	WatchCluster(name string, cb func(config *ClusterConfig) error) error

	// WatchNode registers a user defined function as callback watching for changes
	// in the node configuration
	WatchNode(name string, cb func(config *NodeConfig) error) error
}

ConfigWatcher defines watches on cluster and nodes

type GeoConfig

type GeoConfig struct {
	Rack   string `json:"rack,omitempty" yaml:"rack,omitempty" enable:"true" hidden:"false" usage:"Rack info"`
	Zone   string `json:"zone,omitempty" yaml:"zone,omitempty" enable:"true" hidden:"false" usage:"Zone info"`
	Region string `json:"region,omitempty" yaml:"region,omitempty" enable:"true" hidden:"false" usage:"Region info"`
}

GeoConfig holds geographic information

func (*GeoConfig) Init

func (conf *GeoConfig) Init() *GeoConfig

type KvdbConfig

type KvdbConfig struct {
	Name               string   `json:"name,omitempty" yaml:"name,omitempty" enable:"true" hidden:"false" usage:"Name for kvdb"`
	Username           string   `json:"username,omitempty" yaml:"username,omitempty" enable:"true" hidden:"false" usage:"Username for kvdb"`
	Password           string   `json:"password,omitempty" yaml:"password,omitempty" enable:"true" hidden:"false" usage:"Passwd for kvdb"`
	CAFile             string   `json:"ca_file,omitempty" yaml:"ca_file,omitempty" enable:"true" hidden:"false" usage:"CA file for kvdb"`
	CertFile           string   `json:"cert_file,omitempty" yaml:"cert_file,omitempty" enable:"true" hidden:"false" usage:"Cert file for kvdb"`
	CertKeyFile        string   `json:"cert_key_file,omitempty" yaml:"cert_key_file,omitempty" enable:"true" hidden:"false" usage:"Cert key file for kvdb"`
	TrustedCAFile      string   `` /* 127-byte string literal not displayed */
	ClientCertAuth     string   `json:"client_cert_auth,omitempty" yaml:"client_cert_auth,omitempty" enable:"true" hidden:"false" usage:"Client cert auth"`
	AclToken           string   `json:"acl_token,omitempty" yaml:"acl_token,omitempty" enable:"true" hidden:"false" usage:"ACL token"`
	CAAuthAddress      string   `` /* 146-byte string literal not displayed */
	InsecureSkipVerify bool     `` /* 156-byte string literal not displayed */
	TransportScheme    string   `` /* 153-byte string literal not displayed */
	Discovery          []string `json:"discovery,omitempty" yaml:"discovery,omitempty" enable:"true" hidden:"false" usage:"List of etcd endpoints"`
}

KvdbConfig stores parameters defining kvdb configuration swagger:model

func (*KvdbConfig) Init

func (conf *KvdbConfig) Init() *KvdbConfig

type NetworkConfig

type NetworkConfig struct {
	MgtIface  string `json:"mgt_interface,omitempty" yaml:"mgt_interface,omitempty" enable:"true" hidden:"false" usage:"Management interface"`
	DataIface string `json:"data_interface,omitempty" yaml:"data_interface,omitempty" enable:"true" hidden:"false" usage:"Data interface"`
}

NetworkConfig is a network configuration parameters struct swagger:model

func (*NetworkConfig) Init

func (conf *NetworkConfig) Init() *NetworkConfig

type NodeConfig

type NodeConfig struct {
	NodeId      string         `json:"node_id,omitempty" yaml:"node_id,omitempty" enable:"true" hidden:"false" usage:"ID for the node"`
	CSIEndpoint string         `json:"csi_endpoint,omitempty" yaml:"csi_endpoint,omitempty" enable:"true" hidden:"false" usage:"CSI endpoint"`
	Network     *NetworkConfig `` /* 158-byte string literal not displayed */
	Storage     *StorageConfig `` /* 158-byte string literal not displayed */
	Geo         *GeoConfig     `` /* 142-byte string literal not displayed */
	Private     interface{}    `json:"private,omitempty" yaml:"private,omitempty" enable:"false" hidden:"false" usage:"Private node data"`
}

NodeConfig is a node level config data swagger:model

func (*NodeConfig) Init

func (conf *NodeConfig) Init() *NodeConfig

type NodesConfig

type NodesConfig []*NodeConfig

NodesConfig contains all of node level data swagger:model

type NullConfigCaller

type NullConfigCaller struct {
}

NullConfigCaller is a NULL implementation of the ConfigCaller interface

func (*NullConfigCaller) DeleteNodeConf

func (n *NullConfigCaller) DeleteNodeConf(nodeID string) error

DeleteNodeConf removes node config for a particular node

func (*NullConfigCaller) EnumerateNodeConf

func (n *NullConfigCaller) EnumerateNodeConf() (*NodesConfig, error)

EnumerateNodeConf fetches data for all nodes

func (*NullConfigCaller) GetClusterConf

func (n *NullConfigCaller) GetClusterConf() (*ClusterConfig, error)

GetClusterConf fetches cluster configuration data from a backend such as kvdb

func (*NullConfigCaller) GetNodeConf

func (n *NullConfigCaller) GetNodeConf(nodeID string) (*NodeConfig, error)

GetNodeConf fetches node configuration data using node id

func (*NullConfigCaller) SetClusterConf

func (n *NullConfigCaller) SetClusterConf(config *ClusterConfig) error

SetClusterConf pushes cluster configuration data to the backend It is assumed that the backend will notify the implementor of this interface when a change is triggered

func (*NullConfigCaller) SetNodeConf

func (n *NullConfigCaller) SetNodeConf(config *NodeConfig) error

SetNodeConf pushes node configuration data to the backend It is assumed that the backend will notify the implementor of this interface when a change is triggered

type SecretsConfig

type SecretsConfig struct {
	SecretType       string       `json:"secret_type,omitempty" yaml:"secret_type,omitempty" enable:"true" hidden:"false" usage:"Secret type"`
	ClusterSecretKey string       `json:"cluster_secret_key,omitempty" yaml:"cluster_secret_key,omitempty" enable:"true" hidden:"false" usage:"Secret key"`
	Vault            *VaultConfig `json:"vault,omitempty" yaml:"vault,omitempty" enable:"true" hidden:"false" usage:"Vault configuration"`
	Aws              *AWSConfig   `json:"aws,omitempty" yaml:"aws,omitempty" enable:"true" hidden:"false" usage:"AWS configuration"`
}

SecretsConfig is a secrets configuration parameters struct swagger:model

func (*SecretsConfig) Init

func (conf *SecretsConfig) Init() *SecretsConfig

type StorageConfig

type StorageConfig struct {
	DevicesMd        []string `json:"devices_md,omitempty" yaml:"devices_md,omitempty" enable:"true" hidden:"false" usage:"Devices MD"`
	Devices          []string `json:"devices,omitempty" yaml:"devices,omitempty" enable:"true" hidden:"false" usage:"Devices list"`
	MaxCount         uint32   `json:"max_count,omitempty" yaml:"max_count,omitempty" enable:"true" hidden:"false" usage:"Maximum count"`
	MaxDriveSetCount uint32   `` /* 130-byte string literal not displayed */
	RaidLevel        string   `json:"raid_level,omitempty" yaml:"raid_level,omitempty" enable:"true" hidden:"false" usage:"RAID level info"`
	RaidLevelMd      string   `json:"raid_level_md,omitempty" yaml:"raid_level_md,omitempty" enable:"true" hidden:"false" usage:"RAID level MD"`
}

StorageConfig is a storage configuration parameters struct swagger:model

func (*StorageConfig) Init

func (conf *StorageConfig) Init() *StorageConfig

type VaultConfig

type VaultConfig struct {
	Token         string `json:"token,omitempty" yaml:"token,omitempty" enable:"true" hidden:"false" usage:"Vault token"`
	Address       string `json:"address,omitempty" yaml:"address,omitempty" enable:"true" hidden:"false" usage:"Vault address"`
	CACert        string `json:"ca_cert,omitempty" yaml:"ca_cert,omitempty" enable:"true" hidden:"false" usage:"Vault CA certificate"`
	CAPath        string `json:"ca_path,omitempty" yaml:"ca_path,omitempty" enable:"true" hidden:"false" usage:"Vault CA path"`
	ClientCert    string `json:"client_cert,omitempty" yaml:"client_cert,omitempty" enable:"true" hidden:"false" usage:"Vault client certificate"`
	ClientKey     string `json:"client_key,omitempty" yaml:"client_key,omitempty" enable:"true" hidden:"false" usage:"Vault client key"`
	TLSSkipVerify string `json:"skip_verify,omitempty" yaml:"skip_verify,omitempty" enable:"true" hidden:"false" usage:"Vault skip verification"`
	TLSServerName string `json:"tls_server_name,omitempty" yaml:"tls_server_name,omitempty" enable:"true" hidden:"false" usage:"Vault TLS server name"`
	BasePath      string `json:"base_path,omitempty" yaml:"base_path,omitempty" enable:"true" hidden:"false" usage:"Vault base path"`
	BackendPath   string `` /* 129-byte string literal not displayed */
}

VaultConfig is a vault configuration parameters struct swagger:model

func (*VaultConfig) Init

func (conf *VaultConfig) Init() *VaultConfig

type Watcher

type Watcher string

Watcher is a classifier for registering function

Jump to

Keyboard shortcuts

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