Skip to content

Commit

Permalink
Update scripts for yq v4 CLI changes (#808)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuru authored Oct 8, 2022
1 parent 8f82eed commit 212bcc6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions rootfs/usr/local/bin/codefresh-pipeline
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ function download_pipelines() {
function convert_to_yaml() {
if [[ -n "$2" ]]; then
if [[ $2 == "-" ]]; then
yq r "$1"
yq -P "$1"
else
yq r "$1" >"$2"
yq -P "$1" >"$2"
fi
else
local subdirs="$3"
Expand All @@ -103,7 +103,7 @@ function convert_to_yaml() {
[[ -d "$project" ]] || mkdir -p "$project"
target="${project}/${target}"
fi
yq r "$1" >"$target"
yq -P "$1" >"$target"
green "* Wrote ${target}"
fi
}
Expand All @@ -118,7 +118,7 @@ function filter_pipeline() {
function compare_pipeline() {
# Check that the pipeline file exists and is parseable
local status
yq r "$1" >/dev/null 2>&1
yq -P "$1" >/dev/null 2>&1
status=$?

if (($status == 1)); then
Expand All @@ -130,7 +130,7 @@ function compare_pipeline() {
fi

local name
name=$(yq r -j "$1" | jq -r .metadata.name) || {
name=$(yq -o=json "$1" | jq -r .metadata.name) || {
red "! Cannot find pipeline name in $1"
return 1
}
Expand All @@ -139,7 +139,7 @@ function compare_pipeline() {

if (
set -o pipefail
codefresh get pipeline --limit 1 -o json "$name" | filter_pipeline | yq r - >"$old"
codefresh get pipeline --limit 1 -o json "$name" | filter_pipeline | yq -P - >"$old"
); then
yaml-diff "$old" "$1"
else
Expand Down
2 changes: 1 addition & 1 deletion rootfs/usr/local/bin/grafana-db
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function parse_dashboard_definition() {
# Compact the JSON to a single line
jq -rc
else
yq r -j '-d*' - | jq -rc '.. | if .data? then (.data | to_entries | .[].value | fromjson) elif .json? then .json else empty end'
yq -o=json - | jq -rc '.. | if .data? then (.data | to_entries | .[].value | fromjson) elif .json? then .json else empty end'
fi
}

Expand Down
2 changes: 1 addition & 1 deletion rootfs/usr/local/bin/helm3-metadata-fix
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function main() {

trap "rm -f $temp" EXIT

helm -n $namespace get manifest $release | yq r -j '-d*' - |
helm -n $namespace get manifest $release | yq -o=json - |
jq -c "$jqfilter" >"$temp"

if kubectl -n $namespace diff -f "$temp"; then
Expand Down

0 comments on commit 212bcc6

Please sign in to comment.