blueprint

package
v0.0.0-...-bdb2e15 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: Apache-2.0, MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const BlueprintFileName = "blueprint.cue"

Variables

View Source
var (
	ErrVersionNotFound = errors.New("version not found")
)

Functions

This section is empty.

Types

type BlueprintFile

type BlueprintFile struct {
	Path    string
	Value   cue.Value
	Version *semver.Version
}

BlueprintFile represents a single blueprint file.

func NewBlueprintFile

func NewBlueprintFile(ctx *cue.Context, path string, contents []byte) (BlueprintFile, error)

NewBlueprintFile creates a new BlueprintFile from the given CUE context, path, and contents. The contents are compiled and validated, including injecting any necessary environment variables. Additionally, the version is extracted from the CUE value. If the version is not found or invalid, or the final CUE value is invalid, an error is returned.

type BlueprintFiles

type BlueprintFiles []BlueprintFile

BlueprintFiles represents a collection of blueprint files.

func (BlueprintFiles) Unify

func (b BlueprintFiles) Unify(ctx *cue.Context) (cue.Value, error)

Unify unifies the blueprints into a single CUE value. If the unification fails, an error is returned.

func (BlueprintFiles) ValidateMajorVersions

func (b BlueprintFiles) ValidateMajorVersions() error

validateMajors validates the major versions of the blueprints. If the blueprints have different major versions, an error is returned.

func (BlueprintFiles) Version

func (b BlueprintFiles) Version() *semver.Version

Version returns the highest version number from the blueprints. If there are no blueprints, nil is returned.

type BlueprintLoader

type BlueprintLoader interface {
	// Load loads the blueprint.
	Load(projectPath, gitRootPath string) (RawBlueprint, error)
}

BlueprintLoader is an interface for loading blueprints.

type DefaultBlueprintLoader

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

DefaultBlueprintLoader is the default implementation of the BlueprintLoader

func NewCustomBlueprintLoader

func NewCustomBlueprintLoader(
	ctx *cue.Context,
	fs afero.Fs,
	logger *slog.Logger,
) DefaultBlueprintLoader

NewCustomBlueprintLoader creates a new DefaultBlueprintLoader with custom dependencies.

func NewDefaultBlueprintLoader

func NewDefaultBlueprintLoader(ctx *cue.Context, logger *slog.Logger) DefaultBlueprintLoader

NewDefaultBlueprintLoader creates a new DefaultBlueprintLoader.

func (*DefaultBlueprintLoader) Load

func (b *DefaultBlueprintLoader) Load(projectPath, gitRootPath string) (RawBlueprint, error)

type RawBlueprint

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

RawBlueprint represents a raw (undecoded) blueprint.

func NewRawBlueprint

func NewRawBlueprint(v cue.Value) RawBlueprint

NewRawBlueprint creates a new raw blueprint.

func (*RawBlueprint) Decode

func (r *RawBlueprint) Decode() (schema.Blueprint, error)

Decode decodes the raw blueprint into a schema.Blueprint.

func (RawBlueprint) DecodePath

func (r RawBlueprint) DecodePath(path string, x interface{}) error

DecodePath decodes a path from the raw blueprint to the given interface.

func (RawBlueprint) Get

func (r RawBlueprint) Get(path string) cue.Value

Get returns a value from the raw blueprint.

func (RawBlueprint) MarshalJSON

func (r RawBlueprint) MarshalJSON() ([]byte, error)

MarshalJSON marshals the raw blueprint into JSON.

func (RawBlueprint) Validate

func (r RawBlueprint) Validate() error

Validate validates the raw blueprint is valid with concrete values.

func (RawBlueprint) Value

func (r RawBlueprint) Value() cue.Value

Value returns the raw blueprint value.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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