config

package
v1.1.1-0...-d146046 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

README

Configuration as a Code module

Stores application configuration in Kubernetes or in local filesystem as YAML files in Kubernetes syntax. The state is synchronized in both ways.

Cache

Cache layer should be implemented at adapter level and know the source object (fetched from configuration) and target object (saved back into configuration) to clear both from cache. On each save, deletion, or external modification the cached object should be deleted.

Cache is a service independent of adapter, it is an implementation shared across adapters.

Filesystem adapter

Works in a directory structure that bases on object types and names.

Pattern:

strings.ReplaceAll(o.path+"/"+o.namespace+"/"+apiGroup+"/"+apiVersion+"/"+kind+"/"+id+".yaml", "//", "/")

Examples:

# Example: 
#    apiVersion: backups.riotkit.org/v1alpha1
#    kind: BackupUser
#    metadata:
#        name: admin
#        namespace: default
#

./default/backups.riotkit.org_v1alpha1/BackupUser/admin.yaml


# Example:
#   apiVersion: v1
#   kind: Secret
#   metadata:
#       name: backup-repository-passwords

./default/v1/Secret/backup-repository-passwords.yaml
Immutability

Like in Kubernetes apiVersion, kind and metadata.name are immutable, in this context - when any of them are changed, then object from application cache should be removed.

Labels

To be discussed how to implement.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigurationInKubernetes

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

func CreateKubernetesConfigurationProvider

func CreateKubernetesConfigurationProvider(namespace string) *ConfigurationInKubernetes

func (*ConfigurationInKubernetes) GetHealth

func (o *ConfigurationInKubernetes) GetHealth() error

func (*ConfigurationInKubernetes) GetSingleDocument

func (o *ConfigurationInKubernetes) GetSingleDocument(kind string, id string) (string, error)

func (*ConfigurationInKubernetes) GetSingleDocumentAnyType

func (o *ConfigurationInKubernetes) GetSingleDocumentAnyType(kind string, id string, apiGroup string, apiVersion string) (string, error)

func (*ConfigurationInKubernetes) StoreDocument

func (o *ConfigurationInKubernetes) StoreDocument(kind string, document interface{}) error

type ConfigurationInLocalFilesystem

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

func NewConfigurationInLocalFilesystemProvider

func NewConfigurationInLocalFilesystemProvider(path string, namespace string) *ConfigurationInLocalFilesystem

func (*ConfigurationInLocalFilesystem) GetHealth

func (fs *ConfigurationInLocalFilesystem) GetHealth() error

func (*ConfigurationInLocalFilesystem) GetSingleDocument

func (fs *ConfigurationInLocalFilesystem) GetSingleDocument(kind string, id string) (string, error)

func (*ConfigurationInLocalFilesystem) GetSingleDocumentAnyType

func (fs *ConfigurationInLocalFilesystem) GetSingleDocumentAnyType(kind string, id string, apiGroup string, apiVersion string) (string, error)

func (*ConfigurationInLocalFilesystem) StoreDocument

func (fs *ConfigurationInLocalFilesystem) StoreDocument(kind string, document interface{}) error

type ConfigurationProvider

type ConfigurationProvider interface {
	GetSingleDocument(kind string, id string) (string, error)
	GetSingleDocumentAnyType(kind string, id string, apiGroup string, apiVersion string) (string, error)

	StoreDocument(kind string, document interface{}) error
	GetHealth() error
}

func CreateConfigurationProvider

func CreateConfigurationProvider(providerName string, namespace string, localPath string) (ConfigurationProvider, error)

CreateConfigurationProvider is a configuration factory

type ObjectMetadata

type ObjectMetadata struct {
	Name string `json:"name" structs:"name"`
}

Jump to

Keyboard shortcuts

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