Skip to content

Commit

Permalink
Update boilerplate image to us yq:v4.34.2
Browse files Browse the repository at this point in the history
This commit removes yq:v3 dependencies for the subscriber script within
boilerplate as well as the golang-osd-operator's csv-generate script by
refactoring the yq commands to use the yq:v4 syntax.

Signed-off-by: Michael Shen <[email protected]>
  • Loading branch information
mjlshen committed Aug 7, 2023
1 parent 816e2ff commit 3406777
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 22 deletions.
6 changes: 2 additions & 4 deletions boilerplate/_lib/subscriber.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,11 @@ SUBSCRIBERS_FILE=$REPO_ROOT/subscribers.yaml
# all: Prints all subscribers
# onboarded: Prints only onboarded subscribers
subscriber_list() {
local filt
case $1 in
all) filt='[*]';;
all) yq '.subscribers[] | .name' $SUBSCRIBERS_FILE;;
# TODO: Right now subscribers are only "manual".
onboarded) filt='(conventions.**.status==manual)';;
onboarded) yq '.subscribers[] | select(.conventions[].status == "manual") | .name' $SUBSCRIBERS_FILE;;
esac
yq r $SUBSCRIBERS_FILE "subscribers${filt}.name"
}

## last_bp_commit ORG/PROJ
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fi
if [[ -z "$CONTAINER_ENGINE" ]]; then
YQ_CMD="yq"
else
yq_image="quay.io/app-sre/yq:3.4.1"
yq_image="quay.io/app-sre/yq:4"
$CONTAINER_ENGINE pull $yq_image
YQ_CMD="$CONTAINER_ENGINE run --rm -i $yq_image yq"
fi
Expand Down Expand Up @@ -99,7 +99,7 @@ if [[ -z "$SKIP_SAAS_FILE_CHECKS" ]]; then
# For customer clusters: /services/osd-operators/namespace/<hive shard>/namespaces/cluster-scope.yaml
# For hive clusters: /services/osd-operators/namespace/<hive shard>/namespaces/<namespace name>.yaml
MANAGED_RESOURCE_TYPE=$(curl -s "${SAAS_FILE_URL}" | \
$YQ_CMD r - "managedResourceTypes[0]"
$YQ_CMD '.managedResourceTypes[0]' -
)
if [[ "${MANAGED_RESOURCE_TYPE}" == "" ]]; then
echo "Unabled to determine if SAAS file managed resource type"
Expand All @@ -118,9 +118,11 @@ if [[ -z "$SKIP_SAAS_FILE_CHECKS" ]]; then
# remove any versions more recent than deployed hash
if [[ "$operator_channel" == "production" ]]; then
if [ -z "$DEPLOYED_HASH" ] ; then
deployed_hash_yq_filter=".resourceTemplates[].targets[] | select(.namespace.\$ref == \"${resource_template_ns_path}\") | .ref"
DEPLOYED_HASH=$(
curl -s "${SAAS_FILE_URL}" | \
$YQ_CMD r - "resourceTemplates[*].targets(namespace.\$ref==${resource_template_ns_path}).ref"
# Surround yq filter in single quotes
$YQ_CMD "'"${deployed_hash_yq_filter}"'" -
)
fi

Expand Down
2 changes: 1 addition & 1 deletion boilerplate/test/test-base-convention/update
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ echo "Validating variables exported from the main update driver"
# Granny switch to disable this check for weird tests like reverting to master
if [[ -z "$SKIP_IMAGE_TAG_CHECK" ]]; then
# Update this when publishing a new image tag
[[ "$LATEST_IMAGE_TAG" == "image-v3.0.5" ]] || err "Bad LATEST_IMAGE_TAG: '$LATEST_IMAGE_TAG'"
[[ "$LATEST_IMAGE_TAG" == "image-v3.0.6" ]] || err "Bad LATEST_IMAGE_TAG: '$LATEST_IMAGE_TAG'"
fi
18 changes: 6 additions & 12 deletions config/build_image-v3.0.0.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ go install github.com/golang/mock/mockgen@${MOCKGEN_VERSION}
GO_BINDATA_VERSION=v3.1.2
go install github.com/go-bindata/go-bindata/...@${GO_BINDATA_VERSION}

####
# yq
####
YQ_VERSION="v4.34.2"
go install github.com/mikefarah/yq/v4@${YQ_VERSION}

# HACK: `go get` creates lots of things under GOPATH that are not group
# accessible, even if umask is set properly. This causes failures of
# subsequent go tool usage (e.g. resolving packages) by a non-root user,
Expand All @@ -92,18 +98,6 @@ for bit in r x w; do
find $dir -perm -u+${bit} -a ! -perm -g+${bit} -exec chmod g+${bit} '{}' +
done

####
# yq
####
YQ_VERSION="3.4.1"
YQ_SHA256SUM="adbc6dd027607718ac74ceac15f74115ac1f3caef68babfb73246929d4ffb23c"
YQ_LOCATION=https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64

curl -L -o yq $YQ_LOCATION
echo ${YQ_SHA256SUM} yq | sha256sum -c
chmod ugo+x yq
mv yq /usr/local/bin

####
# gh
####
Expand Down
2 changes: 1 addition & 1 deletion doc/subscriber.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Some caveats:
- The command lives at `./boilerplate/_lib/subscriber`. You may wish to alias or `$PATH` this. But note:
- It (probably) only works if your PWD is the root of the boilerplate repository. (FIXME?)
- Certain subcommands rely on the [`gh` command](https://github.com/cli/cli) being installed and properly configured.
- It relies on [`yq` version 3.x](https://mikefarah.gitbook.io/yq/v/v3.x/). (FIXME: v3 is deprecated.)
- It relies on [`yq` version 4.x](https://mikefarah.gitbook.io/yq/v/v4.x/).

Subcommands follow:

Expand Down
2 changes: 1 addition & 1 deletion test/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ if [ "$BOILERPLATE_SET_X" ]; then
fi

# NOTE: Change this when publishing a new image tag.
LATEST_IMAGE_TAG=image-v3.0.5
LATEST_IMAGE_TAG=image-v3.0.6

REPO_ROOT=$(git rev-parse --show-toplevel)
# Make all tests use this local clone by default.
Expand Down

0 comments on commit 3406777

Please sign in to comment.