config

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2025 License: Apache-2.0 Imports: 8 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 added in v0.7.0

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

func (*Configuration) GetString added in v0.7.0

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

func (*Configuration) ID added in v0.7.0

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

func (*Configuration) IsSet added in v0.7.0

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

func (*Configuration) Serialize added in v0.7.0

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

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

func (*Configuration) TranslatePath added in v0.7.0

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

TranslatePath translates the passed path relative to the config path

func (*Configuration) UnmarshalKey added in v0.7.0

func (m *Configuration) UnmarshalKey(key string, rawVal interface{}) error

UnmarshalKey takes a single key and unmarshals it into a Struct

func (*Configuration) Validate added in v0.7.0

func (m *Configuration) Validate() error

type Provider added in v0.7.0

type Provider interface {
	UnmarshalKey(key string, rawVal interface{}) 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 the token sdk

func NewService

func NewService(cp Provider) *Service

NewService creates a new Service configuration.

func (*Service) AddConfiguration added in v0.7.0

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) Version

func (m *Service) Version() string

type TMSConfig added in v0.7.0

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

TMSConfig is the TMS configuration

type TokenConfig added in v0.7.0

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

TokenConfig is used to serialize a TMS configuration

type ValidateConfiguration added in v0.7.0

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 interface{}) 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 added in v0.7.0

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

Jump to

Keyboard shortcuts

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