2020-08-07 00:30:18 +00:00
|
|
|
#!/usr/bin/env bash
|
2020-07-07 19:35:20 +00:00
|
|
|
|
2022-03-01 01:58:48 +00:00
|
|
|
# Copyright 2020-2022 the Pinniped contributors. All Rights Reserved.
|
2020-08-07 00:30:18 +00:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
2020-08-25 01:07:34 +00:00
|
|
|
|
2020-08-07 00:30:18 +00:00
|
|
|
set -euo pipefail
|
2020-08-25 01:07:34 +00:00
|
|
|
|
2020-08-12 00:48:16 +00:00
|
|
|
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
|
2020-08-07 00:30:18 +00:00
|
|
|
|
2020-10-09 17:00:22 +00:00
|
|
|
# Generate code.
|
2020-10-30 16:12:53 +00:00
|
|
|
xargs -n 1 -P 8 "$ROOT/hack/lib/update-codegen.sh" < "${ROOT}/hack/lib/kube-versions.txt"
|
2020-10-09 17:00:22 +00:00
|
|
|
|
2021-02-09 15:45:28 +00:00
|
|
|
# Copy the latest version into a ./generated/latest directory so we can depend on it without nested modules.
|
2022-03-01 01:58:48 +00:00
|
|
|
LATEST_MINOR_VERSION="$(head -1 < "${ROOT}/hack/lib/kube-versions.txt" | cut -d"." -f1-2)"
|
2021-02-09 15:45:28 +00:00
|
|
|
LATEST_ROOT="$ROOT/generated/latest"
|
|
|
|
rm -rf "$LATEST_ROOT"
|
2022-03-01 01:58:48 +00:00
|
|
|
cp -r "$ROOT/generated/$LATEST_MINOR_VERSION/" "$LATEST_ROOT"
|
2021-02-09 15:45:28 +00:00
|
|
|
find "$LATEST_ROOT" \( -name "go.mod" -or -name "go.sum" -or -name "README.adoc" \) -delete
|
|
|
|
rm -r "$LATEST_ROOT/crds"
|
2022-03-01 01:58:48 +00:00
|
|
|
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
|
2021-02-09 15:45:28 +00:00
|
|
|
|
2020-10-09 17:00:22 +00:00
|
|
|
# Copy each CRD yaml to the app which should cause it to be installed.
|
2022-03-01 01:58:48 +00:00
|
|
|
cp "$ROOT"/generated/"$LATEST_MINOR_VERSION"/crds/*.supervisor.*.yaml "$ROOT/deploy/supervisor"
|
|
|
|
cp "$ROOT"/generated/"$LATEST_MINOR_VERSION"/crds/*.concierge.*.yaml "$ROOT/deploy/concierge"
|
2020-10-09 17:00:22 +00:00
|
|
|
|
|
|
|
# Tidy.
|
2020-08-07 00:30:18 +00:00
|
|
|
"$ROOT/hack/module.sh" tidy
|