configs

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package configs acts as the central place for app-global configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIMapping

type APIMapping struct {
	Path    string
	Package string
	Methods []string
	Queries []string
}

APIMapping within a configs.DatastoreAPIMapping which holds all information that is needed to map an incoming request to a rego package. The Path can be a regular expression.

type AppConfig

type AppConfig struct {
	ExternalConfig
	CallOperands    map[string]map[string]func(args ...string) (string, error)
	MetricsProvider telemetry.MetricsProvider
	TraceProvider   telemetry.TraceProvider
}

AppConfig represents the configuration for the entire app.

type ByteConfigLoader

type ByteConfigLoader struct {
	FileBytes []byte
}

ByteConfigLoader implements Loader by loading config from provided bytes slices.

func (*ByteConfigLoader) Load

func (l *ByteConfigLoader) Load() (*ExternalConfig, error)

Load implementation from ExternalLoader by using the properties of the ByteConfigLoader.

type ConfigLoader

type ConfigLoader interface {
	// Load loads all external configuration files from a predefined source.
	// It returns the loaded configuration and any error encountered that caused the Loader to stop early.
	Load() (*ExternalConfig, error)
}

ConfigLoader is the interface that the functionality of loading kelon's external configuration.

type Datastore

type Datastore struct {
	Type       string
	Connection map[string]string
	Metadata   map[string]string
}

Datastore has a fixed Type (enum type) and variable connection-/metadata-properties Which should be validated and parsed by each data.Datastore separately.

type DatastoreAPIMapping

type DatastoreAPIMapping struct {
	Prefix         string   `yaml:"path-prefix"`
	Datastores     []string `yaml:"datastores,omitempty"`
	Authentication *bool    `yaml:",omitempty"`
	Authorization  *bool    `yaml:",omitempty"`
	Mappings       []*APIMapping
}

DatastoreAPIMapping holds the API-mappings for one of the datastores defined in configs.DatastoreConfig.

Each mapping has a type of 'mapping global' Prefix which should be appended to each Path of its Mappings. The prefix can be a regular expression.

func (*DatastoreAPIMapping) Defaults added in v0.2.0

func (m *DatastoreAPIMapping) Defaults()

Defaults sets default values for required properties, if they are not set

func (*DatastoreAPIMapping) Validate added in v0.2.0

func (m *DatastoreAPIMapping) Validate(schema DatastoreSchemas) error

Validate checks if the provided DatastoreAPIMapping config does not contain invalid options nolint:revive

type DatastoreSchemas added in v0.2.0

type DatastoreSchemas = map[string]map[string]*EntitySchema

DatastoreSchemas maps the datastore alias to a datastore schema to a slice of Entities which are contained in this schema.

type Entity

type Entity struct {
	Name     string
	Alias    string
	Entities []*Entity
}

Entity inside a schema

type EntitySchema

type EntitySchema struct {
	Entities []*Entity
}

EntitySchema contains a List of entities of a schema

func (EntitySchema) ContainsEntity

func (schema EntitySchema) ContainsEntity(search string) (bool, *Entity)

ContainsEntity checks if an entity is contained inside a schema. The entity is searched by its alias which is either its name, or a specified alias!

Returns a boolean indicating if the entity was found and the entity itself.

func (EntitySchema) GenerateEntityPaths

func (schema EntitySchema) GenerateEntityPaths() map[string]map[string][]string

GenerateEntityPaths returns search structure for fast finding of paths from a source to a destination returned map of maps has the semantic pathBegin -> pathEnd -> path

func (EntitySchema) HasNestedEntities

func (schema EntitySchema) HasNestedEntities() bool

HasNestedEntities returns true if the schema contains entities with nested entities

type ExternalConfig

type ExternalConfig struct {
	Global           Global                              `yaml:"global"`
	APIMappings      []*DatastoreAPIMapping              `yaml:"apis"`
	Datastores       map[string]*Datastore               `yaml:"datastores"`
	DatastoreSchemas map[string]map[string]*EntitySchema `yaml:"entity_schemas"`
	OPA              any                                 `yaml:"opa"`
}

ExternalConfig holds all externally configurable properties

func (*ExternalConfig) Defaults added in v0.2.0

func (ec *ExternalConfig) Defaults()

Defaults sets default values for required properties, if they are not set

func (*ExternalConfig) Validate added in v0.2.0

func (ec *ExternalConfig) Validate() error

Validate checks if the provided ExternalConfig config does not contain invalid options

type FileConfigLoader

type FileConfigLoader struct {
	FilePath string
}

FileConfigLoader implements Loader by loading config from two files located at given paths.

func (FileConfigLoader) Load

func (l FileConfigLoader) Load() (*ExternalConfig, error)

Load implementation from Loader by using the properties of the FileConfigLoader.

type Global added in v0.2.0

type Global struct {
	Input Input `yaml:"input"`
}

Global holds the global configuration for the application.

func (*Global) Validate added in v0.2.0

func (g *Global) Validate() error

Validate checks if the provided Global config does not contain invalid options

type HeaderMapping added in v0.2.0

type HeaderMapping struct {
	Name  string `yaml:"name"`
	Alias string `yaml:"alias"`
}

HeaderMapping is a simple struct to hold a key-value pair for headers that should be included in the request. If Name is not set, the header will be included as is, otherwise the header will be included as the specified name.

type Input added in v0.2.0

type Input struct {
	HeaderMapping []*HeaderMapping `yaml:"header-mapping"`
}

Input holds input related configuration, such as global header to input mappings.

func (*Input) Validate added in v0.2.0

func (i *Input) Validate() error

Validate checks if the provided Input config does not contain invalid options

Jump to

Keyboard shortcuts

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