kuesta

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: MIT Imports: 15 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DirServices         = "services"
	DirDevices          = "devices"
	DirComputed         = "computed"
	FileInputCue        = "input.cue"
	FileTransformCue    = "transform.cue"
	FileServiceMetaYaml = "metadata.yaml"
	FileConfigCue       = "config.cue"
	FileActualConfigCue = "actual_config.cue"
)

Variables

This section is empty.

Functions

func ParseServiceComputedFilePath

func ParseServiceComputedFilePath(path string) (string, error)

ParseServiceComputedFilePath parses service computed filepath and returns its device name.

func ParseServiceInputPath

func ParseServiceInputPath(path string) (string, []string, error)

ParseServiceInputPath parses service model `input.cue` filepath and returns its service and keys.

Types

type Device

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

func NewDevice

func NewDevice(v cue.Value) *Device

NewDevice creates Device with the given cue.Value.

func NewDeviceFromBytes

func NewDeviceFromBytes(cctx *cue.Context, buf []byte) (*Device, error)

NewDeviceFromBytes creates Device from the given encoded cue bytes.

func ReadDevice

func ReadDevice(cctx *cue.Context, path string) (*Device, error)

ReadDevice reads the cue file at the specified path and creates Device.

func (*Device) Config

func (d *Device) Config() ([]byte, error)

Config returns the device config bytes.

func (*Device) Value

func (d *Device) Value() cue.Value

type DevicePath

type DevicePath struct {
	RootDir string `validate:"required"`

	Device string
}

func NewDevicePathList

func NewDevicePathList(dir string) ([]*DevicePath, error)

NewDevicePathList returns the slice of DevicePath placed in the given root dir.

func (*DevicePath) CheckSum

func (p *DevicePath) CheckSum() (string, error)

CheckSum returns the SHA256 checksum of the device config.

func (*DevicePath) DeviceActualConfigPath

func (p *DevicePath) DeviceActualConfigPath(t PathOpt) string

DeviceActualConfigPath returns the path to specified device actual config.

func (*DevicePath) DeviceConfigPath

func (p *DevicePath) DeviceConfigPath(t PathOpt) string

DeviceConfigPath returns the path to specified device config.

func (*DevicePath) DeviceDirPath

func (p *DevicePath) DeviceDirPath(t PathOpt) string

DeviceDirPath returns the path to the devices directory.

func (*DevicePath) DevicePath

func (p *DevicePath) DevicePath(t PathOpt) string

DevicePath returns the path to the devices directory.

func (*DevicePath) ReadActualDeviceConfigFile

func (p *DevicePath) ReadActualDeviceConfigFile() ([]byte, error)

ReadActualDeviceConfigFile loads the device actual config.

func (*DevicePath) ReadDeviceConfigFile

func (p *DevicePath) ReadDeviceConfigFile() ([]byte, error)

ReadDeviceConfigFile loads the device config.

func (*DevicePath) RootPath

func (p *DevicePath) RootPath() string

RootPath returns the path to repository root.

func (*DevicePath) Validate

func (p *DevicePath) Validate() error

Validate validates exposed fields according to the `validate` tag.

func (*DevicePath) WriteDeviceConfigFile

func (p *DevicePath) WriteDeviceConfigFile(buf []byte) error

WriteDeviceConfigFile writes the merged device config to the corresponding device dir.

type PathOpt

type PathOpt string
const (
	ExcludeRoot PathOpt = ""
	IncludeRoot PathOpt = "INCLUDE_ROOT"
)

type ServiceMeta

type ServiceMeta struct {
	Kind         string `yaml:"kind,omitempty"`         // Kind of the model.
	Organization string `yaml:"organization,omitempty"` // Organization publishing the model.
	Version      string `yaml:"version,omitempty"`      // Semantic version of the model.
	Description  string `yaml:"description"`
}

func ReadServiceMeta

func ReadServiceMeta(path string) (*ServiceMeta, error)

ReadServiceMeta returns ServiceMeta loaded from the metadata file on the given path.

func ReadServiceMetaAll

func ReadServiceMetaAll(dir string) ([]*ServiceMeta, error)

ReadServiceMetaAll loads all service meta stored in the git repo.

func (*ServiceMeta) ModelData

func (m *ServiceMeta) ModelData() *pb.ModelData

ModelData returns the gnmi.ModelData.

type ServicePath

type ServicePath struct {
	RootDir string `validate:"required"`

	Service string
	Keys    []string `validate:"dive,required"`
}

func NewServicePathList

func NewServicePathList(dir string) ([]*ServicePath, error)

NewServicePathList returns the slice of ServicePath placed in the given root dir.

func (*ServicePath) ReadServiceComputedFile

func (p *ServicePath) ReadServiceComputedFile(device string) ([]byte, error)

ReadServiceComputedFile loads the partial device config computed from specified service.

func (*ServicePath) ReadServiceInput

func (p *ServicePath) ReadServiceInput() ([]byte, error)

ReadServiceInput loads the specified service's input file.

func (*ServicePath) ReadServiceMeta

func (p *ServicePath) ReadServiceMeta() (*ServiceMeta, error)

ReadServiceMeta loads the service meta.

func (*ServicePath) ReadServiceTransform

func (p *ServicePath) ReadServiceTransform(cctx *cue.Context) (*ServiceTransformer, error)

ReadServiceTransform loads the specified service's transform file.

func (*ServicePath) RootPath

func (p *ServicePath) RootPath() string

RootPath returns the path to repository root.

func (*ServicePath) ServiceComputedDirPath

func (p *ServicePath) ServiceComputedDirPath(t PathOpt) string

ServiceComputedDirPath returns the path to the specified service's computed dir.

func (*ServicePath) ServiceComputedPath

func (p *ServicePath) ServiceComputedPath(device string, t PathOpt) string

ServiceComputedPath returns the path to the specified service's computed result of given device.

func (*ServicePath) ServiceDirPath

func (p *ServicePath) ServiceDirPath(t PathOpt) string

ServiceDirPath returns the path to the service directory.

func (*ServicePath) ServiceInputPath

func (p *ServicePath) ServiceInputPath(t PathOpt) string

ServiceInputPath returns the path to the specified service's input file.

func (*ServicePath) ServiceMetaPath

func (p *ServicePath) ServiceMetaPath(t PathOpt) string

ServiceMetaPath returns the path to the service meta.

func (*ServicePath) ServicePath

func (p *ServicePath) ServicePath(t PathOpt) string

ServicePath returns the path to the specified service.

func (*ServicePath) ServiceTransformPath

func (p *ServicePath) ServiceTransformPath(t PathOpt) string

ServiceTransformPath returns the path to the specified service's transform file.

func (*ServicePath) Validate

func (p *ServicePath) Validate() error

Validate validates exposed fields according to the `validate` tag.

func (*ServicePath) WriteServiceComputedFile

func (p *ServicePath) WriteServiceComputedFile(device string, buf []byte) error

WriteServiceComputedFile writes the partial device config computed from service to the corresponding computed dir.

func (*ServicePath) WriteServiceInputFile

func (p *ServicePath) WriteServiceInputFile(buf []byte) error

WriteServiceInputFile writes the supplied service's input file.

type ServiceTransformer

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

func NewServiceTransformer

func NewServiceTransformer(v cue.Value) *ServiceTransformer

NewServiceTransformer creates ServiceTransformer with the given cue.Value.

func ReadServiceTransformer

func ReadServiceTransformer(cctx *cue.Context, filepaths []string, dir string) (*ServiceTransformer, error)

ReadServiceTransformer builds cue.Instance from the specified files and returns ServiceTransformer.

func (*ServiceTransformer) Apply

func (t *ServiceTransformer) Apply(input cue.Value) (*cue.Iterator, error)

Apply performs cue evaluation of transform.cue using given input. It returns cue.Iterator which iterates items including device name label and device config cue.Value.

func (*ServiceTransformer) ConvertInputType

func (t *ServiceTransformer) ConvertInputType(input map[string]string) (map[string]any, error)

ConvertInputType converts the type of given input according to the type defined as #Input in transform.cue.

func (*ServiceTransformer) InputKeys

func (t *ServiceTransformer) InputKeys() ([]string, error)

InputKeys returns unique keys of input specified at the kuesta tag.

func (*ServiceTransformer) Value

func (t *ServiceTransformer) Value() cue.Value

Value returns the cue value contained.

Jump to

Keyboard shortcuts

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