Back to godoc.org

Package linter

v1.6.0
Latest Go to latest

The latest major version is .

Published: Jun 25, 2020 | License: MIT | Module: github.com/stelligent/config-lint

Index

Variables

var Counter = 0

Counter used to generate an ID for providers

func CombineValidationReports

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

CombineValidationReports merges results from two separate Validate runs

func Funcs

func Funcs() map[string]ast.Function

type CSVResourceLoader

type CSVResourceLoader struct {
	Columns []assertion.ColumnConfig
}

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

func (CSVResourceLoader) Load

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

Load converts a text file into a collection of Resource objects

func (CSVResourceLoader) PostLoad

func (l CSVResourceLoader) PostLoad(r FileResources) ([]assertion.Resource, error)

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

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

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

type JSONResourceLoader

type JSONResourceLoader struct {
	Resources []assertion.ResourceConfig
}

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

func (JSONResourceLoader) Load

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

Load converts a text file into a collection of Resource objects

func (JSONResourceLoader) PostLoad

func (l JSONResourceLoader) PostLoad(r FileResources) ([]assertion.Resource, error)

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

func (l KubernetesResourceLoader) PostLoad(r FileResources) ([]assertion.Resource, error)

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

func (l RulesResourceLoader) PostLoad(r FileResources) ([]assertion.Resource, error)

PostLoad does no additional processing for a RulesResourceLoader

type Terraform12LoadResult

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

type Terraform12ResourceLoader struct{}

Terraform12ResourceLoader converts Terraform configuration files into JSON objects

func (Terraform12ResourceLoader) Load

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

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

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

func (Terraform12ResourceLoader) PostLoad

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

PostLoad resolves variable expressions

type TerraformLoadResult

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

func (l TerraformResourceLoader) PostLoad(fr FileResources) ([]assertion.Resource, error)

PostLoad resolves variable expressions

type Variable

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

func (l YAMLResourceLoader) PostLoad(r FileResources) ([]assertion.Resource, error)

PostLoad does no additional processing for a YAMLResourceLoader

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier