yannh / kubeconform

A FAST Kubernetes manifests validator, with support for Custom Resources!
Apache License 2.0
2.15k stars 121 forks source link

How to use with envsubst? #226

Closed koroldavid closed 11 months ago

koroldavid commented 1 year ago

Given such config:

apiVersion: apps/v1
kind: Deployment
spec:
  replicas: ${REPLICA_COUNT}
  ...

Its validation will result in an error:

"msg": "For field spec.replicas: Invalid type. Expected: [integer,null], given: string"

Technically, kubeconform working correctly. However, in practice, I will replace ${REPLICA_COUNT} using envsubst < test-config.yaml. So I want to ignore it by my CI.

My current workaround is to substitute all ${*} with null. Write that content to a temporary file. And finally validate it.

Is there any better approach? The ability to ignore a rule per some line might come in handy

yannh commented 1 year ago

Hi! You can pipe the result to kubeconform to avoid the temporary file... I'm not sure of a way to avoid replacing the variables before invoking Kubeconform though!

yannh commented 11 months ago

I'll be closing this issue since it's slightly out of scope, feel free to update if you ever found a solution :pray: !