terraform

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: GPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const TerraformStateOutputsKey = "outputs"

TerraformStateOutputsKey is the key for the terraform state outputs

Variables

View Source
var (
	// CheckovPolicyTemplate is the default template used to produce a checkov configuration
	CheckovPolicyTemplate = `` /* 441-byte string literal not displayed */

)

checkovPolicyTemplate is the default template used to produce a checkov configuration

View Source
var (
	// Detectors is the error detection pattern
	Detectors = map[string][]ErrorDetection{
		"aws": {
			{
				Regex:   "operation error STS: GetCallerIdentity",
				Message: "AWS Credentials in provider has been missconfigured, contact platform administrator",
			},
		},
		"google":  {},
		"azurerm": {},
		"*": {
			{
				Regex:   "error validating provider credentials",
				Message: "Provider credentials are missconfigured, please contact the platform administrator",
			},
		},
	}
)
View Source
var KubernetesBackendTemplate = `` /* 340-byte string literal not displayed */

KubernetesBackendTemplate is responsible for creating the kubernetes backend terraform configuration

Functions

func Decode

func Decode(data []byte) (io.Reader, error)

Decode returns a Reader that will decode a gzip byte stream

func FindChangesInLogs

func FindChangesInLogs(in io.Reader) (bool, error)

FindChangesInLogs is used to scan the logs for the terraform line which informs on changes

func NewCheckovPolicy added in v0.4.0

func NewCheckovPolicy(data map[string]interface{}) ([]byte, error)

NewCheckovPolicy generates a checkov policy from the configuration

func NewKubernetesBackend

func NewKubernetesBackend(options BackendOptions) ([]byte, error)

NewKubernetesBackend creates a new kubernetes backend

func NewTerraformProvider

func NewTerraformProvider(provider string, configuration []byte) ([]byte, error)

NewTerraformProvider generates a terraform provider configuration

func Template added in v0.3.7

func Template(main string, data interface{}) ([]byte, error)

Template renders the content but includes the hcl method

func ToHCL added in v0.3.7

func ToHCL(data interface{}) (string, error)

ToHCL converts the json to HCL format

Types

type BackendOptions added in v0.3.1

type BackendOptions struct {
	// Configuration is a reference to the terraform configuration
	Configuration *terraformv1alpha1.Configuration
	// Namespace is a reference to the controller namespace
	Namespace string
	// Suffix is an expexted suffix for the terraform state
	Suffix string
	// Template is the golang template to use to generate the backend content
	Template string
}

BackendOptions are the options used to generate the backend

type Change added in v0.4.10

type Change struct {
	Actions []ChangeAction `json:"actions"`
}

type ChangeAction added in v0.4.10

type ChangeAction string
const (
	TFActionNoOp ChangeAction = "no-op"
)

type ErrorDetection

type ErrorDetection struct {
	// Regex is the string we are looking for
	Regex string
	// Message is cause of the error
	Message string
}

ErrorDetection defines an error and potential causes for it.

type OutputChange added in v0.4.10

type OutputChange struct {
	Actions []ChangeAction `json:"actions"`
}

type OutputValue

type OutputValue struct {
	// Value is the value of the output
	Value interface{} `json:"value,omitempty"`
}

OutputValue is a value of the terraform output

func (*OutputValue) String

func (o *OutputValue) String() string

String returns an string representation of the value

type Plan added in v0.4.10

type Plan struct {
	Timestamp       string                  `json:"timestamp"`
	ResourceChanges []ResourceChange        `json:"resource_changes"`
	OutputChanges   map[string]OutputChange `json:"output_changes"`
	Applyable       *bool                   `json:"applyable"`
}

Plan is the terraform plan output

func DecodePlan added in v0.4.10

func DecodePlan(in []byte) (*Plan, error)

DecodePlan decodes the terraform plan outputs

func (Plan) ID added in v0.4.10

func (p Plan) ID() string

ID uniquely identifies a plan and should be safe to use in a resource label.

func (Plan) NeedsApply added in v0.4.10

func (p Plan) NeedsApply() bool

NeedsApply returns a boolean indicating if running apply is necessary

type Resource

type Resource struct {
	// Mode is the mode of the resource
	Mode string `json:"mode,omitempty"`
	// Type is the type of the resource
	Type string `json:"type,omitempty"`
	// Instances a collection of the resource instances in the state
	Instances []map[string]interface{} `json:"instances,omitempty"`
}

Resource represents a resource in the state

type ResourceChange added in v0.4.10

type ResourceChange struct {
	Change Change `json:"change"`
}

type State

type State struct {
	// Outputs are the terraform outputs
	Outputs map[string]OutputValue `json:"outputs"`
	// Resources is a collection of resources in the state
	Resources []Resource `json:"resources,omitempty"`
	// TerraformVersion is the version of terraform used
	TerraformVersion string `json:"terraform_version,omitempty"`
}

State is the state of the terraform

func DecodeState

func DecodeState(in []byte) (*State, error)

DecodeState decodes the terraform state outputs

func (*State) CountResources

func (s *State) CountResources() int

CountResources returns the number of managed resources from the state

func (*State) HasOutputs

func (s *State) HasOutputs() bool

HasOutputs returns true if the state has outputs

Jump to

Keyboard shortcuts

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