backend

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// TerraformStateNameInSecret is the key name to store Terraform state
	TerraformStateNameInSecret = "tfstate"
	// TFBackendSecret is the Secret name for Kubernetes backend
	TFBackendSecret = "tfstate-%s-%s"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	// HCL can get the hcl code string
	HCL() string

	// GetTFStateJSON is used to get the Terraform state json from backend
	GetTFStateJSON(ctx context.Context) ([]byte, error)

	// CleanUp is used to clean up the backend when delete the configuration object
	// For example, if the configuration use kubernetes backend, CleanUp will delete the backend secret
	CleanUp(ctx context.Context) error
}

Backend is an abstraction of what all backend types can do

func ParseConfigurationBackend

func ParseConfigurationBackend(configuration *v1beta2.Configuration, k8sClient client.Client) (Backend, error)

ParseConfigurationBackend parses backend Conf from the v1beta2.Configuration

type K8SBackend

type K8SBackend struct {
	// Client is used to interact with the Kubernetes apiServer
	Client client.Client
	// HCLCode stores the backend hcl code string
	HCLCode string
	// SecretSuffix is the suffix of the name of the Terraform backend secret
	SecretSuffix string
	// SecretNS is the namespace of the Terraform backend secret
	SecretNS string
}

K8SBackend is used to interact with the Terraform kubernetes backend

func (*K8SBackend) CleanUp

func (k *K8SBackend) CleanUp(ctx context.Context) error

CleanUp will delete the Terraform kubernetes backend secret when deleting the configuration object

func (*K8SBackend) GetTFStateJSON

func (k *K8SBackend) GetTFStateJSON(ctx context.Context) ([]byte, error)

GetTFStateJSON gets Terraform state json from the Terraform kubernetes backend

func (*K8SBackend) HCL

func (k *K8SBackend) HCL() string

HCL returns the backend hcl code string

type ParsedBackendConfig

type ParsedBackendConfig struct {
	// Name is the label of the backend hcl block
	// It means which backend type the configuration will use
	Name string `hcl:"name,label"`
	// Attrs are the key-value pairs in the backend hcl block
	Attrs hcl.Body `hcl:",remain"`
}

ParsedBackendConfig is a struct parsed from the backend hcl block

Jump to

Keyboard shortcuts

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