Documentation ¶
Overview ¶
configs helps with loading and parsing configuration files
Package configs helps with loading and parsing configuration files
Index ¶
- Constants
- func LoadRegoFiles(dir string) ([]string, error)
- func LoadUnstructured(dirs []string) ([]*unstructured.Unstructured, error)
- func LoadUnstructuredFromContents(files []*PolicyFile) ([]*unstructured.Unstructured, error)
- func NormalizeAncestry(val string) string
- func SuffixPredicate(suffix string) readPredicate
- type Configuration
- type File
- type Path
- type PolicyFile
Constants ¶
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
const (
OriginalName = GCPTargetName + "/originalName"
)
Variables ¶
This section is empty.
Functions ¶
func LoadRegoFiles ¶
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 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.
type PolicyFile ¶
PolicyFile represents a .yaml file with its path and contents, which may or may not have been loaded from the file system.