Documentation ¶
Index ¶
- func DebugJSON(title string, object interface{})
- func Debugf(format string, args ...interface{})
- func ExcludeResource(rule Rule, resource Resource) bool
- func JSONStringify(data interface{}) (string, error)
- func ResolveRule(rule Rule, valueSource ValueSource) (Rule, []Violation)
- func ResolveRules(rules []Rule, valueSource ValueSource) ([]Rule, []Violation)
- func SearchData(expression string, data interface{}) (interface{}, error)
- func SetDebug(b bool)
- func ShouldIncludeFile(patterns []string, filename string) (bool, error)
- func SliceContains(list []string, value string) bool
- type CollectionExpression
- type ColumnConfig
- type Expression
- type ExternalRuleInvoker
- type InvokeResponse
- type InvokeRuleAPI
- type InvokeViolation
- type MatchResult
- type Resource
- func ExcludeResourceTypes(resources []Resource, resourceTypes []string, resourceCategory string) []Resource
- func FilterResourceExceptions(rule Rule, resources []Resource) []Resource
- func FilterResourcesByType(resources []Resource, resourceType string, resourceCategory string) []Resource
- func FilterResourcesByTypes(resources []Resource, resourceTypes []string, resourceCategory string) []Resource
- func FilterResourcesForRule(resources []Resource, rule Rule) []Resource
- type ResourceConfig
- type Result
- type Rule
- type RuleSet
- type ScannedResource
- type StandardExternalRuleInvoker
- type StandardValueSource
- type ValidationReport
- type ValueFrom
- type ValueSource
- type Violation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Debugf ¶
func Debugf(format string, args ...interface{})
Debugf prints a formatted string when verbose logging is turned on
func ExcludeResource ¶
ExcludeResource when resource.ID included in list of exceptions
func JSONStringify ¶
JSONStringify converts a JSON object into an indented string suitable for printing
func ResolveRule ¶
func ResolveRule(rule Rule, valueSource ValueSource) (Rule, []Violation)
ResolveRule loads any dynamic values for a single Rule
func ResolveRules ¶
func ResolveRules(rules []Rule, valueSource ValueSource) ([]Rule, []Violation)
ResolveRules loads any dynamic values for a collection or rules
func SearchData ¶
SearchData applies a JMESPath to a JSON object
func ShouldIncludeFile ¶
ShouldIncludeFile return true if a filename matches one of a list of patterns
func SliceContains ¶ added in v0.0.11
Types ¶
type CollectionExpression ¶
type CollectionExpression struct { Key string Expressions []Expression }
CollectionExpression assertion for every element of a collection
type ColumnConfig ¶ added in v0.0.19
type ColumnConfig struct {
Name string
}
ColumnConfig describes how to discover resources in a CSV file
type Expression ¶
type Expression struct { Key string Op string Value string ValueType string `json:"value_type"` ValueFrom ValueFrom `json:"value_from"` Or []Expression Xor []Expression And []Expression Not []Expression Every CollectionExpression Some CollectionExpression None CollectionExpression ExactlyOne CollectionExpression `json:"exactly-one"` }
Expression expression for a Rule
type ExternalRuleInvoker ¶
ExternalRuleInvoker defines an interface for invoking an external API
type InvokeResponse ¶
type InvokeResponse struct {
Violations []InvokeViolation
}
InvokeResponse contains a collection of validation errors
type InvokeRuleAPI ¶
InvokeRuleAPI describes an external API for linting a resource
type InvokeViolation ¶
type InvokeViolation struct {
Message string
}
InvokeViolation has message describing a single validation error
type MatchResult ¶
MatchResult has a true/false result, but also includes a message for better reporting
type Resource ¶
type Resource struct { ID string `cty:"aws_instance"` Type string Category string // default is "resource", can be "data", "provider" for Terraform Properties interface{} Filename string LineNumber int }
Resource describes a resource to be linted
func ExcludeResourceTypes ¶ added in v0.0.28
func ExcludeResourceTypes(resources []Resource, resourceTypes []string, resourceCategory string) []Resource
Exclude resources
func FilterResourceExceptions ¶
FilterResourceExceptions filters out resources that should not be validated
func FilterResourcesByType ¶
func FilterResourcesByType(resources []Resource, resourceType string, resourceCategory string) []Resource
FilterResourcesByType filters a list of resources that match a single resource type
func FilterResourcesByTypes ¶ added in v0.0.11
func FilterResourcesByTypes(resources []Resource, resourceTypes []string, resourceCategory string) []Resource
FilterResourcesByTypes filters a list of resources that match a slice of resource types
func FilterResourcesForRule ¶ added in v0.0.11
FilterResourcesForRule returns resources applicable to the given rule
type ResourceConfig ¶
ResourceConfig describes how to discover resouces in a YAML file
type Result ¶
Result returns a status, along with a message
func CheckExpression ¶
func CheckExpression(rule Rule, expression Expression, resource Resource) (Result, error)
CheckExpression validates a single Resource using a single Expression
type Rule ¶
type Rule struct { ID string Message string Severity string Resource string Resources []string ExceptResources []string `json:"except_resources"` Category string // default is "resource", can be "data", "provider", "module" for Terraform Conditions []Expression Assertions []Expression Except []string Tags []string Invoke InvokeRuleAPI }
Rule is part of a RuleSet
func FilterRulesByID ¶
FilterRulesByID selectes a subset of rules based on ID
func FilterRulesByTag ¶
FilterRulesByTag selects a subset of rules based on a tag
type RuleSet ¶
type RuleSet struct { Type string Description string Files []string Rules []Rule Version string Resources []ResourceConfig Columns []ColumnConfig Source string }
RuleSet describes a collection of rules for a Linter
func JoinRuleSets ¶ added in v1.0.0
Join two RuleSets together
func ParseRules ¶
ParseRules converts YAML string content to a Result
type ScannedResource ¶
type ScannedResource struct { ResourceID string ResourceType string RuleID string Status string Filename string LineNumber int }
ScannedResource has details for each resource scanned
type StandardExternalRuleInvoker ¶
type StandardExternalRuleInvoker struct { }
StandardExternalRuleInvoker implements an external HTTP or HTTPS call
type StandardValueSource ¶
StandardValueSource can fetch values from external sources
func (StandardValueSource) GetValue ¶
func (v StandardValueSource) GetValue(expression Expression) (string, error)
GetValue looks up external values when an Expression includes a ValueFrom attribute
func (StandardValueSource) GetValueFromHTTP ¶
func (v StandardValueSource) GetValueFromHTTP(url string) (string, error)
GetValueFromHTTP looks up external value for an Expression when the HTTP protocol is specified
func (StandardValueSource) GetValueFromS3 ¶
func (v StandardValueSource) GetValueFromS3(bucket string, key string) (string, error)
GetValueFromS3 looks up external values for an Expression when the S3 protocol is specified
type ValidationReport ¶
type ValidationReport struct { FilesScanned []string Violations []Violation ResourcesScanned []ScannedResource }
ValidationReport summarizes validation for resources using rules
type ValueSource ¶
type ValueSource interface {
GetValue(Expression) (string, error)
}
ValueSource interface to fetch dynamic values