backend

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2023 License: Apache-2.0 Imports: 25 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, credentials map[string]string, controllerNSSpecified bool) (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
	// LegacySecretSuffix is the same as SecretSuffix, but only used when `--controller-namespace` is specified
	LegacySecretSuffix 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 S3Backend added in v0.7.4

type S3Backend struct {
	Region string
	Key    string
	Bucket string
	// contains filtered or unexported fields
}

S3Backend is used to interact with the Terraform s3 backend

func (*S3Backend) CleanUp added in v0.7.4

func (s *S3Backend) CleanUp(_ context.Context) error

CleanUp will delete the s3 object which contains the Terraform state

func (*S3Backend) GetTFStateJSON added in v0.7.4

func (s *S3Backend) GetTFStateJSON(_ context.Context) ([]byte, error)

GetTFStateJSON gets Terraform state json from the Terraform s3 backend

func (S3Backend) HCL added in v0.7.4

func (s S3Backend) HCL() string

HCL returns the backend hcl code string

Jump to

Keyboard shortcuts

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