Skip to content

Option to remove fields with null value #61

Open
@arthurk

Description

@arthurk

I'm trying to install Istio. I've generated the YAML manifests and converted them to HCL using:

$ istioctl manifest generate > istio.yaml
$ tfk8s -f istio.yaml > istio.tf

Applying with terraform is failing:

Error: API response status: Failure

  with kubernetes_manifest.deployment_istio_system_istio_ingressgateway,
  on istio.tf line 14211, in resource "kubernetes_manifest" "deployment_istio_system_istio_ingressgateway":
14211: resource "kubernetes_manifest" "deployment_istio_system_istio_ingressgateway" {

Deployment.apps "istio-ingressgateway" is invalid:
spec.template.spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms: Required value: must
have at least one node selector term

The problem is with the conversion of null values. The YAML includes:

affinity:
  nodeAffinity:
    requiredDuringSchedulingIgnoredDuringExecution:
    preferredDuringSchedulingIgnoredDuringExecution:

and was converted to:

"affinity" = {
  "nodeAffinity" = {
    "preferredDuringSchedulingIgnoredDuringExecution" = null
    "requiredDuringSchedulingIgnoredDuringExecution" = null
  }
}

After removing the null fields in the YAML or HCL file, the apply was successful.

Is it possible to implement an option in tfk8s that would automatically strip out YAML fields that have no value?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions