chart

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyID          = "id"
	KeyNamespace   = "namespace"
	KeyName        = "name"
	KeyAnnotations = "annotations"
	KeySpecs       = "specs"
	KeyInbounds    = "inbounds"
	KeyOutbounds   = "outbounds"
	KeyEnv         = "env"
)

Key constants for commonly used fields.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chart

type Chart struct {
	ID          uuid.UUID               `json:"id" bson:"_id" yaml:"id" map:"id" validate:"required"`
	Namespace   string                  `json:"namespace" bson:"namespace" yaml:"namespace" map:"namespace" validate:"required"`
	Name        string                  `json:"name,omitempty" bson:"name,omitempty" yaml:"name,omitempty" map:"name,omitempty"`
	Annotations map[string]string       `json:"annotations,omitempty" bson:"annotations,omitempty" yaml:"annotations,omitempty" map:"annotations,omitempty"`
	Specs       []*spec.Unstructured    `json:"specs" bson:"specs" yaml:"specs" map:"specs"`
	Inbounds    map[string][]spec.Port  `json:"inbounds,omitempty" bson:"inbounds,omitempty" yaml:"inbounds,omitempty" map:"inbounds,omitempty"`
	Outbounds   map[string][]spec.Port  `json:"outbounds,omitempty" bson:"outbounds,omitempty" yaml:"outbounds,omitempty" map:"outbounds,omitempty"`
	Env         map[string][]spec.Value `json:"env,omitempty" bson:"env,omitempty" yaml:"env,omitempty" map:"env,omitempty"`
}

Chart defines the structure that combines multiple nodes into a cluster node.

func New

func New() *Chart

New creates and returns a new instance of Chart.

func (*Chart) Bind

func (c *Chart) Bind(secrets ...*secret.Secret) error

Bind binds the chart's environment variables to the provided secrets.

func (*Chart) Build

func (c *Chart) Build(root spec.Spec) ([]spec.Spec, error)

Build constructs a specs based on the given spec.

func (*Chart) GetAnnotations

func (c *Chart) GetAnnotations() map[string]string

GetAnnotations returns the chart's annotations.

func (*Chart) GetEnv

func (c *Chart) GetEnv() map[string][]spec.Value

GetEnv returns the chart's environment data.

func (*Chart) GetID

func (c *Chart) GetID() uuid.UUID

GetID returns the chart's ID.

func (*Chart) GetInbounds added in v0.12.0

func (c *Chart) GetInbounds() map[string][]spec.Port

GetInbounds returns the chart's inbounds.

func (*Chart) GetName

func (c *Chart) GetName() string

GetName returns the chart's name.

func (*Chart) GetNamespace

func (c *Chart) GetNamespace() string

GetNamespace returns the chart's namespace.

func (*Chart) GetOutbounds added in v0.12.0

func (c *Chart) GetOutbounds() map[string][]spec.Port

GetOutbounds returns the chart's outbounds.

func (*Chart) GetSpecs

func (c *Chart) GetSpecs() []*spec.Unstructured

GetSpecs returns the chart's specs.

func (*Chart) IsBound

func (c *Chart) IsBound(secrets ...*secret.Secret) bool

IsBound checks whether any of the secrets are bound to the chart.

func (*Chart) SetAnnotations

func (c *Chart) SetAnnotations(val map[string]string)

SetAnnotations sets the chart's annotations.

func (*Chart) SetEnv

func (c *Chart) SetEnv(val map[string][]spec.Value)

SetEnv sets the chart's environment data.

func (*Chart) SetID

func (c *Chart) SetID(val uuid.UUID)

SetID sets the chart's ID.

func (*Chart) SetInbounds added in v0.12.0

func (c *Chart) SetInbounds(val map[string][]spec.Port)

SetInbounds sets the chart's inbounds.

func (*Chart) SetName

func (c *Chart) SetName(val string)

SetName sets the chart's name.

func (*Chart) SetNamespace

func (c *Chart) SetNamespace(val string)

SetNamespace sets the chart's namespace.

func (*Chart) SetOutbounds added in v0.12.0

func (c *Chart) SetOutbounds(val map[string][]spec.Port)

SetOutbounds sets the chart's outbounds.

func (*Chart) SetSpecs

func (c *Chart) SetSpecs(val []*spec.Unstructured)

SetSpecs sets the chart's specs.

type LinkHook

type LinkHook interface {
	// Link processes the loading of a chart and may return an error.
	Link(*Chart) error
}

LinkHook defines an interface for handling the loading of a chart.

func LinkFunc

func LinkFunc(link func(*Chart) error) LinkHook

LinkFunc creates a LoadHook from the given function.

type LinkHooks

type LinkHooks []LinkHook
func (h LinkHooks) Link(chrt *Chart) error

type Linker

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

Linker manages chart loading and unloading.

func NewLinker

func NewLinker(s *scheme.Scheme) *Linker

NewLinker creates a new Linker.

func (l *Linker) Link(chrt *Chart) error

Link loads the chart, creating nodes and symbols.

func (l *Linker) Unlink(chrt *Chart) error

Unlink removes the chart from the scheme.

type Loader

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

Loader synchronizes with spec.Store to load spec.Spec into the Table.

func NewLoader

func NewLoader(config LoaderConfig) *Loader

NewLoader creates a new Loader instance with the provided configuration.

func (*Loader) Load

func (l *Loader) Load(ctx context.Context, charts ...*Chart) error

Load loads charts and binds them with secrets, then inserts them into the table.

type LoaderConfig

type LoaderConfig struct {
	Table       *Table       // Lookup table for storing loaded symbols
	ChartStore  Store        // ChartStore to retrieve charts from
	SecretStore secret.Store // SecretStore to retrieve secrets from
}

LoaderConfig holds configuration for the Loader.

type Store

type Store resource.Store[*Chart]

Store is an alias for the resource.Store interface, specialized for Chart resources.

func NewStore

func NewStore() Store

NewStore creates and returns a new instance of a Store for managing Chart resources.

type Stream

type Stream = resource.Stream

type Table

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

Table manages charts and their references, allowing insertion, lookup, and removal.

func NewTable

func NewTable(opts ...TableOption) *Table

NewTable creates and returns a new Table instance with the provided options.

func (*Table) Close

func (t *Table) Close() error

Close removes all charts from the table and unloads them.

func (*Table) Free

func (t *Table) Free(id uuid.UUID) (bool, error)

Free removes a chart from the table based on its UUID and unloads it.

func (*Table) Insert

func (t *Table) Insert(chrt *Chart) error

Insert adds a new chart to the table, freeing the previous chart if it exists.

func (*Table) Keys

func (t *Table) Keys() []uuid.UUID

Keys returns all IDs of charts in the table.

func (t *Table) Links(id uuid.UUID) []*Chart

Links returns the charts linked to the chart specified by its UUID.

func (*Table) Lookup

func (t *Table) Lookup(id uuid.UUID) *Chart

Lookup retrieves a chart from the table based on its UUID.

type TableOption

type TableOption struct {
	LinkHooks   []LinkHook   // LoadHooks are functions executed when symbols are loaded.
	UnlinkHooks []UnlinkHook // UnloadHooks are functions executed when symbols are unloaded.
}

TableOption holds configurations for a Table instance.

type UnlinkHook

type UnlinkHook interface {
	// Unlink is called when a chart is unloaded and may return an error.
	Unlink(*Chart) error
}

UnlinkHook defines an interface for handling the unloading of a chart.

func UnlinkFunc

func UnlinkFunc(unlink func(*Chart) error) UnlinkHook

UnlinkFunc creates an UnloadHook from the given function.

type UnlinkHooks

type UnlinkHooks []UnlinkHook

UnlinkHooks is a slice of UnloadHook, processed in reverse order.

func (h UnlinkHooks) Unlink(chrt *Chart) error

Jump to

Keyboard shortcuts

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