configs

package
v0.0.0-...-0da46e6 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

configs helps with loading and parsing configuration files

Package configs helps with loading and parsing configuration files

Index

Constants

View Source
const (
	K8STargetName = "admission.k8s.gatekeeper.sh"
	GCPTargetName = "validation.gcp.forsetisecurity.org"
	TFTargetName  = "validation.resourcechange.terraform.cloud.google.com"
)

TODO: Using constant from gcptarget/tftarget packages causes circular reference. Fix circular reference and use <package>.Name

View Source
const (
	OriginalName = GCPTargetName + "/originalName"
)

Variables

This section is empty.

Functions

func LoadRegoFiles

func LoadRegoFiles(dir string) ([]string, error)

LoadRegoFiles load rego policy library files from the given directory.

func LoadUnstructured

func LoadUnstructured(dirs []string) ([]*unstructured.Unstructured, error)

LoadUnstructured loads .yaml files from the provided directories as k8s unstructured.Unstructured types.

func LoadUnstructuredFromContents

func LoadUnstructuredFromContents(files []*PolicyFile) ([]*unstructured.Unstructured, error)

LoadUnstructuredFromContents loads provided file contents as k8s unstructured.Unstructured types.

func NormalizeAncestry

func NormalizeAncestry(val string) string

func SuffixPredicate

func SuffixPredicate(suffix string) readPredicate

SuffixPredicate returns read predicate that returns true if the file name has the specified suffix.

Types

type Configuration

type Configuration struct {
	GCPTemplates   []*cftemplates.ConstraintTemplate // Constraint Templates for GCP
	GCPConstraints []*unstructured.Unstructured      // Constraints for GCP
	K8STemplates   []*cftemplates.ConstraintTemplate // Constraint Templates for GKE
	K8SConstraints []*unstructured.Unstructured      // Constraints for GKE
	TFTemplates    []*cftemplates.ConstraintTemplate // Constraint Templates for TF
	TFConstraints  []*unstructured.Unstructured      // Constraints for TF
	// contains filtered or unexported fields
}

Configuration represents the configuration files fed into FCV.

func NewConfiguration

func NewConfiguration(dirs []string, libDir string) (*Configuration, error)

NewConfiguration returns the configuration from the list of provided directories.

func NewConfigurationFromContents

func NewConfigurationFromContents(unstructuredObjects []*unstructured.Unstructured, regoLib []string) (*Configuration, error)

NewConfigurationFromContents returns the configuration from the given unstructured objects and the rego library file contents. This can be used by code that may not have access to a file system and passes in the contents directly.

type File

type File struct {
	// Path is the path to the file.
	Path string
	// Content is the full contents for the file.
	Content []byte
}

File represents the contents of a file

type Path

type Path interface {
	// ReadAll will read the given file, or recursively read all files under the specified directory.
	ReadAll(ctx context.Context, predicates ...readPredicate) ([]File, error)
}

Path represents a path to a file or directory.

func NewPath

func NewPath(path string) (Path, error)

NewPath returns a new Path to a local or gcs file.

type PolicyFile

type PolicyFile struct {
	Path    string
	Content []byte
}

PolicyFile represents a .yaml file with its path and contents, which may or may not have been loaded from the file system.

Jump to

Keyboard shortcuts

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