config

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Splitter is a splitter for configmap name generation
	Splitter = "-"

	// TypeConfigMap defines the type of Configmap
	TypeConfigMap = "configmap"
)
View Source
const TypeFake = "fake"

TypeFake is a fake type

View Source
const TypeLocal = "local"

TypeLocal defines the local config store type

Variables

This section is empty.

Functions

func DecodeConfigFormat

func DecodeConfigFormat(data []map[string]string) (map[string]string, error)

DecodeConfigFormat will decode config{name: key, value: value} format to key-value mode.

func EncodeConfigFormat

func EncodeConfigFormat(key, value string) map[string]string

EncodeConfigFormat will encode key-value to config{name: key, value: value} format

func GenConfigMapName

func GenConfigMapName(appName, serviceName, configName string) string

GenConfigMapName is a fixed way to name the configmap name for appfile config

func ToConfigMap

func ToConfigMap(s Store, name, envName string, configData map[string]string) (*v1.ConfigMap, error)

ToConfigMap will get the data of the store and upload to configmap. Serverside Application controller can only use the config in appfile context by configmap.

Types

type Configmap

type Configmap struct {
	Client client.Client
}

Configmap is the configmap implementation of config store

func (*Configmap) GetConfigData

func (f *Configmap) GetConfigData(name, envName string) ([]map[string]string, error)

GetConfigData will get config data from configmap

func (*Configmap) Namespace

func (f *Configmap) Namespace(envName string) (string, error)

Namespace returns the namespace of the config store from env

func (Configmap) Type

func (Configmap) Type() string

Type returns the type of the config store

type Fake

type Fake struct {
	Data []map[string]string
}

Fake is a fake implementation of config store, help for test

func (*Fake) GetConfigData

func (f *Fake) GetConfigData(_ string, _ string) ([]map[string]string, error)

GetConfigData get data

func (Fake) Namespace

func (Fake) Namespace(_ string) (string, error)

Namespace return the Namespace

func (Fake) Type

func (Fake) Type() string

Type return the type

type Local

type Local struct{}

Local is the local implementation of config store

func (*Local) GetConfigData

func (l *Local) GetConfigData(configName, envName string) ([]map[string]string, error)

GetConfigData will return config data from local

func (*Local) Namespace

func (l *Local) Namespace(envName string) (string, error)

Namespace return namespace from env

func (*Local) Type

func (l *Local) Type() string

Type returns the type of this config store implementation

type Store

type Store interface {
	GetConfigData(configName, envName string) ([]map[string]string, error)
	Type() string
	Namespace(envName string) (string, error)
}

Store will get config data

Jump to

Keyboard shortcuts

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