Skip to content

Commit

Permalink
feat: get-resource returns {} if json key not found
Browse files Browse the repository at this point in the history
This commit changes the behavior of the get-resource util to return {}
instead of the empty string if a jsonpath is passed and the key is not
found.

Signed-off-by: Johnny Bieren <[email protected]>
  • Loading branch information
johnbieren committed Oct 17, 2023
1 parent 970ae76 commit 6a3f840
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion utils/get-resource
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ IFS='/' read -r namespace name <<< "$namespaced_name"

# If a jsonpath is provided, append it to the kubectl command
if [ ! -z "$jsonpath" ]; then
kubectl get $resource_type -n $namespace $name -o jsonpath="$jsonpath"
kubectl get $resource_type -n $namespace $name -o jsonpath="$jsonpath" --allow-missing-template-keys=false || echo "{}"
else
kubectl get $resource_type -n $namespace $name -o json
fi

0 comments on commit 6a3f840

Please sign in to comment.