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
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
Click to show internal directories.
Click to hide internal directories.