From f9c6e19eb34c4047fef588e2d7f13f8ee2fa0cb8 Mon Sep 17 00:00:00 2001 From: Vihang Mehta Date: Sat, 21 Jan 2023 05:39:45 +0000 Subject: [PATCH] Fix some shellcheck issues Summary: There were some shellcheck ignores that should have been addressed. Also cleanup the shell cmds in some genrules. Test Plan: Ran the rules, ensured that the output was correct. Reviewers: michelle, zasgar Reviewed By: michelle Signed-off-by: Vihang Mehta Differential Revision: https://phab.corp.pixielabs.ai/D12885 GitOrigin-RevId: acebfb7d14986be9057a06dcc4c7a56c738f76c3 --- ci/cloud_build_release.sh | 16 ++++++++-------- ci/operator_helm_build_release.sh | 3 +-- k8s/vizier/BUILD.bazel | 8 ++------ 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/ci/cloud_build_release.sh b/ci/cloud_build_release.sh index 359c48c75e9..958ecfffd7e 100755 --- a/ci/cloud_build_release.sh +++ b/ci/cloud_build_release.sh @@ -65,20 +65,20 @@ if [[ "$PUBLIC" == "true" ]]; then gsutil cp "${repo_path}/bazel-bin/tools/licenses/all_licenses.json" "gs://pixie-dev-public/oss-licenses/latest.json" # Write YAMLs + image paths to a tar file to support easy deployment. - mkdir -p "${repo_path}/pixie_cloud" mkdir -p "${repo_path}/pixie_cloud/yamls" image_list_file="${repo_path}/pixie_cloud/cloud_image_list.txt" kustomize build "k8s/cloud_deps/public/" > "${repo_path}/pixie_cloud/yamls/cloud_deps.yaml" - kustomize build "k8s/cloud_deps/base/elastic/operator" >> "${repo_path}/pixie_cloud/yamls/cloud_deps_elastic_operator.yaml" + kustomize build "k8s/cloud_deps/base/elastic/operator" > "${repo_path}/pixie_cloud/yamls/cloud_deps_elastic_operator.yaml" kustomize build "k8s/cloud/public/" > "${repo_path}/pixie_cloud/yamls/cloud.yaml" - #shellcheck disable=SC2002 - cat "${repo_path}/pixie_cloud/yamls/cloud_deps.yaml" | yq e '.. | .image? | select(.)' -o=json - | jq 'strings' | sort | uniq > "${image_list_file}" - #shellcheck disable=SC2002 - cat "${repo_path}/pixie_cloud/yamls/cloud_deps_elastic_operator.yaml" | yq e '.. | .image? | select(.)' -o=json - | jq 'strings' | sort | uniq > "${image_list_file}" - #shellcheck disable=SC2002 - cat "${repo_path}/pixie_cloud/yamls/cloud.yaml" | yq e '.. | .image? | select(.)' -o=json - | jq 'strings' | sort | uniq >> "${image_list_file}" + deploy_yamls=( + "${repo_path}/pixie_cloud/yamls/cloud_deps.yaml" + "${repo_path}/pixie_cloud/yamls/cloud_deps_elastic_operator.yaml" + "${repo_path}/pixie_cloud/yamls/cloud.yaml" + ) + + yq e '.. | .image? | select(.)' -o=json "${deploy_yamls[@]}" | jq 'strings' | sort | uniq > "${image_list_file}" cd "${repo_path}" tar -czvf "${repo_path}/pixie_cloud.tar.gz" "pixie_cloud" diff --git a/ci/operator_helm_build_release.sh b/ci/operator_helm_build_release.sh index 28059298ff6..45616374aed 100755 --- a/ci/operator_helm_build_release.sh +++ b/ci/operator_helm_build_release.sh @@ -52,8 +52,7 @@ version: ${VERSION}" > "${helm_path}/Chart.yaml" cp "${repo_path}/k8s/operator/crd/base/px.dev_viziers.yaml" "${helm_path}/crds/vizier_crd.yaml" # Updates templates with Helm-specific template functions. -#shellcheck disable=SC2016,SC2086 -helm_tmpl_checks="$(cat ${repo_path}/k8s/operator/helm/olm_template_checks.tmpl)" +helm_tmpl_checks="$(cat "${repo_path}/k8s/operator/helm/olm_template_checks.tmpl")" sed -i "1c${helm_tmpl_checks}" "${repo_path}/k8s/operator/helm/templates/00_olm.yaml" rm "${repo_path}/k8s/operator/helm/olm_template_checks.tmpl" diff --git a/k8s/vizier/BUILD.bazel b/k8s/vizier/BUILD.bazel index 2cb430033fb..704c81b07c2 100644 --- a/k8s/vizier/BUILD.bazel +++ b/k8s/vizier/BUILD.bazel @@ -290,9 +290,7 @@ genrule( ], outs = ["vizier_etcd_image_list.txt"], cmd = """ - T=`mktemp -d` - for FILE in $(SRCS); do cat $$FILE | yq e '.. | .image? | select(.)' -o=json - | jq 'strings' | sort | uniq >> $@; done - touch $@ + yq e '.. | .image? | select(.)' -o=json $(SRCS) | jq 'strings' | sort | uniq > $@ """, ) @@ -313,9 +311,7 @@ genrule( ], outs = ["vizier_image_list.txt"], cmd = """ - T=`mktemp -d` - for FILE in $(SRCS); do cat $$FILE | yq e '.. | .image? | select(.)' -o=json - | jq 'strings' | sort | uniq >> $@; done - touch $@ + yq e '.. | .image? | select(.)' -o=json $(SRCS) | jq 'strings' | sort | uniq > $@ """, )