Closed l0n3star closed 4 years ago
I'm using yq on OSX to try and get a key with contains a dot. Specifically I'm looking to get tls.crt. I tried:
yq
tls.crt
yq .data."tls.crt" tls.yaml
but it doesn't work. I just get null.
How can this be achieved? The yaml file is below.
cat tls.yaml apiVersion: v1 data: tls.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNxRENDQVpBQ0NRQzJ3Q2xDd3I2RlV6QU5CZ2txaGtpRzl3MEJBUXNGQURBV01SUXdFZ1lEVlFRRERBdG0KYjI4dVltRnlMbU52YlRBZUZ3MHlNREE0TVRBeE9UTTJNRE5hRncweU1UQTRNVEF4T1RNMk1ETmFNQll4RkRBUwpCZ05WQkFNTUMyWnZieTVpWVhJdVkyOXRNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDCkFRRUF0ZTgrZXNvc2Voc0UvYXErNUpHWTBzVzJUQTN1ZXN5Zi9UL3hTcXdXc25wMm9yQmphSE5xUUpaRzJHNWwKS0NnVFVxY3JwNFhraVhmS1hXelEzRml5R2N0SHZPSDdyRWhDVnBrVkM1QWtqMDN6aW40Tkc1UEdBaDdReHdMWApxSGhVR09QTFVXQk5iWDdFZlRjTHllSmNpU3l2QmlQVFZDYWJhSjdFWUUxbjNKcDFPcEhuTlFjb2ZPdnRablFaClRRdG4xNEt1NUFsbXRFWWNkaEZNcWZtQW9jUGhYdkZhZWVCZlcrNTlNSjc1OFJMME4vOWZjaEF1TDNhTWxoOEQKVy94ZjJsMldrTjVkYUZJNmJHSE9GYUdsNDhaN1hkZUFzMDNPRUVxVkJPa09FdjI0MTdWdHRtb1Y2blhLUTljUgp3UWdyU05kSjFtSkdWd0tRMHBCcFR2YU9Kd0lEQVFBQk1BMEdDU3FHU0liM0RRRUJDd1VBQTRJQkFRQUU2SjRqCkIwY0dHdXVGZ1BRY2w0RGVDcCtLcWxhNzNXTGoxdVQzWVVCajM2ZGVDSkZZdWFCQ0YvVXpOTm5CRFU1K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xaaGUKOFpKclZmTmJVZHlRMDZ5ZS9GWUtyQjJBaGsvdGczOEF6NlQyRWMxK1NnL3ozVTRKM3R2TG9KTFBBb0dCQUo5YgpXOC9uUXI5MEt2c2hyNlVWb2ZibE5IU1J4QTQxeTJFK3U2U2wyQ3ZFM25hczZtekJQc1BHZEdYQVVVSEZtbGlMCkQvdEJUWTZJelMwZW5XaUhMemd1dUVSMG9OSTlyTkF5Z01vN0ZhL3UxenZFcDJNcTY3alNORytrbTFMbkUzNDIKSHdmekNyazhOZ0t5aHc4ek5MWGhpRjJidHRwaVNzOFRiMXl0UDFMaEFvR0JBTjFibHdyTklKQW44UmFZeFZFVwpGa1hMZEF5b2t1WEdPcGVpaTJGckVHbnEyS3p3NUlva1MrQVVaVE83YWJIaGhFbDAxS3h3MXpLRDdZVGJVL01ECjVjYVFPWGtaZmFMYktDVk95MFVIekwzbXRtS3B1cW80UGhPK0NoRGRtcXFRTXRYWG5kR0tRUGVBWkMwNEYwYUcKSU1vSHZTT05DbDhYeEhUWXpvMWtWZFplCi0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K kind: Secret metadata: creationTimestamp: "2020-08-10T19:37:06Z" name: test-tls namespace: default resourceVersion: "853143" selfLink: /api/v1/namespaces/default/secrets/test-tls uid: 6955a6ab-2cf9-4c91-8ed9-f28769102918 type: kubernetes.io/tls
Please see here: https://stackoverflow.com/questions/37018393/how-to-use-jq-when-the-variable-has-a-period
Thanks. I did this:
yq '.data."tls.crt"' tls.yaml
and it works.
I'm using
yq
on OSX to try and get a key with contains a dot. Specifically I'm looking to gettls.crt
. I tried:but it doesn't work. I just get null.
How can this be achieved? The yaml file is below.