mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-09 05:25:14 +09:00
## What this PR does Add DNS-1035 validation for Application names to prevent creation of resources with invalid names that would fail Kubernetes resource creation. ### Changes - Add `ValidateApplicationName()` function using standard `IsDNS1035Label` from `k8s.io/apimachinery` - Call validation in REST API `Create()` method (skipped on `Update` — names are immutable) - Add name length validation: `prefix + name` must fit within Helm release name limit (53 chars) - Remove rootHost-based length validation — the underlying label limit issue is tracked in #2002 - Remove `parseRootHostFromSecret` and `cozystack-values` Secret reading at API server startup - Add unit tests for both DNS-1035 format and length validation ### DNS-1035 Requirements - Start with a lowercase letter `[a-z]` - Contain only lowercase alphanumeric or hyphens `[-a-z0-9]` - End with an alphanumeric character `[a-z0-9]` Fixes #1538 Closes #2001 ### Release note ```release-note [platform] Add DNS-1035 validation for Application names to prevent invalid tenant names ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Enforced DNS-1035 name format and Helm-compatible length limits for applications during creation; name constraints surfaced early and reflected in API validation. * **Documentation** * Updated tenant naming rules to DNS-1035, clarified hyphen guidance, and noted maximum length considerations. * **Tests** * Added comprehensive tests covering format and length validation, including many invalid and boundary cases. * **API** * OpenAPI/Swagger schemas updated to include name pattern and max-length validation. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
How to test packages local
cd packages/core/installer
make image-cozystack REGISTRY=YOUR_CUSTOM_REGISTRY
make apply
kubectl delete po -l app=source-controller -n cozy-fluxcd