tfkschema

package
v0.0.0-...-8549fe5 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2019 License: MPL-2.0 Imports: 10 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 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 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.

Types

This section is empty.

Jump to

Keyboard shortcuts

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