Change:
done return 1 } <ins> kube::test::version::object_to_file() { name=$1 flags=${2:-""} file=$3 kubectl version $flags | grep "$name Version:" | sed -e s/"$name Version: version.Info{"/'/' -e s/'}'/'/' -e s/', '/','/g -e s/':'/'=/g' -e s/'"'/""/g | tr , 'n' > "${file}" } kube::test::version::json_object_to_file() { flags=$1 file=$2 kubectl version $flags --output json | sed -e s/'"'/''/g -e s/'}'/''/g -e s/'{'/''/g -e s/'clientVersion:'/'clientVersion:,'/ -e s/'serverVersion:'/'serverVersion:,'/ | tr , 'n' > "${file}" } kube::test::version::json_client_server_object_to_file() { flags=$1 name=$2 file=$3 kubectl version $flags --output json | jq -r ".${name}" | sed -e s/'"'/''/g -e s/'}'/''/g -e s/'{'/''/g -e /^$/d -e s/','/''/g  -e s/':'/'='/g > "${file}" } kube::test::version::yaml_object_to_file() { flags=$1 file=$2 kubectl version $flags --output yaml | sed -e s/' '/''/g -e s/'"'/''/g -e /^$/d > "${file}" } kube::test::version::diff_assert() { local original=$1 local comparator=${2:-"eq"} local latest=$3 local diff_msg=${4:-""} local res="" if [ ! -f $original ]; then echo ${bold}${red} echo "FAIL! ${diff_msg}" echo "the file '${original}' does not exit" echo ${reset}${red} caller echo ${reset} return 1 fi if [ ! -f $latest ]; then echo ${bold}${red} echo "FAIL! ${diff_msg}" echo "the file '${latest}' does not exit" echo ${reset}${red} caller echo ${reset} return 1 fi sort ${original} > "${original}.sorted" sort ${latest} > "${latest}.sorted" if [ "$comparator" == "eq" ]; then if [ "$(diff -iwB ${original}.sorted ${latest}.sorted)" == "" ] ; then echo -n ${green} echo "Successful: ${diff_msg}" echo -n ${reset} return 0 else echo ${bold}${red} echo "FAIL! ${diff_msg}" echo "  Expected: " echo "$(cat ${original})" echo "  Got: " echo "$(cat ${latest})" echo ${reset}${red} caller echo ${reset} return 1 fi else if [ ! -z "$(diff -iwB ${original}.sorted ${latest}.sorted)" ] ; then echo -n ${green} echo "Successful: ${diff_msg}" echo -n ${reset} return 0 else echo ${bold}${red} echo "FAIL! ${diff_msg}" echo "  Expected: " echo "$(cat ${original})" echo "  Got: " echo "$(cat ${latest})" echo ${reset}${red} caller echo ${reset} return 1 fi fi } </ins>

Discussion:
<!-- Thanks for filing an issue! Before hitting the button, please answer these questions.--Is this a request for help? (If yes, you should use our troubleshooting guide and community support channels, see ): no What keywords did you search in Kubernetes issues before filing this one? (If you have found any duplicates, you should instead reply there.): "kubectl version", "kubectl version" json Is this a BUG REPORT or FEATURE REQUEST? (choose one): Feature request Kubernetes version (use ): $ kubectl version --client Client Version: version.Info{Major:"1", Minor:"4", GitVersion:"v1.4.6", GitCommit:"", GitTreeState:"clean", BuildDate:"2016-11-12T05:22:15Z", GoVersion:"go1.7.1", Compiler:"gc", Platform:"darwin/amd64"} Environment: Cloud provider or hardware configuration: GKE OS (e.g. from /etc/os-release): MacOS 10.12.2 I find it difficult to parse the output of programmatically. I have to use a YAML parser to do it. I'd prefer to use JSON, or to be given just the string and asked to parse it with a regex. This is obviously a relatively low-priority request.
I wouldnt mind helping out on this, if there are no objections?
are you working on this? If not, I would like to work on it.
I plan to, but if i'll keep you posted if i get too delayed.
How can I direct message you?
didnt see this till now, felt bad i had not kept up on this so i decided to just push through it. If my email is not available in my profile, please let me know, otherwise AT gmail would be the best way to contact me.
Thanks!
Included below are some examples. Let me know what you think, my only concern is the the original output of included the key and then the object type which is a little strange. Note the output flag is optional so we don't break previous behavior and contract, which is now baked and part of e2e testing. here are the couple of samples: