Documentation
¶
Index ¶
- Constants
- Variables
- func AddIdPrefix(id string) string
- func CheckFileExists(filepath string) (bool, error)
- func CleanMultilineString(str string) string
- func GetDomain(domain *Domain) (types.Domain, error)
- func GetProvider(provider *Provider, ctx context.Context) (types.Provider, error)
- func IsLulaLink(link oscalTypes.Link) bool
- func IsVersionValid(versionConstraint string, version string) (bool, error)
- func ReadFileToBytes(path string) ([]byte, error)
- func RemapPath(path string, baseDir string, newDir string) (string, error)
- func SetCwdToFileDir(dirPath string) (resetFunc func(), err error)
- func TrimIdPrefix(id string) string
- func ValidationFromString(raw, uuid string) (validation types.LulaValidation, err error)
- type Domain
- type Metadata
- type Provider
- type Validation
- func (validation *Validation) Lint() oscalValidation.ValidationResult
- func (v *Validation) MarshalYaml() ([]byte, error)
- func (validation *Validation) ToLulaValidation(uuid string) (lulaValidation types.LulaValidation, err error)
- func (v *Validation) ToResource() (resource *oscalTypes.Resource, err error)
- func (v *Validation) UnmarshalYaml(data []byte) error
Constants ¶
const ( UUID_PREFIX = "#" WILDCARD = "*" YAML_DELIMITER = "---" )
Variables ¶
var ( ErrInvalidSchema = errors.New("schema is invalid") ErrInvalidYaml = errors.New("error unmarshaling JSON") ErrInvalidVersion = errors.New("version is invalid") ErrInvalidDomain = errors.New("domain is invalid") ErrInvalidProvider = errors.New("provider is invalid") ErrInvalidTest = errors.New("test is invalid") )
Define base errors for validations
Functions ¶
func AddIdPrefix ¶ added in v0.3.0
AddIdPrefix adds the id prefix to the given id
func CheckFileExists ¶ added in v0.10.0
func CleanMultilineString ¶ added in v0.9.0
CleanMultilineString removes leading and trailing whitespace from a multiline string
func GetProvider ¶ added in v0.2.0
func IsLulaLink ¶ added in v0.3.0
func IsLulaLink(link oscalTypes.Link) bool
IsLulaLink checks if the link is a lula link
func IsVersionValid ¶ added in v0.1.0
Returns version validity
func ReadFileToBytes ¶
ReadFileToBytes reads a file to bytes
func RemapPath ¶ added in v0.16.0
RemapPath takes an input path, relative to the baseDir, and remaps it to be relative to the newDir Example: path = "folder/file.txt", baseDir = "/home/user/dir", newDir = "/home/user/newDir" output path = "../dir/folder/file.txt"
func SetCwdToFileDir ¶ added in v0.2.0
SetCwdToFileDir takes a path and changes the current working directory to the directory of the path
func TrimIdPrefix ¶ added in v0.3.0
TrimIdPrefix trims the id prefix from the given id
func ValidationFromString ¶ added in v0.2.0
func ValidationFromString(raw, uuid string) (validation types.LulaValidation, err error)
Converts a raw string to a Validation object (string -> common.Validation -> types.Validation)
Types ¶
type Domain ¶ added in v0.2.0
type Domain struct {
// Type is the type of domain: enum: kubernetes, api
Type string `json:"type" yaml:"type"`
// KubernetesSpec is the specification for a Kubernetes domain, required if type is kubernetes
KubernetesSpec *kube.KubernetesSpec `json:"kubernetes-spec,omitempty" yaml:"kubernetes-spec,omitempty"`
// ApiSpec is the specification for an API domain, required if type is api
ApiSpec *api.ApiSpec `json:"api-spec,omitempty" yaml:"api-spec,omitempty"`
// FileSpec is the specification for a File domain, required if type is file
FileSpec *files.Spec `json:"file-spec,omitempty" yaml:"file-spec,omitempty"`
}
Domain is a structure that contains the domain type and the corresponding spec
type Metadata ¶ added in v0.2.0
type Metadata struct {
Name string `json:"name" yaml:"name"`
UUID string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
Metadata is a structure that contains the name and uuid of a validation
type Provider ¶ added in v0.2.0
type Provider struct {
Type string `json:"type" yaml:"type"`
OpaSpec *opa.OpaSpec `json:"opa-spec,omitempty" yaml:"opa-spec,omitempty"`
KyvernoSpec *kyverno.KyvernoSpec `json:"kyverno-spec,omitempty" yaml:"kyverno-spec,omitempty"`
}
type Validation ¶ added in v0.2.0
type Validation struct {
LulaVersion string `json:"lula-version" yaml:"lula-version"`
Metadata *Metadata `json:"metadata,omitempty" yaml:"metadata,omitempty"`
Provider *Provider `json:"provider,omitempty" yaml:"provider,omitempty"`
Domain *Domain `json:"domain,omitempty" yaml:"domain,omitempty"`
Tests *[]types.LulaValidationTest `json:"tests,omitempty" yaml:"tests,omitempty"`
}
Data structures for ingesting validation data
func ReadValidationsFromYaml ¶ added in v0.4.0
func ReadValidationsFromYaml(validationBytes []byte) (validations []Validation, err error)
ReadValidationsFromYaml reads a yaml file of validations to an array of validations
func (*Validation) Lint ¶ added in v0.4.3
func (validation *Validation) Lint() oscalValidation.ValidationResult
Lint is a convenience method to lint a Validation object
func (*Validation) MarshalYaml ¶ added in v0.2.0
func (v *Validation) MarshalYaml() ([]byte, error)
MarshalYaml is a convenience method to marshal a Validation object to a YAML byte array
func (*Validation) ToLulaValidation ¶ added in v0.2.0
func (validation *Validation) ToLulaValidation(uuid string) (lulaValidation types.LulaValidation, err error)
ToLulaValidation converts a Validation object to a LulaValidation object
func (*Validation) ToResource ¶ added in v0.3.0
func (v *Validation) ToResource() (resource *oscalTypes.Resource, err error)
ToResource converts a Validation object to a Resource object
func (*Validation) UnmarshalYaml ¶ added in v0.2.0
func (v *Validation) UnmarshalYaml(data []byte) error
UnmarshalYaml is a convenience method to unmarshal a Validation object from a YAML byte array