From 2d82d428008dae733684c0f65cc199ef1608405e Mon Sep 17 00:00:00 2001 From: Christopher Tauchen Date: Wed, 4 Feb 2026 13:41:35 +0000 Subject: [PATCH 1/2] Add script that updates Felix configs This script updates the FelixConfiguration component with data from projectcalico/calico and tigera/calico-private. DOCS-2833 Add script for updating Felix configs --- scripts/update-felix-config.sh | 157 +++++++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100755 scripts/update-felix-config.sh diff --git a/scripts/update-felix-config.sh b/scripts/update-felix-config.sh new file mode 100755 index 0000000000..6f9b760c9d --- /dev/null +++ b/scripts/update-felix-config.sh @@ -0,0 +1,157 @@ +#!/usr/bin/env bash + +############################################################################### +# # +# felix-update-config-ce.sh # +# Created: 2026-02-05 # +# # +# Description: Synchronizes Felix configuration JSON files from GitHub # +# repos (OSS & Enterprise) into local documentation paths. # +# # +############################################################################### + +# --- Safety & Environment --- +set -euo pipefail + +# --- Global Constants (No Magic Numbers) --- +readonly SUCCESS=0 +readonly E_MISSING_TOKEN=1 +readonly E_INVALID_JSON=2 +readonly VERSIONS_FILE_OSS="calico_versions.json" +readonly VERSIONS_FILE_CE="calico-enterprise_versions.json" + +# --- Global Variables --- +VERSIONS_OSS=($(jq -r '.[]' "$VERSIONS_FILE_OSS")) +VERSIONS_CE=($(jq -r '.[]' "$VERSIONS_FILE_CE")) +CLEANUP_FILES=() + +# --------------------------------------------------------------------------- # +# cleanup() # +# Internal function triggered on script exit to remove all temp files. # +# --------------------------------------------------------------------------- # +cleanup() { + local file + for file in "${CLEANUP_FILES[@]:-}"; do + if [[ -f "$file" ]]; then + rm -f "$file" + fi + done +} + +trap cleanup EXIT + +# --------------------------------------------------------------------------- # +# update_felix_config() # +# Downloads a remote JSON file and replaces a local target file. # +# --------------------------------------------------------------------------- # +update_felix_config() { + local tmpfile + tmpfile=$(mktemp -t remote-url-output.XXXXXX) + CLEANUP_FILES+=("$tmpfile") + + printf "%s\n\n" "Begin processing $VERSION" + printf "%s\n" "Target path: $LOCAL_PATH" + printf "%s\n" "Source URL: $REMOTE_URL" + + curl -fsSL \ + -H "Authorization: token $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github.v3.raw" \ + -o "$tmpfile" \ + "$REMOTE_URL" + + if jq -e . "$tmpfile" >/dev/null 2>&1; then + echo "Success: $tmpfile is valid JSON." + else + echo "Error: $tmpfile contains invalid JSON." >&2 + exit "$E_INVALID_JSON" + fi + + mv "$tmpfile" "$LOCAL_PATH" + printf "%s\n\n\n" "Finished processing $VERSION." +} + +# --------------------------------------------------------------------------- # +# OSS Functions # +# --------------------------------------------------------------------------- # + +update_master_OSS () { + VERSION="master" + LOCAL_PATH="calico/_includes/components/FelixConfig/config-params.json" + REMOTE_URL="https://raw.githubusercontent.com/projectcalico/calico/refs/heads/master/felix/docs/config-params.json" + update_felix_config +} + +update_versions_OSS () { + local -n VERSIONS_ARRAY=$1 + local i + for i in "${!VERSIONS_ARRAY[@]}"; do + VERSION="${VERSIONS_ARRAY[$i]}" + LOCAL_PATH="calico_versioned_docs/version-${VERSION}/_includes/components/FelixConfig/config-params.json" + REMOTE_URL="https://raw.githubusercontent.com/projectcalico/calico/refs/heads/release-v${VERSION}/felix/docs/config-params.json" + + if [[ "$VERSION" == "3.29" ]]; then + printf "%s\n" "Skipping $VERSION: No action required." + continue + fi + + update_felix_config + done +} + +# --------------------------------------------------------------------------- # +# Enterprise Functions # +# --------------------------------------------------------------------------- # + +update_master_CE () { + VERSION="master" + LOCAL_PATH="calico-enterprise/_includes/components/FelixConfig/config-params.json" + REMOTE_URL="https://api.github.com/repos/tigera/calico-private/contents/felix/docs/config-params.json?ref=master" + update_felix_config +} + +update_versions_CE() { + local -n VERSIONS_ARRAY=$1 + local i branch base_version + + for i in "${!VERSIONS_ARRAY[@]}"; do + VERSION="${VERSIONS_ARRAY[$i]}" + base_version="${VERSION%-*}" + + if [[ "$VERSION" == *"-2" ]]; then + branch="release-calient-v${base_version}" + elif [[ "$VERSION" == *"-1" ]]; then + branch="release-calient-v${base_version}-1" + else + branch="release-v${VERSION}" + fi + + LOCAL_PATH="calico-enterprise_versioned_docs/version-${VERSION}/_includes/components/FelixConfig/config-params.json" + REMOTE_URL="https://api.github.com/repos/tigera/calico-private/contents/felix/docs/config-params.json?ref=${branch}" + + if [[ "$VERSION" == "3.20-2" ]]; then + printf "%s\n" "Skipping $VERSION: No action required." + continue + fi + + update_felix_config + done +} + +# --- Main Logic --- + +if [[ -z "${GITHUB_TOKEN:-}" ]]; then + echo "Error: GITHUB_TOKEN is not set." >&2 + exit "$E_MISSING_TOKEN" +fi + +printf "OSS Versions: %s\n" "${VERSIONS_OSS[*]}" +printf "CE Versions: %s\n\n" "${VERSIONS_CE[*]}" + +update_master_OSS +update_versions_OSS VERSIONS_OSS + +update_master_CE +update_versions_CE VERSIONS_CE + +printf "%s\n" "All updates are complete." +exit "$SUCCESS" \ No newline at end of file From 264abe1fae69ca3c1fc2efc4733984bbcb3c5eb4 Mon Sep 17 00:00:00 2001 From: Christopher Tauchen Date: Thu, 5 Feb 2026 17:14:21 +0000 Subject: [PATCH 2/2] Add update-felix-config script to Makefile --- Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Makefile b/Makefile index 93767ba539..1fc6fd9b71 100644 --- a/Makefile +++ b/Makefile @@ -365,3 +365,13 @@ vale: -v $(CURDIR)/.github/styles:/styles \ -v $(CURDIR):/docs \ -w /docs/$(PRODUCT) jdkato/vale . + +# --------------------------------------------------------------------------- # +# Felix Configuration Sync # +# --------------------------------------------------------------------------- # + +.PHONY: update-felix-config +update-felix-config: + $(if $(GITHUB_TOKEN),,$(error GITHUB_TOKEN is not set or empty, but is required)) + @echo "Updating Felix configurations for OSS and Enterprise..." + @./scripts/update-felix-config.sh \ No newline at end of file