Open deftdawg opened 5 years ago
This seems like a nice to have, but lower priority.
Approved.
+1
I'm looking for a workaround (since my go-lang contribution abilities are too restricted): wrap goss add
into an alias that would modify the generated goss.yaml to permute the command into the exec
attribute, and replace the top command with the content of an option.
Here is what the manual change I would like to automate in this workaround
git diff
@@ -1,5 +1,8 @@
+# Currently, goss add does not support passing the command alias as argment
command:
- kubectl get pod -o=custom-columns=STATUS:.status.phase,NODE:.spec.nodeName | sort -r:
+ "One pod per agent node to enforce IP source being preserved":
+ exec: |
+ kubectl get pod -o=custom-columns=STATUS:.status.phase,NODE:.spec.nodeName | sort -r:
exit-status: 0
stdout:
- STATUS NODE
Not obvious as a first look using yq mostly because of the variable key names and need to escape white spaces and other characters from key names:
Fetch the key(s) name:
KEYNAME=$(cat goss.yaml | yq -r '(.command | keys[0])')
echo $KEYNAME
#> kubectl get pod -o=custom-columns=STATUS:.status.phase,NODE:.spec.nodeName | sort -r
Fetch the value needs white space escape
cat goss.yaml | yq -r "(.command.$KEYNAME)"
#> Error: 1:19: invalid input text "get pod -o=custo..."
Replace the key map (see https://mikefarah.gitbook.io/yq/operators/keys#update-map-key)
Replace the key with a short DESC (see https://mikefarah.gitbook.io/yq/operators/keys#update-map-key)
I have a scenario where I parse a config ini file and then generate calls to goss. It would be helpful if there was a way to invoke goss and have the title written to the goss.yaml file in a way similar to this: