tfkschema

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAttrNotFound = fmt.Errorf("could not find attribute in resource schema")

Functions

func IncludedOnZero

func IncludedOnZero(attrName string) bool

IncludedOnZero checks the attribute name against a lookup table to determine if it can be included when it is zero / empty.

func IsAttributeRequired

func IsAttributeRequired(attrName string) bool

IsAttributeRequired scans the Terraform resource to determine if the named attribute is required by the Kubernetes provider.

func IsAttributeSupported

func IsAttributeSupported(attrName string) bool

IsAttributeSupported scans the Terraform resource to determine if the named attribute is supported by the Kubernetes provider.

func IsKubernetesKindSupported

func IsKubernetesKindSupported(obj runtime.Object) bool

IsKubernetesKindSupported returns true if a matching resource is found in the Terraform provider

func NormalizeTerraformMapKey

func NormalizeTerraformMapKey(s string) string

NormalizeTerraformMapKey converts Map keys to a form suitable for Terraform HCL

e.g. map keys that include certain characters ( '/', '.' ) will be wrapped in double quotes.

func NormalizeTerraformName

func NormalizeTerraformName(s string, toSingular bool, path string) string

normalizeTerraformName converts the given string to snake case and optionally to singular form of the given word s is the string to normalize set toSingular to true to singularize the given word path is the full schema path to the named element

func ObjectMeta

func ObjectMeta(obj runtime.Object) metav1.ObjectMeta

func ResourceField

func ResourceField(attrName string) *schema.Schema

ResourceField returns the Terraform schema object for the named resource field attrName should be in the form <resource>.path.to.field

func ResourceSchema

func ResourceSchema(name string) *schema.Resource

ResourceSchema returns the named Terraform Provider Resource schema as defined in the `terraform-provider-kubernetes` package

func ToTerraformAttributeName

func ToTerraformAttributeName(field *reflect.StructField, path string) string

ToTerraformAttributeName takes the reflect.StructField data of a Kubernetes object attribute and translates it to the equivalent `terraform-kubernetes-provider` schema format.

Sometimes the Kubernetes attribute name doesn't match struct name

e.g. `type ContainerPort struct` -> "ports" in YAML

so we need to extract the JSON name from the StructField tag. Finally, the attribute name is converted to snake case.

func ToTerraformResourceName

func ToTerraformResourceName(obj runtime.Object) string

ToTerraformResourceName extract the Kubernetes API Objects' name from the ObjectMeta

func ToTerraformResourceType

func ToTerraformResourceType(obj runtime.Object) string

ToTerraformResourceType converts a Kubernetes API Object Type name to the equivalent `terraform-provider-kubernetes` schema name.

func ToTerraformSubBlockName

func ToTerraformSubBlockName(field *reflect.StructField, path string) string

ToTerraformSubBlockName takes the reflect.StructField data of a Kubernetes object attribute and translates it to the equivalent `terraform-kubernetes-provider` schema format.

Sometimes the Kubernetes block name doesn't match struct name

e.g. `type ContainerPort struct` -> "ports" in YAML

so we need to extract the JSON name from the StructField tag. Next, the attribute name is converted to singular + snake case.

func TypeMeta

func TypeMeta(obj runtime.Object) metav1.TypeMeta

Types

type K8sObject

type K8sObject struct {
	Object           runtime.Object
	GroupVersionKind *schema.GroupVersionKind
}

Jump to

Keyboard shortcuts

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