Documentation ¶
Index ¶
- Constants
- func ParseServiceComputedFilePath(path string) (string, error)
- func ParseServiceInputPath(path string) (string, []string, error)
- type Device
- type DevicePath
- func (p *DevicePath) CheckSum() (string, error)
- func (p *DevicePath) DeviceActualConfigPath(t PathOpt) string
- func (p *DevicePath) DeviceConfigPath(t PathOpt) string
- func (p *DevicePath) DeviceDirPath(t PathOpt) string
- func (p *DevicePath) DevicePath(t PathOpt) string
- func (p *DevicePath) ReadActualDeviceConfigFile() ([]byte, error)
- func (p *DevicePath) ReadDeviceConfigFile() ([]byte, error)
- func (p *DevicePath) RootPath() string
- func (p *DevicePath) Validate() error
- func (p *DevicePath) WriteDeviceConfigFile(buf []byte) error
- type PathOpt
- type ServiceMeta
- type ServicePath
- func (p *ServicePath) ReadServiceComputedFile(device string) ([]byte, error)
- func (p *ServicePath) ReadServiceInput() ([]byte, error)
- func (p *ServicePath) ReadServiceMeta() (*ServiceMeta, error)
- func (p *ServicePath) ReadServiceTransform(cctx *cue.Context) (*ServiceTransformer, error)
- func (p *ServicePath) RootPath() string
- func (p *ServicePath) ServiceComputedDirPath(t PathOpt) string
- func (p *ServicePath) ServiceComputedPath(device string, t PathOpt) string
- func (p *ServicePath) ServiceDirPath(t PathOpt) string
- func (p *ServicePath) ServiceInputPath(t PathOpt) string
- func (p *ServicePath) ServiceMetaPath(t PathOpt) string
- func (p *ServicePath) ServicePath(t PathOpt) string
- func (p *ServicePath) ServiceTransformPath(t PathOpt) string
- func (p *ServicePath) Validate() error
- func (p *ServicePath) WriteServiceComputedFile(device string, buf []byte) error
- func (p *ServicePath) WriteServiceInputFile(buf []byte) error
- type ServiceTransformer
Constants ¶
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 ¶
ParseServiceComputedFilePath parses service computed filepath and returns its device name.
Types ¶
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
func NewDeviceFromBytes ¶
NewDeviceFromBytes creates Device from the given encoded cue bytes.
func ReadDevice ¶
ReadDevice reads the cue file at the specified path and creates Device.
type DevicePath ¶
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 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 ¶
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 ¶
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.