linter

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2020 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Counter = 0

Counter used to generate an ID for providers

Functions

func CombineValidationReports

func CombineValidationReports(r1, r2 assertion.ValidationReport) assertion.ValidationReport

CombineValidationReports merges results from two separate Validate runs

func Funcs added in v0.0.19

func Funcs() map[string]ast.Function

Types

type CSVResourceLoader added in v0.0.19

type CSVResourceLoader struct {
	Columns []assertion.ColumnConfig
}

CSVResourceLoader loads a list of Resource objects based on the list of ResourceConfig objects

func (CSVResourceLoader) Load added in v0.0.19

func (l CSVResourceLoader) Load(filename string) (FileResources, error)

Load converts a text file into a collection of Resource objects

func (CSVResourceLoader) PostLoad added in v0.0.19

PostLoad does no additional processing fro a CSVResourceLoader

type FileLinter

type FileLinter struct {
	Filenames   []string
	ValueSource assertion.ValueSource
	Loader      FileResourceLoader
}

FileLinter provides implementation for some common functions that are used by multiple Linter implementations

func (FileLinter) Search

func (fl FileLinter) Search(ruleSet assertion.RuleSet, searchExpression string, w io.Writer)

Search evaluates a JMESPath expression against resources in a collection of filenames

func (FileLinter) Validate

func (fl FileLinter) Validate(ruleSet assertion.RuleSet, options Options) (assertion.ValidationReport, error)

Validate validates a collection of filenames using a RuleSet

type FileResourceLoader

type FileResourceLoader interface {
	Load(filename string) (FileResources, error)
	PostLoad(resources FileResources) ([]assertion.Resource, error)
}

FileResourceLoader provides the interface that a Linter needs to load a collection of Resource objects

type FileResources added in v0.0.3

type FileResources struct {
	Resources []assertion.Resource
	Variables []Variable
}

FileResources contains the variables and resources loaded from a collection of files

type JSONResourceLoader added in v0.0.19

type JSONResourceLoader struct {
	Resources []assertion.ResourceConfig
}

JSONResourceLoader loads a list of Resource objects based on the list of ResourceConfig objects

func (JSONResourceLoader) Load added in v0.0.19

func (l JSONResourceLoader) Load(filename string) (FileResources, error)

Load converts a text file into a collection of Resource objects

func (JSONResourceLoader) PostLoad added in v0.0.19

PostLoad does no additional processing fro a JSONResourceLoader

type KubernetesLinter

type KubernetesLinter struct {
	Filenames   []string
	ValueSource assertion.ValueSource
}

KubernetesLinter lints resources in Kubernets YAML files

type KubernetesResourceLoader

type KubernetesResourceLoader struct{}

KubernetesResourceLoader converts Kubernetes configuration files into a collection of Resource objects

func (KubernetesResourceLoader) Load

func (l KubernetesResourceLoader) Load(filename string) (FileResources, error)

Load converts a text file into a collection of Resource objects

func (KubernetesResourceLoader) PostLoad added in v0.0.5

PostLoad does no additional processing for a KubernetesLoader

type Linter

type Linter interface {
	Validate(ruleSet assertion.RuleSet, options Options) (assertion.ValidationReport, error)
	Search(ruleSet assertion.RuleSet, searchExpression string, w io.Writer)
}

Linter provides the interface for all supported linters

func NewLinter

func NewLinter(ruleSet assertion.RuleSet, vs assertion.ValueSource, filenames []string, tfParser string) (Linter, error)

NewLinter create the right kind of Linter based on the type argument

type Options

type Options struct {
	Tags          []string
	RuleIDs       []string
	IgnoreRuleIDs []string
}

Options configures what resources will be linted

type ResourceLinter

type ResourceLinter struct {
	ValueSource assertion.ValueSource
}

ResourceLinter provides the basic validation logic used by all linters

func (ResourceLinter) ValidateResources

func (r ResourceLinter) ValidateResources(resources []assertion.Resource, rules []assertion.Rule) (assertion.ValidationReport, error)

ValidateResources evaluates a list of Rule objects to a list of Resource objects

type RulesResourceLoader

type RulesResourceLoader struct{}

RulesResourceLoader converts a YAML configuration file into a collection with Resource objects

func (RulesResourceLoader) Load

func (l RulesResourceLoader) Load(filename string) (FileResources, error)

Load converts a text file into a collection of Resource objects

func (RulesResourceLoader) PostLoad added in v0.0.5

PostLoad does no additional processing for a RulesResourceLoader

type Terraform12LoadResult added in v0.0.44

type Terraform12LoadResult struct {
	Resources []assertion.Resource
	Data      []interface{}
	Providers []interface{}
	Modules   []interface{}
	Variables []Variable
	AST       *hcl.File
}

Terraform12LoadResult collects all the returns value for parsing an HCL string

type Terraform12ResourceLoader added in v0.0.44

type Terraform12ResourceLoader struct{}

Terraform12ResourceLoader converts Terraform configuration files into JSON objects

func (Terraform12ResourceLoader) Load added in v0.0.44

Load parses an HCLv2 file into a collection or Resource objects TODO: This should be unused, but can't remove due to the interface, I think?

func (Terraform12ResourceLoader) LoadMany added in v0.0.44

func (l Terraform12ResourceLoader) LoadMany(filenames []string) (FileResources, error)

func (Terraform12ResourceLoader) PostLoad added in v0.0.44

func (l Terraform12ResourceLoader) PostLoad(inputResources FileResources) ([]assertion.Resource, error)

PostLoad resolves variable expressions

type TerraformLoadResult added in v0.0.3

type TerraformLoadResult struct {
	Resources []interface{}
	Data      []interface{}
	Providers []interface{}
	Modules   []interface{}
	Variables []Variable
	AST       *ast.File
}

TerraformLoadResult collects all the returns value for parsing an HCL string

type TerraformResourceLoader

type TerraformResourceLoader struct{}

TerraformResourceLoader converts Terraform configuration files into JSON objects

func (TerraformResourceLoader) Load

func (l TerraformResourceLoader) Load(filename string) (FileResources, error)

Load parses an HCL file into a collection or Resource objects

func (TerraformResourceLoader) PostLoad added in v0.0.5

PostLoad resolves variable expressions

type Variable added in v0.0.3

type Variable struct {
	Name  string
	Value interface{}
}

Variable contains a key value pair for expressions in a Terraform configuration file

type YAMLResourceLoader

type YAMLResourceLoader struct {
	Resources []assertion.ResourceConfig
}

YAMLResourceLoader loads a list of Resource objects based on the list of ResourceConfig objects

func (YAMLResourceLoader) Load

func (l YAMLResourceLoader) Load(filename string) (FileResources, error)

Load converts a text file into a collection of Resource objects

func (YAMLResourceLoader) PostLoad added in v0.0.5

PostLoad does no additional processing for a YAMLResourceLoader

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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