policy

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const RulePrefix = "rule."

RulePrefix is the prefix of the rule name

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Name string

	Config hcl.Body

	TypeRange hcl.Range
	DeclRange hcl.Range

	// can ignore (TODO)
	Report *ReportConfig
}

Config is

type Local

type Local struct {
	Name string
	Expr hcl.Expression

	DeclRange hcl.Range
}

Local represents a single entry from a "locals" block in a module or file. The "locals" block itself is not represented, because it serves only to provide context for us to interpret its contents.

type Output

type Output struct {
	Name        string
	Description string
	Expr        hcl.Expression
	DependsOn   []hcl.Traversal
	Sensitive   bool

	DescriptionSet bool
	SensitiveSet   bool

	DeclRange hcl.Range
}

Output represents an "output" block in a module or file.

type Policy

type Policy struct {
	Config    *Config
	Rules     []*Rule
	Variables []*Variable
	Outputs   []*Output
}

Policy is

func Decode

func Decode(body hcl.Body) (*Policy, hcl.Diagnostics)

Decode is

func (Policy) BuildContext

func (p Policy) BuildContext(body hcl.Body, filename string, filedata []byte) (*hcl.EvalContext, hcl.Diagnostics)

BuildContext is

type Precondition

type Precondition struct {
	Config hcl.Body

	TypeRange hcl.Range
	DeclRange hcl.Range

	Cases []bool
}

Precondition is

type Report

type Report struct {
	Config hcl.Body

	TypeRange hcl.Range
	DeclRange hcl.Range

	Level   string
	Message string
}

Report is

type ReportConfig

type ReportConfig struct {
	Name string

	Config hcl.Body

	TypeRange hcl.Range
	DeclRange hcl.Range
}

ReportConfig is

type Rule

type Rule struct {
	Name string

	Config hcl.Body

	TypeRange hcl.Range
	DeclRange hcl.Range

	Description  string
	Dependencies []string
	Precondition *Precondition
	Conditions   []bool
	Report       *Report

	Debug []string
}

Rule isj

type Variable

type Variable struct {
	Name        string
	Description string
	Default     cty.Value
	Type        cty.Type
	ParsingMode VariableParsingMode

	DescriptionSet bool

	DeclRange hcl.Range
}

Variable represents a "variable" block in a module or file.

type VariableParsingMode

type VariableParsingMode rune

VariableParsingMode defines how values of a particular variable given by text-only mechanisms (command line arguments and environment variables) should be parsed to produce the final value.

const VariableParseHCL VariableParsingMode = 'H'

VariableParseHCL is a variable parsing mode that attempts to parse the given string as an HCL expression and returns the result.

const VariableParseLiteral VariableParsingMode = 'L'

VariableParseLiteral is a variable parsing mode that just takes the given string directly as a cty.String value.

func (VariableParsingMode) Parse

func (m VariableParsingMode) Parse(name, value string) (cty.Value, hcl.Diagnostics)

Parse uses the receiving parsing mode to process the given variable value string, returning the result along with any diagnostics.

A VariableParsingMode does not know the expected type of the corresponding variable, so it's the caller's responsibility to attempt to convert the result to the appropriate type and return to the user any diagnostics that conversion may produce.

The given name is used to create a synthetic filename in case any diagnostics must be generated about the given string value. This should be the name of the root module variable whose value will be populated from the given string.

If the returned diagnostics has errors, the returned value may not be valid.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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