rules

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MPL-2.0 Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

Functions

func AssertIssues

func AssertIssues(t *testing.T, expected helper.Issues, actual helper.Issues)

AssertIssues is an assertion helper for comparing issues.

func Check

func Check(runner tflint.Runner, check func(tflint.Runner, *hcl.File) error) error

Check checks whether the tf config files match given rules

func IsHeadMeta

func IsHeadMeta(argName string) bool

IsHeadMeta checks whether a name represents a type of head Meta arg

func IsTailMeta

func IsTailMeta(argName string) bool

IsTailMeta checks whether a name represents a type of tail Meta arg

Types

type Arg

type Arg struct {
	Name  string
	Range hcl.Range
	File  *hcl.File
}

Arg is a wrapper of the attribute

func (*Arg) ToString

func (a *Arg) ToString() string

ToString prints the arg content

type Args

type Args struct {
	Args  []*Arg
	Range *hcl.Range
}

Args is the collection of args with the same type

func (*Args) CheckOrder

func (a *Args) CheckOrder() bool

CheckOrder checks whether this type of args are sorted

func (*Args) GetRange

func (a *Args) GetRange() *hcl.Range

GetRange returns the entire range of this type of args

func (*Args) ToString

func (a *Args) ToString() string

ToString prints this type of args in order

type AzurermArgOrderRule

type AzurermArgOrderRule struct {
	tflint.DefaultRule
}

AzurermArgOrderRule checks whether the arguments in a block are sorted in azure doc order

func NewAzurermArgOrderRule

func NewAzurermArgOrderRule() *AzurermArgOrderRule

NewAzurermArgOrderRule returns a new rule

func (*AzurermArgOrderRule) Check

func (r *AzurermArgOrderRule) Check(runner tflint.Runner) error

func (*AzurermArgOrderRule) CheckFile

func (r *AzurermArgOrderRule) CheckFile(runner tflint.Runner, file *hcl.File) error

CheckFile checks whether the arguments in a block are sorted in codex order

func (*AzurermArgOrderRule) Enabled

func (r *AzurermArgOrderRule) Enabled() bool
func (r *AzurermArgOrderRule) Link() string

func (*AzurermArgOrderRule) Name

func (r *AzurermArgOrderRule) Name() string

Name returns the rule name

func (*AzurermArgOrderRule) Severity

func (r *AzurermArgOrderRule) Severity() tflint.Severity

type AzurermResourceTagRule

type AzurermResourceTagRule struct {
	tflint.DefaultRule
}

AzurermResourceTagRule checks whether the tags arg is specified if supported

func NewAzurermResourceTagRule

func NewAzurermResourceTagRule() *AzurermResourceTagRule

NewAzurermResourceTagRule returns a new rule

func (*AzurermResourceTagRule) Check

func (r *AzurermResourceTagRule) Check(runner tflint.Runner) error

func (*AzurermResourceTagRule) CheckFile

func (r *AzurermResourceTagRule) CheckFile(runner tflint.Runner, file *hcl.File) error

CheckFile checks whether the tags arg is specified if supported

func (*AzurermResourceTagRule) Enabled

func (r *AzurermResourceTagRule) Enabled() bool
func (r *AzurermResourceTagRule) Link() string

func (*AzurermResourceTagRule) Name

func (r *AzurermResourceTagRule) Name() string

func (*AzurermResourceTagRule) Severity

func (r *AzurermResourceTagRule) Severity() tflint.Severity

type Block

type Block interface {
	// CheckBlock checks the resourceBlock/nestedBlock recursively to find the block not in order,
	// and invoke the emit function on that block
	CheckBlock() error

	// ToString prints the sorted block
	ToString() string

	// DefRange gets the definition range of the block
	DefRange() hcl.Range
}

Block is an interface offering general APIs on resource/nested block

type HeadMetaArgs

type HeadMetaArgs struct {
	Args  []*Arg
	Range *hcl.Range
}

HeadMetaArgs is the collection of head meta args

func (*HeadMetaArgs) CheckOrder

func (a *HeadMetaArgs) CheckOrder() bool

CheckOrder checks whether the head meta args are sorted

func (*HeadMetaArgs) GetRange

func (a *HeadMetaArgs) GetRange() *hcl.Range

GetRange returns the entire range of head meta args

func (*HeadMetaArgs) ToString

func (a *HeadMetaArgs) ToString() string

ToString prints the head meta args in order

type NestedBlock

type NestedBlock struct {
	File                 *hcl.File
	Block                *hclsyntax.Block
	Name                 string
	SortField            string
	Range                hcl.Range
	HeadMetaArgs         *HeadMetaArgs
	RequiredArgs         *Args
	OptionalArgs         *Args
	RequiredNestedBlocks *NestedBlocks
	OptionalNestedBlocks *NestedBlocks
	ParentBlockNames     []string
	// contains filtered or unexported fields
}

NestedBlock is a wrapper of the nested block

func (*NestedBlock) CheckBlock

func (b *NestedBlock) CheckBlock() error

CheckBlock checks the nestedBlock recursively to find the block not in order, and invoke the emit function on that block

func (*NestedBlock) CheckOrder

func (b *NestedBlock) CheckOrder() bool

CheckOrder checks whether the nestedBlock is sorted

func (*NestedBlock) DefRange

func (b *NestedBlock) DefRange() hcl.Range

DefRange gets the definition range of the nested block

func (*NestedBlock) ToString

func (b *NestedBlock) ToString() string

ToString prints the sorted block

type NestedBlocks

type NestedBlocks struct {
	Blocks []*NestedBlock
	Range  *hcl.Range
}

NestedBlocks is the collection of nestedBlocks with the same type

func (*NestedBlocks) CheckOrder

func (b *NestedBlocks) CheckOrder() bool

CheckOrder checks whether this type of nestedBlocks are sorted

func (*NestedBlocks) GetRange

func (b *NestedBlocks) GetRange() *hcl.Range

GetRange returns the entire range of this type of nestedBlocks

func (*NestedBlocks) ToString

func (b *NestedBlocks) ToString() string

ToString prints this type of nestedBlocks in order

type ResourceBlock

type ResourceBlock struct {
	File                 *hcl.File
	Block                *hclsyntax.Block
	HeadMetaArgs         *HeadMetaArgs
	RequiredArgs         *Args
	OptionalArgs         *Args
	RequiredNestedBlocks *NestedBlocks
	OptionalNestedBlocks *NestedBlocks
	TailMetaArgs         *Args
	TailMetaNestedBlocks *NestedBlocks
	ParentBlockNames     []string
	// contains filtered or unexported fields
}

ResourceBlock is the wrapper of a resource block

func BuildResourceBlock

func BuildResourceBlock(block *hclsyntax.Block, file *hcl.File,
	emitter func(block Block) error) *ResourceBlock

BuildResourceBlock Build the root block wrapper using hclsyntax.Block

func (*ResourceBlock) CheckBlock

func (b *ResourceBlock) CheckBlock() error

CheckBlock checks the resource block and nested block recursively to find the block not in order, and invoke the emit function on that block

func (*ResourceBlock) CheckOrder

func (b *ResourceBlock) CheckOrder() bool

CheckOrder checks whether the resourceBlock is sorted

func (*ResourceBlock) DefRange

func (b *ResourceBlock) DefRange() hcl.Range

DefRange gets the definition range of the resource block

func (*ResourceBlock) ToString

func (b *ResourceBlock) ToString() string

ToString prints the sorted resource block

type Section

type Section interface {
	// CheckOrder checks whether the arguments in the collection is sorted
	CheckOrder() bool

	// ToString prints arguments in the collection in order
	ToString() string

	// GetRange returns the entire range of the argument collection
	GetRange() *hcl.Range
}

Section is an interface offering general APIs of argument collections

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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