common

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UUID_PREFIX    = "#"
	WILDCARD       = "*"
	YAML_DELIMITER = "---"
)

Variables

This section is empty.

Functions

func AddIdPrefix added in v0.3.0

func AddIdPrefix(id string) string

AddIdPrefix adds the id prefix to the given id

func GetDomain added in v0.2.0

func GetDomain(domain *Domain, ctx context.Context) types.Domain

Get the domain and providers

func GetProvider added in v0.2.0

func GetProvider(provider *Provider, ctx context.Context) types.Provider
func IsLulaLink(link oscalTypes_1_1_2.Link) bool

IsLulaLink checks if the link is a lula link

func IsVersionValid added in v0.1.0

func IsVersionValid(versionConstraint string, version string) (bool, error)

Returns version validity

func ReadFileToBytes

func ReadFileToBytes(path string) ([]byte, error)

ReadFileToBytes reads a file to bytes

func SetCwdToFileDir added in v0.2.0

func SetCwdToFileDir(dirPath string) (resetFunc func(), err error)

SetCwdToFileDir takes a path and changes the current working directory to the directory of the path

func TrimIdPrefix added in v0.3.0

func TrimIdPrefix(id string) string

TrimIdPrefix trims the id prefix from the given id

func ValidationFromString added in v0.2.0

func ValidationFromString(raw 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           string               `json:"type" yaml:"type"`
	KubernetesSpec *kube.KubernetesSpec `json:"kubernetes-spec,omitempty" yaml:"kubernetes-spec,omitempty"`
	ApiSpec        *api.ApiSpec         `json:"api-spec,omitempty" yaml:"api-spec,omitempty"`
}

type Metadata added in v0.2.0

type Metadata struct {
	Name string `json:"name" yaml:"name"`
	UUID string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}

TODO: Perhaps extend this structure with other needed information, such as UUID or type of validation if workflow is needed

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"`
}

Data structures for ingesting validation data

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() (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_1_1_2.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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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