From 0e8b6515afaa0131fbbd9665ebfa5111d602b60c Mon Sep 17 00:00:00 2001 From: Aleksei Sviridkin Date: Thu, 19 Feb 2026 17:42:31 +0300 Subject: [PATCH] fix(installer): handle parsePlatformSourceURL error, restore variant validation Check error from parsePlatformSourceURL instead of discarding it, preventing silent fallback to OCIRepository on invalid URLs. Move variant validation from deleted packagesource.yaml to cozystack-operator.yaml template so invalid cozystackOperator.variant values still fail at helm template/install time. Co-Authored-By: Claude Signed-off-by: Aleksei Sviridkin --- cmd/cozystack-operator/main.go | 6 +++++- packages/core/installer/templates/cozystack-operator.yaml | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/cozystack-operator/main.go b/cmd/cozystack-operator/main.go index ba5730e2..cb19a3d3 100644 --- a/cmd/cozystack-operator/main.go +++ b/cmd/cozystack-operator/main.go @@ -225,7 +225,11 @@ func main() { // Create platform PackageSource that references the source resource setupLog.Info("Creating platform PackageSource", "platformSourceName", platformSourceName) - sourceType, _, _ := parsePlatformSourceURL(platformSourceURL) + sourceType, _, err := parsePlatformSourceURL(platformSourceURL) + if err != nil { + setupLog.Error(err, "failed to parse platform source URL for PackageSource creation") + os.Exit(1) + } sourceRefKind := "OCIRepository" if sourceType == "git" { sourceRefKind = "GitRepository" diff --git a/packages/core/installer/templates/cozystack-operator.yaml b/packages/core/installer/templates/cozystack-operator.yaml index b33d186a..fcd499a8 100644 --- a/packages/core/installer/templates/cozystack-operator.yaml +++ b/packages/core/installer/templates/cozystack-operator.yaml @@ -1,3 +1,7 @@ +{{- $validVariants := list "talos" "generic" "hosted" -}} +{{- if not (has .Values.cozystackOperator.variant $validVariants) -}} +{{- fail (printf "Invalid cozystackOperator.variant %q: must be one of talos, generic, hosted" .Values.cozystackOperator.variant) -}} +{{- end -}} --- apiVersion: v1 kind: Namespace