Skip to content

Instantly share code, notes, and snippets.

@rbo
Created June 11, 2021 07:59
Show Gist options
  • Save rbo/863e8cfbbb527dbeedc1562a3ef540ba to your computer and use it in GitHub Desktop.
Save rbo/863e8cfbbb527dbeedc1562a3ef540ba to your computer and use it in GitHub Desktop.
Newlines in "eval" break "del()" behaviour
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
annotations:
include.release.openshift.io/self-managed-high-availability: "true"
include.release.openshift.io/single-node-developer: "true"
creationTimestamp: "2021-03-19T18:28:38Z"
name: machine-api-operator
resourceVersion: "2156"
selfLink: /apis/rbac.authorization.k8s.io/v1/clusterrolebindings/machine-api-operator
uid: 1594b3cb-bfc6-451b-8c32-4e114196b334
#!/usr/bin/env bash
set -xe
cat example.yaml
echo "Single line eval pass:"
yq eval ' del( .metadata.uid, .metadata.creationTimestamp, .metadata.managedFields, .metadata.resourceVersion, .metadata.selfLink) ' example.yaml
echo "Multihttps://docs.google.com/document/d/1yBdx4O1IFtDhKQxAipMr3JC0wbRm98nB31XfI7LE4hg/edit#heading=h.3qjsun3cm2c1 line eval fail:"
yq eval '
del(
.metadata.uid,
.metadata.creationTimestamp,
.metadata.managedFields,
.metadata.resourceVersion,
.metadata.selfLink
) ' example.yaml
yq -V
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment