Documentation ¶
Overview ¶
Package engine manages the acquisition and compilation of Timoni's CUE modules.
Index ¶
- Constants
- func CopyModule(srcDir string, dstDir string) (err error)
- func ExtractValueFromBytes(ctx *cue.Context, data []byte, expr string) (cue.Value, error)
- func ExtractValueFromFile(ctx *cue.Context, filePath, expr string) (cue.Value, error)
- func MergeValue(overlay, base cue.Value) (cue.Value, error)
- func ReadIgnoreFile(moduleRoot string) ([]string, error)
- type Bundle
- type BundleBuilder
- type BundleInstance
- type Fetcher
- type Injector
- type ModuleBuilder
- func (b *ModuleBuilder) Build() (cue.Value, error)
- func (b *ModuleBuilder) GetAPIVersion(value cue.Value) (string, error)
- func (b *ModuleBuilder) GetApplySets(value cue.Value) ([]ResourceSet, error)
- func (b *ModuleBuilder) GetDefaultValues() (string, error)
- func (b *ModuleBuilder) GetModuleName() (string, error)
- func (b *ModuleBuilder) GetValues(value cue.Value) (string, error)
- func (b *ModuleBuilder) MergeValuesFile(overlays [][]byte) error
- func (b *ModuleBuilder) SetVersionInfo(moduleVersion, kubeVersion string)
- func (b *ModuleBuilder) WriteSchemaFile() error
- func (b *ModuleBuilder) WriteValuesFileWithDefaults(val cue.Value) error
- type ModuleVersion
- type ResourceSet
- type ValuesBuilder
Constants ¶
const LatestTag = "latest"
LatestTag is the OCI tag name used to denote the latest stable version of a module.
Variables ¶
This section is empty.
Functions ¶
func CopyModule ¶ added in v0.0.4
CopyModule copies the given module to the destination directory, while excluding files that match the timoni.ignore patterns.
func ExtractValueFromBytes ¶ added in v0.3.0
func ExtractValueFromFile ¶ added in v0.0.4
ExtractValueFromFile compiles the given file and returns the CUE value that matches the given expression.
func MergeValue ¶ added in v0.0.4
MergeValue merges the given overlay on top of the base CUE value. New fields from the overlay are added to the base and existing fields are overridden with the overlay values.
func ReadIgnoreFile ¶ added in v0.6.0
ReadIgnoreFile returns the ignore patters found in the module root.
Types ¶
type Bundle ¶ added in v0.5.0
type Bundle struct { Name string Instances []BundleInstance }
type BundleBuilder ¶ added in v0.4.0
type BundleBuilder struct {
// contains filtered or unexported fields
}
BundleBuilder compiles CUE definitions to Go Bundle objects.
func NewBundleBuilder ¶ added in v0.4.0
func NewBundleBuilder(ctx *cue.Context, files []string) *BundleBuilder
NewBundleBuilder creates a BundleBuilder for the given module and package.
func (*BundleBuilder) Build ¶ added in v0.4.0
func (b *BundleBuilder) Build() (cue.Value, error)
Build builds a CUE instance for the specified files and returns the CUE value. A workspace must be initialised with InitWorkspace before calling this function.
func (*BundleBuilder) GetBundle ¶ added in v0.5.0
func (b *BundleBuilder) GetBundle(v cue.Value) (*Bundle, error)
GetBundle returns a Bundle from the bundle CUE value.
func (*BundleBuilder) InitWorkspace ¶ added in v0.9.0
func (b *BundleBuilder) InitWorkspace(workspace string) error
InitWorkspace copies the bundle definitions to the specified workspace, sets the bundle schema, and then it injects values based on @timoni() attributes. A workspace must be initialised before calling Build.
type BundleInstance ¶ added in v0.4.0
type Fetcher ¶
type Fetcher struct {
// contains filtered or unexported fields
}
Fetcher downloads a module and extracts it locally.
func NewFetcher ¶
NewFetcher creates a Fetcher for the given module.
func (*Fetcher) Fetch ¶
func (f *Fetcher) Fetch() (*apiv1.ModuleReference, error)
Fetch downloads a remote module locally into tmp.
func (*Fetcher) GetModuleRoot ¶
func (*Fetcher) GetVersions ¶ added in v0.4.0
func (f *Fetcher) GetVersions() ([]ModuleVersion, error)
GetVersions returns a list of OCI tags and their digests. The list is ordered based on semver, newest version first.
type Injector ¶ added in v0.9.0
type Injector struct {
// contains filtered or unexported fields
}
Injector injects field values in CUE files based on @timoni() attributes.
func NewInjector ¶ added in v0.9.0
NewInjector creates an Injector for the given context.
type ModuleBuilder ¶ added in v0.0.4
type ModuleBuilder struct {
// contains filtered or unexported fields
}
ModuleBuilder compiles CUE definitions to Kubernetes objects.
func NewModuleBuilder ¶ added in v0.0.4
func NewModuleBuilder(ctx *cue.Context, name, namespace, moduleRoot, pkgName string) *ModuleBuilder
NewModuleBuilder creates a ModuleBuilder for the given module and package.
func (*ModuleBuilder) Build ¶ added in v0.0.4
func (b *ModuleBuilder) Build() (cue.Value, error)
Build builds a CUE instances for the specified package and returns the CUE value.
func (*ModuleBuilder) GetAPIVersion ¶ added in v0.0.6
func (b *ModuleBuilder) GetAPIVersion(value cue.Value) (string, error)
GetAPIVersion returns the list of API version of the Timoni's CUE definition.
func (*ModuleBuilder) GetApplySets ¶ added in v0.0.5
func (b *ModuleBuilder) GetApplySets(value cue.Value) ([]ResourceSet, error)
GetApplySets returns the list of Kubernetes unstructured objects to be applied in steps.
func (*ModuleBuilder) GetDefaultValues ¶ added in v0.0.4
func (b *ModuleBuilder) GetDefaultValues() (string, error)
GetDefaultValues extracts the default values from the module.
func (*ModuleBuilder) GetModuleName ¶ added in v0.0.4
func (b *ModuleBuilder) GetModuleName() (string, error)
GetModuleName returns the module name as defined in 'cue.mod/module.cue'.
func (*ModuleBuilder) GetValues ¶ added in v0.0.4
func (b *ModuleBuilder) GetValues(value cue.Value) (string, error)
GetValues extracts the values from the build result.
func (*ModuleBuilder) MergeValuesFile ¶ added in v0.0.4
func (b *ModuleBuilder) MergeValuesFile(overlays [][]byte) error
MergeValuesFile merges the given values overlays into the module's root values.cue.
func (*ModuleBuilder) SetVersionInfo ¶ added in v0.12.0
func (b *ModuleBuilder) SetVersionInfo(moduleVersion, kubeVersion string)
SetVersionInfo allows setting the Timoni module version and Kubernetes version, which are injected at build time as optional CUE tags.
func (*ModuleBuilder) WriteSchemaFile ¶ added in v0.5.0
func (b *ModuleBuilder) WriteSchemaFile() error
WriteSchemaFile generates the module's instance schema.
func (*ModuleBuilder) WriteValuesFileWithDefaults ¶ added in v0.8.2
func (b *ModuleBuilder) WriteValuesFileWithDefaults(val cue.Value) error
WriteValuesFileWithDefaults merges the module's root values.cue with the supplied value.
type ModuleVersion ¶ added in v0.4.0
type ResourceSet ¶ added in v0.0.5
type ResourceSet struct { // Name of the object list. Name string `json:"name"` // Objects holds the list of Kubernetes objects. // +optional Objects []*unstructured.Unstructured `json:"objects,omitempty"` }
ResourceSet is a named list of Kubernetes resource objects.
func GetResources ¶ added in v0.0.5
func GetResources(value cue.Value) ([]ResourceSet, error)
GetResources converts the CUE value to a list of ResourceSets.
type ValuesBuilder ¶ added in v0.0.4
type ValuesBuilder struct {
// contains filtered or unexported fields
}
ValuesBuilder compiles and merges values files.
func NewValuesBuilder ¶ added in v0.0.4
func NewValuesBuilder(ctx *cue.Context) *ValuesBuilder
NewValuesBuilder creates a ValuesBuilder for the given context.
func (*ValuesBuilder) MergeValues ¶ added in v0.0.4
MergeValues merges the given overlays in order using the base as the starting point.