ContainerImage.Pinniped/hack/update.sh
Ryan Richard f501c76acc Add generated code for Kube 1.21, 1.22, and 1.23
Also:
- Make our code generator script work with Go 1.17
- Make our update.sh script work on linux
- Update the patch versions of the old Kube versions that we were using
  to generate code (see kube-versions.txt)
- Use our container images from ghcr instead of
  projects.registry.vmware.com for codegen purposes
- Make it easier to debug in the future by passing "-v" to the Kube
  codegen scripts
- Updated copyright years to make commit checks pass
2022-02-28 17:58:48 -08:00

38 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Copyright 2020-2022 the Pinniped contributors. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
set -euo pipefail
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
# Generate code.
xargs -n 1 -P 8 "$ROOT/hack/lib/update-codegen.sh" < "${ROOT}/hack/lib/kube-versions.txt"
# Copy the latest version into a ./generated/latest directory so we can depend on it without nested modules.
LATEST_MINOR_VERSION="$(head -1 < "${ROOT}/hack/lib/kube-versions.txt" | cut -d"." -f1-2)"
LATEST_ROOT="$ROOT/generated/latest"
rm -rf "$LATEST_ROOT"
cp -r "$ROOT/generated/$LATEST_MINOR_VERSION/" "$LATEST_ROOT"
find "$LATEST_ROOT" \( -name "go.mod" -or -name "go.sum" -or -name "README.adoc" \) -delete
rm -r "$LATEST_ROOT/crds"
if [[ "$(uname -s)" == "Linux" ]]; then
# docker on linux preserves the root ownership of the output files of update-codegen.sh,
# so chown the files before editing them.
sudo chown -R "$(id --user)" generated
sudo chgrp -R "$(id --group)" generated
# sed on Linux uses -i'' (no space in between).
find "$LATEST_ROOT" -type f -print0 | xargs -0 sed -i'' -e "s|go.pinniped.dev/generated/$LATEST_MINOR_VERSION|go.pinniped.dev/generated/latest|g"
else
# sed on MacOS uses -i '' (with space in between).
find "$LATEST_ROOT" -type f -print0 | xargs -0 sed -i '' -e "s|go.pinniped.dev/generated/$LATEST_MINOR_VERSION|go.pinniped.dev/generated/latest|g"
fi
# Copy each CRD yaml to the app which should cause it to be installed.
cp "$ROOT"/generated/"$LATEST_MINOR_VERSION"/crds/*.supervisor.*.yaml "$ROOT/deploy/supervisor"
cp "$ROOT"/generated/"$LATEST_MINOR_VERSION"/crds/*.concierge.*.yaml "$ROOT/deploy/concierge"
# Tidy.
"$ROOT/hack/module.sh" tidy