pkg

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: MIT Imports: 47 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FsFactory = func() afero.Fs {
	return afero.NewOsFs()
}

Functions

func CtyValueToString

func CtyValueToString(val cty.Value) string

func GoTypeToCtyType

func GoTypeToCtyType(goType reflect.Type) cty.Type

func Int

func Int(i int) *int

func LocalsValues

func LocalsValues(blocks []Local) cty.Value

func ToCtyValue

func ToCtyValue(input interface{}) cty.Value

ToCtyValue is a function that converts a primary/collection type to cty.Value

func Values

func Values[T block](blocks []T) cty.Value

Types

type BaseBlock

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

func (*BaseBlock) BaseValues

func (bb *BaseBlock) BaseValues() map[string]cty.Value

func (*BaseBlock) Context

func (bb *BaseBlock) Context() context.Context

func (*BaseBlock) EvalContext

func (bb *BaseBlock) EvalContext() *hcl.EvalContext

func (*BaseBlock) HclBlock

func (bb *BaseBlock) HclBlock() *hclBlock

func (*BaseBlock) Id

func (bb *BaseBlock) Id() string

func (*BaseBlock) Name

func (bb *BaseBlock) Name() string

func (*BaseBlock) PreConditionCheck

func (bb *BaseBlock) PreConditionCheck(ctx *hcl.EvalContext) ([]PreCondition, error)

type BaseData

type BaseData struct{}

func (*BaseData) BlockType

func (bd *BaseData) BlockType() string

type BaseFix

type BaseFix struct {
	RuleIds []string `json:"rule_ids" hcl:"rule_ids"`
}

func (*BaseFix) BlockType

func (bf *BaseFix) BlockType() string

func (*BaseFix) Decode

func (bf *BaseFix) Decode(hb *hclBlock, evalContext *hcl.EvalContext) error

func (*BaseFix) GetRuleIds

func (bf *BaseFix) GetRuleIds() []string

func (*BaseFix) Values

func (bf *BaseFix) Values() map[string]cty.Value

type BaseRule

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

func (*BaseRule) BlockType

func (br *BaseRule) BlockType() string

func (*BaseRule) CheckError

func (br *BaseRule) CheckError() error

type Config

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

func NewConfig

func NewConfig(baseDir, cfgDir string, ctx context.Context) (*Config, error)

func (*Config) DataBlocks

func (c *Config) DataBlocks() []Data

func (*Config) EvalContext

func (c *Config) EvalContext() *hcl.EvalContext

func (*Config) FixBlocks

func (c *Config) FixBlocks() []Fix

func (*Config) LocalBlocks

func (c *Config) LocalBlocks() []Local

func (*Config) Plan

func (c *Config) Plan() (*Plan, error)

func (*Config) RuleBlocks

func (c *Config) RuleBlocks() []Rule

type CopyFileFix

type CopyFileFix struct {
	*BaseBlock
	*BaseFix
	Src  string `json:"src" hcl:"src"`
	Dest string `json:"dest" hcl:"dest"`
}

func (*CopyFileFix) Apply

func (c *CopyFileFix) Apply() error

func (*CopyFileFix) Type

func (c *CopyFileFix) Type() string

func (*CopyFileFix) Values

func (c *CopyFileFix) Values() map[string]cty.Value

type Dag

type Dag struct {
	*dag.DAG
	// contains filtered or unexported fields
}

type Data

type Data interface {
	// contains filtered or unexported methods
}

type DecodeBase

type DecodeBase interface {
	Decode(*hclBlock, *hcl.EvalContext) error
}

type DirExistRule

type DirExistRule struct {
	*BaseBlock
	*BaseRule
	Dir         string `hcl:"dir"`
	FailOnExist bool   `hcl:"fail_on_exist,optional"`
}

func (*DirExistRule) ExecuteDuringPlan

func (d *DirExistRule) ExecuteDuringPlan() error

func (*DirExistRule) Type

func (d *DirExistRule) Type() string

func (*DirExistRule) Values

func (d *DirExistRule) Values() map[string]cty.Value

type FailedRule

type FailedRule struct {
	Rule
	CheckError error
}

func (*FailedRule) String

func (fr *FailedRule) String() string

type FileExistRule

type FileExistRule struct {
	*BaseBlock
	*BaseRule
	Glob       string `hcl:"glob"`
	MatchFiles []string
}

func (*FileExistRule) ExecuteDuringPlan

func (f *FileExistRule) ExecuteDuringPlan() error

func (*FileExistRule) Type

func (f *FileExistRule) Type() string

func (*FileExistRule) Values

func (f *FileExistRule) Values() map[string]cty.Value

type FileHashRule

type FileHashRule struct {
	*BaseBlock
	*BaseRule
	Glob               string `hcl:"glob"`
	Hash               string `hcl:"hash"`
	Algorithm          string `hcl:"algorithm,optional" default:"sha1"`
	FailOnHashMismatch bool   `hcl:"fail_on_hash_mismatch,optional"`
	HashMismatchFiles  []string
}

func (*FileHashRule) ExecuteDuringPlan

func (fhr *FileHashRule) ExecuteDuringPlan() error

func (*FileHashRule) Type

func (fhr *FileHashRule) Type() string

func (*FileHashRule) Validate

func (fhr *FileHashRule) Validate() error

func (*FileHashRule) Values

func (fhr *FileHashRule) Values() map[string]cty.Value

type Fix

type Fix interface {
	GetRuleIds() []string
	Apply() error
	// contains filtered or unexported methods
}

type GitIgnoreDatasource

type GitIgnoreDatasource struct {
	*BaseBlock
	*BaseData
	Records []string
}

func (*GitIgnoreDatasource) ExecuteDuringPlan

func (g *GitIgnoreDatasource) ExecuteDuringPlan() error

func (*GitIgnoreDatasource) Type

func (g *GitIgnoreDatasource) Type() string

func (*GitIgnoreDatasource) Values

func (g *GitIgnoreDatasource) Values() map[string]cty.Value

type GitIgnoreFix

type GitIgnoreFix struct {
	*BaseBlock
	*BaseFix
	Exist    []string `hcl:"exist,optional" validate:"at_least_one_of=Exist NotExist"`
	NotExist []string `hcl:"not_exist,optional" validate:"at_least_one_of=Exist NotExist"`
}

func (*GitIgnoreFix) Apply

func (g *GitIgnoreFix) Apply() error

func (*GitIgnoreFix) Type

func (g *GitIgnoreFix) Type() string

func (*GitIgnoreFix) Values

func (g *GitIgnoreFix) Values() map[string]cty.Value

type HttpDatasource

type HttpDatasource struct {
	*BaseBlock
	*BaseData
	Url             string            `hcl:"url"`
	Method          string            `hcl:"method,optional" default:"GET"`
	RequestBody     string            `hcl:"request_body,optional"`
	RequestHeaders  map[string]string `hcl:"request_headers,optional"`
	RetryMax        int               `hcl:"retry_max,optional" default:"4"`
	ResponseBody    string
	ResponseHeaders map[string]string
	StatusCode      int
}

func (*HttpDatasource) ExecuteDuringPlan

func (h *HttpDatasource) ExecuteDuringPlan() error

func (*HttpDatasource) Type

func (h *HttpDatasource) Type() string

func (*HttpDatasource) Validate

func (h *HttpDatasource) Validate() error

func (*HttpDatasource) Values

func (h *HttpDatasource) Values() map[string]cty.Value

type Local

type Local interface {
	// contains filtered or unexported methods
}

type LocalBlock

type LocalBlock struct {
	*BaseBlock
	Value cty.Value `hcl:"value"`
}

func (*LocalBlock) BlockType

func (l *LocalBlock) BlockType() string

func (*LocalBlock) Type

func (l *LocalBlock) Type() string

func (*LocalBlock) Values

func (l *LocalBlock) Values() map[string]cty.Value

type LocalFileFix

type LocalFileFix struct {
	*BaseBlock
	*BaseFix
	Paths   []string     `json:"paths" hcl:"paths"`
	Content string       `json:"content" hcl:"content"`
	Mode    *fs.FileMode `json:"mode" hcl:"mode,optional" default:"0644" validate:"file_mode"`
}

func (*LocalFileFix) Apply

func (lf *LocalFileFix) Apply() error

func (*LocalFileFix) Type

func (lf *LocalFileFix) Type() string

func (*LocalFileFix) Values

func (lf *LocalFileFix) Values() map[string]cty.Value

type LocalShellFix

type LocalShellFix struct {
	*BaseBlock
	*BaseFix
	ExecuteCommand []string          `hcl:"execute_command,optional" default:"[/bin/sh,-c]"` // The command used to execute the script.
	InlineShebang  string            `hcl:"inline_shebang,optional" validate:"required_with=Inlines"`
	Inlines        []string          `hcl:"inlines,optional" validate:"conflict_with=Script RemoteScript,at_least_one_of=Inlines Script RemoteScript"`
	Script         string            `hcl:"script,optional" validate:"conflict_with=Inlines RemoteScript,at_least_one_of=Inlines Script RemoteScript"`
	RemoteScript   string            `hcl:"remote_script,optional" validate:"conflict_with=Inlines Script,at_least_one_of=Inlines Script RemoteScript,eq=|http_url"`
	OnlyOn         []string          `` /* 129-byte string literal not displayed */
	Env            map[string]string `hcl:"env,optional"`
}

func (*LocalShellFix) Apply

func (l *LocalShellFix) Apply() (err error)

func (*LocalShellFix) Type

func (l *LocalShellFix) Type() string

func (*LocalShellFix) Values

func (l *LocalShellFix) Values() map[string]cty.Value

type MustBeTrueRule

type MustBeTrueRule struct {
	*BaseBlock
	*BaseRule
	Condition    bool   `hcl:"condition"`
	ErrorMessage string `hcl:"error_message,optional"`
}

func (*MustBeTrueRule) ExecuteDuringPlan

func (m *MustBeTrueRule) ExecuteDuringPlan() error

func (*MustBeTrueRule) Type

func (m *MustBeTrueRule) Type() string

func (*MustBeTrueRule) Values

func (m *MustBeTrueRule) Values() map[string]cty.Value

type Plan

type Plan struct {
	FailedRules []*FailedRule
	Fixes       map[string]Fix
	// contains filtered or unexported fields
}

func (*Plan) Apply

func (p *Plan) Apply() error

func (*Plan) String

func (p *Plan) String() string

type PreCondition

type PreCondition struct {
	Body         *hclsyntax.Body
	Condition    bool   `hcl:"condition"`
	ErrorMessage string `hcl:"error_message,optional"`
}

type RenameFileFix

type RenameFileFix struct {
	*BaseBlock
	*BaseFix
	OldName string `json:"old_name" hcl:"old_name"`
	NewName string `json:"new_name" hcl:"new_name"`
}

func (*RenameFileFix) Apply

func (rf *RenameFileFix) Apply() error

func (*RenameFileFix) Type

func (rf *RenameFileFix) Type() string

func (*RenameFileFix) Values

func (rf *RenameFileFix) Values() map[string]cty.Value

type RmLocalFileFix

type RmLocalFileFix struct {
	*BaseBlock
	*BaseFix
	Paths []string `hcl:"paths" json:"paths"`
}

func (*RmLocalFileFix) Apply

func (r *RmLocalFileFix) Apply() error

func (*RmLocalFileFix) Type

func (r *RmLocalFileFix) Type() string

func (*RmLocalFileFix) Values

func (r *RmLocalFileFix) Values() map[string]cty.Value

type Rule

type Rule interface {
	CheckError() error
	// contains filtered or unexported methods
}

type Validatable

type Validatable interface {
	Validate() error
}

type Valuable

type Valuable interface {
	Values() map[string]cty.Value
}

type YamlTransform

type YamlTransform struct {
	YamlPath    string `hcl:"yaml_path" json:"yaml_path"`
	StringValue string `hcl:"string_value" json:"string_value"`
}

type YamlTransformFix

type YamlTransformFix struct {
	*BaseBlock
	*BaseFix
	FilePath  string          `hcl:"file_path" json:"file_path" validate:"endswith=.yaml|endswith=.yml"`
	Transform []YamlTransform `hcl:"transform,block"`
}

func (*YamlTransformFix) Apply

func (y *YamlTransformFix) Apply() error

func (*YamlTransformFix) Type

func (y *YamlTransformFix) Type() string

func (*YamlTransformFix) Values

func (y *YamlTransformFix) Values() map[string]cty.Value

Jump to

Keyboard shortcuts

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