config

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Network   = "network"
	Channel   = "channel"
	Namespace = "namespace"
)
View Source
const (
	RootKey = "token"
	TMSKey  = "tms"
)

Variables

View Source
var (
	TMSPath     = config.Join(RootKey, TMSKey)
	VersionPath = config.Join(RootKey, "version")
	EnabledPath = config.Join(RootKey, "enabled")

	// ErrConfigurationNotFound is returned when a configuration is not found
	ErrConfigurationNotFound = errors.Errorf("configuration not found")
)

Functions

This section is empty.

Types

type Configuration

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

Configuration is the configuration of a given configuration

func NewConfiguration

func NewConfiguration(cp Provider, keyID string, tmsID driver.TMSID) *Configuration

func (*Configuration) GetBool

func (m *Configuration) GetBool(key string) bool

func (*Configuration) GetString

func (m *Configuration) GetString(key string) string

func (*Configuration) ID

func (m *Configuration) ID() driver.TMSID

func (*Configuration) IsSet

func (m *Configuration) IsSet(key string) bool

func (*Configuration) Serialize

func (m *Configuration) Serialize(tmsID token.TMSID) ([]byte, error)

Serialize serializes this configuration with the respect to the passed tms ID

func (*Configuration) SetValidators

func (m *Configuration) SetValidators(validators []Validator)

SetValidators sets the validators for this configuration.

func (*Configuration) TranslatePath

func (m *Configuration) TranslatePath(path string) string

TranslatePath translates the passed path relative to the config path

func (*Configuration) UnmarshalKey

func (m *Configuration) UnmarshalKey(key string, rawVal any) error

UnmarshalKey takes a single key and unmarshals it into a Struct

func (*Configuration) Validate

func (m *Configuration) Validate() error

type Provider

type Provider interface {
	UnmarshalKey(key string, rawVal any) error
	GetString(key string) string
	IsSet(key string) bool
	TranslatePath(path string) string
	GetBool(s string) bool
	MergeConfig(raw []byte) error
	ProvideFromRaw(raw []byte) (*config.Provider, error)
}

type Service

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

Service model the configuration service for Panurus

func NewService

func NewService(cp Provider) *Service

NewService creates a new Service configuration.

func (*Service) AddConfiguration

func (m *Service) AddConfiguration(raw []byte) error

AddConfiguration does the following: - parse raw as a yaml stream - extract the configuration - validate it making sure it contains a new TMS If all good, accept the new TMS Updates to an existing TMS should be rejected.

func (*Service) ConfigurationFor

func (m *Service) ConfigurationFor(network, channel, namespace string) (*Configuration, error)

ConfigurationFor returns a configuration for the given network, channel, and namespace.

func (*Service) Configurations

func (m *Service) Configurations() ([]*Configuration, error)

Configurations returns all configuration configurations.

func (*Service) Enabled

func (m *Service) Enabled() bool

func (*Service) LookupNamespace

func (m *Service) LookupNamespace(network, channel string) (string, error)

LookupNamespace searches for a configuration that matches the given network and channel, and return its namespace. If no matching configuration is found, an error is returned. If multiple matching configurations are found, an error is returned.

func (*Service) ResetConfigurations

func (m *Service) ResetConfigurations() error

ResetConfigurations resets the internal configurations holder.

func (*Service) Version

func (m *Service) Version() string

type TMSConfig

type TMSConfig struct {
	Token TokenConfig `yaml:"token"`
}

TMSConfig is the TMS configuration

type TokenConfig

type TokenConfig struct {
	TMS map[string]map[string]any `mapstructure:"tms" yaml:"tms"`
}

TokenConfig is used to serialize a TMS configuration

type ValidateConfiguration

type ValidateConfiguration interface {
	// ID identities the TMS this configuration refers to.
	ID() token.TMSID
	// IsSet checks to see if the key has been set in any of the data locations
	IsSet(key string) bool
	// UnmarshalKey takes a single key and unmarshals it into a struct.
	// The key must be relative to the TMS this configuration refers to.
	UnmarshalKey(key string, rawVal any) error
	// GetString returns the value associated with the key as a string
	GetString(key string) string
	// GetBool returns the value associated with the key as a bool
	GetBool(key string) bool
	// TranslatePath translates the passed path relative to the config path
	TranslatePath(path string) string
}

ValidateConfiguration provides functions to access the configuration of a given TMS

type Validator

type Validator interface {
	// Validate returns nil if the passed configuration is valid, an error otherwise.
	Validate(ValidateConfiguration) error
}

Validator is used to validate a TMS configuration

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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