ignorefiles

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package ignorefiles deals with the ".terraformignore" file format, which is a convention similar to ".gitignore" that specifies path patterns that match files Terraform should discard or ignore when interpreting a package fetched from a remote location.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExcludesResult added in v0.13.3

type ExcludesResult struct {
	Excluded   bool
	Dominating bool
}

ExcludesResult is the result of matching a path against a Ruleset. A result is Excluded if it matches a set of paths that are excluded by the rules in a Ruleset. A matching result is Dominating if none of the rules that follow it contain a negation, implying that if the rule excludes a directory, everything below that directory may be ignored.

type Ruleset

type Ruleset struct {
	// contains filtered or unexported fields
}

A Ruleset is the result of reading, parsing, and compiling a ".terraformignore" file.

var DefaultRuleset *Ruleset

func LoadPackageIgnoreRules

func LoadPackageIgnoreRules(packageDir string) (*Ruleset, error)

LoadPackageIgnoreRules implements reasonable default behavior for finding ignore rules for a particular package root directory: if .terraformignore is present then use it, or otherwise just return DefaultRuleset.

This function will return an error only if an ignore file is present but unreadable, or if an ignore file is present but contains invalid syntax.

func ParseIgnoreFileContent

func ParseIgnoreFileContent(r io.Reader) (*Ruleset, error)

ParseIgnoreFileContent takes a reader over the content of a .terraformignore file and returns the Ruleset described by that file, or an error if the file is invalid.

func (*Ruleset) Excludes

func (r *Ruleset) Excludes(path string) (ExcludesResult, error)

Excludes tests whether the given path matches the set of paths that are excluded by the rules in the ruleset.

If any of the rules in the ruleset have invalid syntax then Excludes will return an error, but it will also still return a result which considers all of the remaining valid rules, to support callers that want to just ignore invalid exclusions. Such callers can safely ignore the error result:

exc, matching, _ = ruleset.Excludes(path)

func (*Ruleset) Includes

func (r *Ruleset) Includes(path string) (bool, error)

Includes is the inverse of Ruleset.Excludes.

Jump to

Keyboard shortcuts

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