provider

package
v0.0.0-...-16e85e8 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CapabilityRegoModule     = "rego_module"
	CapabilityRegoExpression = "rego_expr"
)

Capabilities

View Source
const ExpressionTemplate = `` /* 335-byte string literal not displayed */

ExpressionTemplate is the template that the parameters from the rego.expr capability will be injected into to create a complete module.

View Source
const (
	ProviderName = "k8s"
)

Variables

View Source
var InventoryModule string

Functions

This section is empty.

Types

type ConditionInfo

type ConditionInfo struct {
	Expression ExpressionCondition `json:"rego_expr" yaml:"rego_expr"`
	Module     ModuleCondition     `json:"rego_module" yaml:"rego_module"`
}

type ExpressionCondition

type ExpressionCondition struct {
	// Collection is the resource collection from the
	// base module that the expression should be evaluated against.
	Collection string `json:"collection"`
	// Expression is a single rego expression.
	Expression string `json:"expression"`
}

ExpressionCondition is the input for the rego_expr capability, which takes a single rego expression and injects it into a module template which will evaluate it in the context of a single resource collection.

type K8s

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

K8s provider

func New

func New() (k *K8s)

New constructs a new K8s provider.

func (*K8s) Capabilities

func (r *K8s) Capabilities() (caps []libprovider.Capability)

Capabilities returns the supported capabilities of the provider.

func (*K8s) Evaluate

func (r *K8s) Evaluate(ctx context.Context, cap string, conditionBytes []byte) (resp libprovider.ProviderEvaluateResponse, err error)

Evaluate a capability and return a result.

func (*K8s) GetDependencies

func (r *K8s) GetDependencies(ctx context.Context) (deps map[uri.URI][]*libprovider.Dep, err error)

func (*K8s) GetDependenciesDAG

func (r *K8s) GetDependenciesDAG(ctx context.Context) (dag map[uri.URI][]libprovider.DepDAGItem, err error)

func (*K8s) Init

func (r *K8s) Init(ctx context.Context, log logr.Logger, initCfg libprovider.InitConfig) (svc libprovider.ServiceClient, err error)

Init the provider. Reads in base Rego modules, kubeconfig, and pulls resources from the cluster.

func (*K8s) Stop

func (r *K8s) Stop()

type K8sInitConfig

type K8sInitConfig struct {
	libprovider.InitConfig
	ProviderSpecificConfig struct {
		// path to the cluster's kube config
		KubeConfig []byte `json:"kubeConfig"`
		// list of GVKs to evaluate rules against
		GroupVersionKinds []schema.GroupVersionKind `json:"groupVersionKinds"`
		// list of namespaces to collect resources from
		Namespaces []string `json:"namespaces"`
	}
}

K8sInitConfig is the provider init config with the k8s provider-specific fields unmarshalled.

func NewK8sInitConfig

func NewK8sInitConfig(initCfg libprovider.InitConfig) (k *K8sInitConfig, err error)

NewK8sInitConfig creates a k8s specific provider configuration from the generic provider init.

type ModuleCondition

type ModuleCondition struct {
	Module string `json:"module"`
}

ModuleCondition is the input for the rego_module capability, which takes an entire rego module and evaluates it.

type RegoIncident

type RegoIncident struct {
	Name       string `json:"name"`
	Namespace  string `json:"namespace"`
	ApiVersion string `json:"apiVersion"`
	Kind       string `json:"kind"`
}

RegoIncident describes the format that the output from each Rego rule must take.

func (RegoIncident) GroupVersion

func (r RegoIncident) GroupVersion() (group string, version string)

GroupVersion splits the resource's ApiVersion into an API group and a version.

Jump to

Keyboard shortcuts

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