Created
June 11, 2021 07:59
-
-
Save rbo/863e8cfbbb527dbeedc1562a3ef540ba to your computer and use it in GitHub Desktop.
Newlines in "eval" break "del()" behaviour
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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