Documentation ¶
Index ¶
- Variables
- func TfFilePathJoin(leading, trailing string) string
- type AutoDetector
- type CfnDetector
- type ConfigurationDetector
- type DetectOptions
- type HclConfiguration
- func (c *HclConfiguration) GetChild(name string) (*HclConfiguration, bool)
- func (c *HclConfiguration) GetOutput(name string) interface{}
- func (c *HclConfiguration) LoadedFiles() []string
- func (c *HclConfiguration) Location(path []string) (LocationStack, error)
- func (c *HclConfiguration) RegulaInput() RegulaInput
- type IACConfiguration
- type InputDirectory
- type InputFile
- type InputPath
- type InputType
- type KubernetesDetector
- type LoadPathsOptions
- type LoadedConfigurations
- type Location
- type LocationStack
- type NoLoadableConfigsError
- type RegulaInput
- type SourceInfoNode
- type TfDetector
- type TfNode
- type TfPlanDetector
- type UnsupportedOperationDiag
- type WalkFunc
Constants ¶
This section is empty.
Variables ¶
var InputTypeIDs = map[InputType][]string{ Auto: {"auto"}, TfPlan: {"tf-plan", "tf_plan"}, Cfn: {"cfn"}, Tf: {"tf"}, K8s: {"k8s", "kubernetes"}, }
InputTypeIDs maps the InputType enums to string values that can be specified in CLI options.
Functions ¶
func TfFilePathJoin ¶ added in v1.1.0
TfFilePathJoin is like `filepath.Join` but avoids cleaning the path. This allows to get unique paths for submodules including a parent module, e.g.:
. examples/mssql/../../ examples/complete/../../
Types ¶
type AutoDetector ¶
type AutoDetector struct {
// contains filtered or unexported fields
}
func NewAutoDetector ¶
func NewAutoDetector(detectors ...ConfigurationDetector) *AutoDetector
func (*AutoDetector) DetectDirectory ¶
func (a *AutoDetector) DetectDirectory(i InputDirectory, opts DetectOptions) (IACConfiguration, error)
func (*AutoDetector) DetectFile ¶
func (a *AutoDetector) DetectFile(i InputFile, opts DetectOptions) (IACConfiguration, error)
type CfnDetector ¶
type CfnDetector struct{}
func (*CfnDetector) DetectDirectory ¶
func (c *CfnDetector) DetectDirectory(i InputDirectory, opts DetectOptions) (IACConfiguration, error)
func (*CfnDetector) DetectFile ¶
func (c *CfnDetector) DetectFile(i InputFile, opts DetectOptions) (IACConfiguration, error)
type ConfigurationDetector ¶
type ConfigurationDetector interface { DetectDirectory(i InputDirectory, opts DetectOptions) (IACConfiguration, error) DetectFile(i InputFile, opts DetectOptions) (IACConfiguration, error) }
ConfigurationDetector implements the visitor part of the visitor pattern for the concrete InputPath implementations. A ConfigurationDetector implementation must contain functions to visit both directories and files. An empty implementation must return nil, nil to indicate that the InputPath has been ignored.
func DetectorByInputTypes ¶ added in v1.2.0
func DetectorByInputTypes(inputTypes []InputType) (ConfigurationDetector, error)
type DetectOptions ¶
DetectOptions are options passed to the configuration detectors.
type HclConfiguration ¶
type HclConfiguration struct {
// contains filtered or unexported fields
}
func ParseDirectory ¶
func ParseDirectory( path []string, dir string, moduleRegister *terraformModuleRegister, ) (*HclConfiguration, error)
func (*HclConfiguration) GetChild ¶
func (c *HclConfiguration) GetChild(name string) (*HclConfiguration, bool)
func (*HclConfiguration) GetOutput ¶
func (c *HclConfiguration) GetOutput(name string) interface{}
func (*HclConfiguration) LoadedFiles ¶
func (c *HclConfiguration) LoadedFiles() []string
func (*HclConfiguration) Location ¶
func (c *HclConfiguration) Location(path []string) (LocationStack, error)
func (*HclConfiguration) RegulaInput ¶
func (c *HclConfiguration) RegulaInput() RegulaInput
type IACConfiguration ¶
type IACConfiguration interface { // RegulaInput returns a input for regula. RegulaInput() RegulaInput // LoadedFiles are all of the files contained within this configuration. LoadedFiles() []string // Location resolves an attribute path to to a file, line and column. // The first element of the attributePath is usually the resource ID. Location(attributePath []string) (LocationStack, error) }
IACConfiguration is a loaded IaC Configuration.
type InputDirectory ¶
type InputPath ¶
type InputPath interface { DetectType(d ConfigurationDetector, opts DetectOptions) (IACConfiguration, error) IsDir() bool Path() string Name() string }
InputPath is a generic interface to represent both directories and files that can serve as inputs for a ConfigurationDetector.
type InputType ¶
type InputType int
InputType is a flag that determines which types regula should look for.
const ( // Auto means that regula will automatically try to determine which input types are // in the given paths. Auto InputType = iota // TfPlan means that regula will only look for Terraform plan JSON files in given // directories and it will assume that given files are Terraform plan JSON. TfPlan // Cfn means that regula will only look for CloudFormation template files in given // directories and it will assume that given files are CloudFormation YAML or JSON. Cfn // Tf means that regula will load the HCL in the directory in a similar // way to terraform plan, or it can also load individual files. Tf // Kubernetes manifests will be loaded K8s )
func InputTypeForString ¶
InputTypeForString is a utility function to translate the string name of an input type to an InputType enum
type KubernetesDetector ¶ added in v1.5.0
type KubernetesDetector struct{}
func (*KubernetesDetector) DetectDirectory ¶ added in v1.5.0
func (c *KubernetesDetector) DetectDirectory(i InputDirectory, opts DetectOptions) (IACConfiguration, error)
func (*KubernetesDetector) DetectFile ¶ added in v1.5.0
func (c *KubernetesDetector) DetectFile(i InputFile, opts DetectOptions) (IACConfiguration, error)
type LoadPathsOptions ¶
type LoadedConfigurations ¶
type LoadedConfigurations interface { // AddConfiguration adds a configuration entry for the given path AddConfiguration(path string, config IACConfiguration) // Location resolves a file path and attribute path from the regula output to a // location within a file. Location(path string, attributePath []string) (LocationStack, error) // AlreadyLoaded indicates whether the given path has already been loaded as part // of another IACConfiguration. AlreadyLoaded(path string) bool // RegulaInput renders the RegulaInput from all of the contained configurations. RegulaInput() []RegulaInput // Count returns the number of loaded configurations. Count() int }
LoadedConfigurations is a container for IACConfigurations loaded by Regula.
func LoadPaths ¶
func LoadPaths(options LoadPathsOptions) (LoadedConfigurations, error)
type LocationStack ¶ added in v1.1.0
type LocationStack = []Location
In some cases, we have more than one location, for example:
attribute "foo" at line 4... included in "rds" module at line 8... included in "main" module at line 3...
These are stored as a call stack, with the most specific location in the first position, and the "root of the call stack" at the last position.
type NoLoadableConfigsError ¶
type NoLoadableConfigsError struct {
// contains filtered or unexported fields
}
func (*NoLoadableConfigsError) Error ¶
func (e *NoLoadableConfigsError) Error() string
type RegulaInput ¶
type RegulaInput map[string]interface{}
RegulaInput is a generic map that can be fed to OPA for regula.
type SourceInfoNode ¶ added in v1.6.0
type SourceInfoNode struct {
// contains filtered or unexported fields
}
func LoadMultiSourceInfoNode ¶ added in v1.6.0
func LoadMultiSourceInfoNode(contents []byte) ([]SourceInfoNode, error)
LoadMultiSourceInfoNode parses YAML documents with multiple entries, or normal single YAML/JSON documents.
func LoadSourceInfoNode ¶ added in v1.6.0
func LoadSourceInfoNode(contents []byte) (*SourceInfoNode, error)
func (*SourceInfoNode) GetIndex ¶ added in v1.6.0
func (node *SourceInfoNode) GetIndex(index int) (*SourceInfoNode, error)
func (*SourceInfoNode) GetKey ¶ added in v1.6.0
func (node *SourceInfoNode) GetKey(key string) (*SourceInfoNode, error)
func (*SourceInfoNode) GetPath ¶ added in v1.6.0
func (node *SourceInfoNode) GetPath(path []string) (*SourceInfoNode, error)
GetPath tries to retrieve a path as far as possible.
func (*SourceInfoNode) Location ¶ added in v1.6.0
func (node *SourceInfoNode) Location() (int, int)
type TfDetector ¶
type TfDetector struct{}
func (*TfDetector) DetectDirectory ¶
func (t *TfDetector) DetectDirectory(i InputDirectory, opts DetectOptions) (IACConfiguration, error)
func (*TfDetector) DetectFile ¶
func (t *TfDetector) DetectFile(i InputFile, opts DetectOptions) (IACConfiguration, error)
type TfNode ¶
type TfNode struct { // Exactly one of the next three fields will be set. Object hcl.Body Array hcl.Blocks Attribute *hcl.Attribute // This will always be set. Range hcl.Range }
A `TfNode` represents a syntax tree in the HCL config.
type TfPlanDetector ¶
type TfPlanDetector struct{}
func (*TfPlanDetector) DetectDirectory ¶
func (t *TfPlanDetector) DetectDirectory(i InputDirectory, opts DetectOptions) (IACConfiguration, error)
func (*TfPlanDetector) DetectFile ¶
func (t *TfPlanDetector) DetectFile(i InputFile, opts DetectOptions) (IACConfiguration, error)
type UnsupportedOperationDiag ¶
type UnsupportedOperationDiag struct { }
func (UnsupportedOperationDiag) Description ¶
func (d UnsupportedOperationDiag) Description() tfdiags.Description
func (UnsupportedOperationDiag) FromExpr ¶
func (d UnsupportedOperationDiag) FromExpr() *tfdiags.FromExpr
func (UnsupportedOperationDiag) Severity ¶
func (d UnsupportedOperationDiag) Severity() tfdiags.Severity
func (UnsupportedOperationDiag) Source ¶
func (d UnsupportedOperationDiag) Source() tfdiags.Source