translator

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const LatestVersion = "latest"

Variables

This section is empty.

Functions

This section is empty.

Types

type OrderedComponentMap added in v0.6.0

type OrderedComponentMap struct {
	// Keys is the list of keys in the order they were added.
	Keys []string
	// Values is the map of keys to values.
	Values map[string]config.Component
}

OrderedComponentMap is a generic map that maintains the order of insertion. It is used to ensure that the order of components and properties is preserved when generating the configuration.

func NewOrderedComponentMap added in v0.6.0

func NewOrderedComponentMap() *OrderedComponentMap

func (*OrderedComponentMap) Get added in v0.6.0

Get retrieves a value from the ordered map by key.

func (*OrderedComponentMap) Items added in v0.6.0

Items returns a Go iterable

func (*OrderedComponentMap) Set added in v0.6.0

func (om *OrderedComponentMap) Set(key string, value config.Component)

Set adds a key-value pair to the ordered map.

type SubstitutionContext

type SubstitutionContext map[string]string

type Substitutor

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

func NewSubstitutor

func NewSubstitutor() *Substitutor

func (*Substitutor) AddContext

func (s *Substitutor) AddContext(name string, context SubstitutionContext, priority int)

AddContext adds an entire new context to the substitutor. The context is a map of key-value pairs that will be used for substitutions.

func (*Substitutor) AddSubstitution

func (s *Substitutor) AddSubstitution(ctx, key, value string)

AddSubstitution adds a single key-value pair to a context. If the context doesn't exist, it will be created.

func (*Substitutor) DoSubstitutions

func (s *Substitutor) DoSubstitutions(input string) string

func (*Substitutor) SetPriority

func (s *Substitutor) SetPriority(name string, priority int)

type Translator

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

A Translator is responsible for translating an HPSF document into a collection of components, and then further rendering those into configuration files.

func NewEmptyTranslator

func NewEmptyTranslator() *Translator

NewEmptyTranslator creates a translator with no components loaded.

func NewTranslator deprecated

func NewTranslator() (*Translator, error)

Deprecated: use NewEmptyTranslator and InstallComponents instead

func (*Translator) GenerateConfig

func (t *Translator) GenerateConfig(h *hpsf.HPSF, ct hpsftypes.Type, artifactVersion string, userdata map[string]any) (tmpl.TemplateConfig, error)

func (*Translator) GetComponents added in v0.2.0

func (t *Translator) GetComponents() map[string]config.TemplateComponent

GetComponents returns the components installed in the translator.

func (*Translator) GetTemplates added in v0.2.0

func (t *Translator) GetTemplates() map[string]hpsf.HPSF

GetTemplates returns the templates installed in the translator.

func (*Translator) InstallComponents

func (t *Translator) InstallComponents(components map[string]config.TemplateComponent)

InstallComponents installs the given components into the translator.

func (*Translator) InstallTemplates added in v0.2.0

func (t *Translator) InstallTemplates(components map[string]hpsf.HPSF)

InstallTemplates installs the given templates into the translator.

func (*Translator) LoadEmbeddedComponents

func (t *Translator) LoadEmbeddedComponents() error

LoadEmbeddedComponents loads the embedded components into the translator. Deprecated: use InstallComponents instead

func (*Translator) MakeConfigComponent

func (t *Translator) MakeConfigComponent(component *hpsf.Component, artifactVersion string) (config.Component, error)

func (*Translator) ValidateConfig added in v0.3.0

func (t *Translator) ValidateConfig(h *hpsf.HPSF) error

ValidateConfig validates the configuration of the HPSF document as it stands with respect to the components and templates installed in the translator. Note that it returns a validation.Result so that the errors can be collected and reported in a structured way. This allows for multiple validation errors to be returned at once, rather than stopping at the first error. This is useful for providing feedback to users on multiple issues in their configuration.

Jump to

Keyboard shortcuts

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