tap

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(tfCfg *configs.Config, cfg *Config) (*configs.Config, error)

Apply applies the tap configuration to the Terraform configuration.

func HasConfig

func HasConfig(dir string) (bool, error)

HasConfig checks if the given directory has a tap configuration.

Types

type Config

type Config struct {
	PathSyntax string
	Patches    []Patch
}

func Load

func Load(dir string) (*Config, error)

Load loads the tap configuration from the given directory, returns nil if no tap configuration is found.

type JSONPointerPathOperator

type JSONPointerPathOperator []JSONPointerPathToken

func (JSONPointerPathOperator) Add

func (op JSONPointerPathOperator) Add(resource *configs.Resource, value Value) (*configs.Resource, error)

func (JSONPointerPathOperator) Remove

func (op JSONPointerPathOperator) Remove(resource *configs.Resource) (*configs.Resource, error)

func (JSONPointerPathOperator) Replace

func (op JSONPointerPathOperator) Replace(resource *configs.Resource, value Value) (*configs.Resource, error)

func (JSONPointerPathOperator) Search

func (op JSONPointerPathOperator) Search(resource *configs.Resource) (target, parent any, err error)

func (JSONPointerPathOperator) Set

func (op JSONPointerPathOperator) Set(resource *configs.Resource, value Value) (*configs.Resource, error)

func (JSONPointerPathOperator) String

func (op JSONPointerPathOperator) String() string

type JSONPointerPathToken

type JSONPointerPathToken struct {
	Raw   string
	Value string
}

func TokenizeJSONPointerPath

func TokenizeJSONPointerPath(path string) []JSONPointerPathToken

type Operation

type Operation struct {
	Mode  string // Select from "add", "remove", "replace", or "set".
	Path  string
	Value Value
}

type Patch

type Patch struct {
	ContinueOnError bool
	ResourceMode    string // Select from "resource" or "data".
	ResourceTypes   []string
	ResourceNames   []string
	Operations      []Operation
}

type PathOperator

type PathOperator interface {
	// Add adds Value at the path if not found in the given configs.Resource.
	Add(*configs.Resource, Value) (*configs.Resource, error)
	// Replace replaces the value at the path if found in the given configs.Resource.
	Replace(*configs.Resource, Value) (*configs.Resource, error)
	// Remove removes the value at the path if found in the given configs.Resource.
	Remove(*configs.Resource) (*configs.Resource, error)
	// Set sets the value at the path of the given configs.Resource.
	Set(*configs.Resource, Value) (*configs.Resource, error)
}

func NewJSONPointerPathOperator

func NewJSONPointerPathOperator(path string) (PathOperator, error)

type TerraformResources

type TerraformResources = map[string]*configs.Resource

func Operate

func Operate(tfRess TerraformResources, patch *Patch, pathSyntax string) (TerraformResources, error)

Operate operates the patch on the given Terraform resources.

type Value

type Value struct {
	Attribute *hcl.Attribute
	Block     *hcl.Block
}

Jump to

Keyboard shortcuts

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