func icon indicating copy to clipboard operation
func copied to clipboard

Add namespace validation to catch invalid names before build/deploy

Open RayyanSeliya opened this issue 1 month ago • 4 comments

Changes

  • :gift: Add early namespace validation with user-friendly error messages
  • :bug: Prevent wasted build time when using invalid namespace names
  • :broom: Add comprehensive unit tests for namespace validation

Adds DNS-1123 validation for namespace names before build/deploy operations. Invalid namespace names now fail immediately with clear error messages instead of proceeding through lengthy builds.

Implementation:

  • Add ValidateNamespace() function using Kubernetes DNS-1123 validation (pkg/utils/names.go)
  • Add validation check in deployConfig.Validate() and error handling in runDeploy() (cmd/deploy.go)
  • Add ErrInvalidNamespace error type (pkg/functions/errors.go) with user-friendly CLI message

/kind enhancement

Fixes #3132

Release Note

Invalid namespace names are now caught immediately with helpful error messages, preventing wasted build time

RayyanSeliya avatar Oct 22 '25 19:10 RayyanSeliya

Hi @RayyanSeliya. Thanks for your PR.

I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

knative-prow[bot] avatar Oct 22 '25 19:10 knative-prow[bot]

Codecov Report

:x: Patch coverage is 38.88889% with 11 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 63.10%. Comparing base (b785e68) to head (a8a0ec9). :warning: Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
cmd/deploy.go 15.38% 9 Missing and 2 partials :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3133      +/-   ##
==========================================
+ Coverage   62.37%   63.10%   +0.73%     
==========================================
  Files         150      150              
  Lines       13501    13519      +18     
==========================================
+ Hits         8421     8531     +110     
+ Misses       4103     3981     -122     
- Partials      977     1007      +30     
Flag Coverage Δ
e2e-tests 42.25% <16.66%> (+1.42%) :arrow_up:
integration-tests 57.51% <11.11%> (+1.59%) :arrow_up:
unit-tests 49.44% <38.88%> (-0.03%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Oct 22 '25 20:10 codecov[bot]

Hey @gauron99 can u have alook when u have some moments am I doing right ?

RayyanSeliya avatar Oct 24 '25 07:10 RayyanSeliya

same here as with my other comment on different PR. I think we could put the utils stuff inside cmd/deploy because its only used there.

WDYT @lkingland ?

gauron99 avatar Nov 04 '25 14:11 gauron99

Hey @gauron99 should I wait for luke and other member for opinion or should I implement as you have described ?

RayyanSeliya avatar Nov 05 '25 09:11 RayyanSeliya

same here some of the test are failing @lkingland @gauron99 dont know why !

RayyanSeliya avatar Nov 11 '25 08:11 RayyanSeliya

/override "On Cluster RT Test (ubuntu-latest, pack)" "E2E Test (ubuntu-latest, springboot)" These fails are due to custom pack builder issue with springboot /lgtm /approve

gauron99 avatar Nov 11 '25 09:11 gauron99

@gauron99: Overrode contexts on behalf of gauron99: E2E Test (ubuntu-latest, springboot), On Cluster RT Test (ubuntu-latest, pack)

In response to this:

/override "On Cluster RT Test (ubuntu-latest, pack)" "E2E Test (ubuntu-latest, springboot)" These fails are due to custom pack builder issue with springboot /lgtm /approve

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

knative-prow[bot] avatar Nov 11 '25 09:11 knative-prow[bot]

/lgtm /approve

gauron99 avatar Nov 13 '25 08:11 gauron99

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gauron99, lkingland, RayyanSeliya

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • ~~OWNERS~~ [gauron99,lkingland]

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

knative-prow[bot] avatar Nov 13 '25 08:11 knative-prow[bot]