Skip to content

fix: use user-defined NAMESPACE in script env#2653

Merged
eddycharly merged 1 commit into
kyverno:mainfrom
lzielezinska:fix-2643-namespace-env
Mar 26, 2026
Merged

fix: use user-defined NAMESPACE in script env#2653
eddycharly merged 1 commit into
kyverno:mainfrom
lzielezinska:fix-2643-namespace-env

Conversation

@lzielezinska

@lzielezinska lzielezinska commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Explanation

This PR fixes a bug where a user-defined NAMESPACE in a script or command env block was being silently overwritten by the internal ephemeral namespace.

After this change, if a user sets NAMESPACE, their value is respected. The default namespace is only used when NAMESPACE is not provided.

Related issue

Fixes #2643

Proposed Changes

  • Do not overwrite NAMESPACE if it is already set by the user
  • Only set the default ephemeral namespace when NAMESPACE is not defined
  • Keep behavior unchanged for users who do not define NAMESPACE

Checklist

@lzielezinska
lzielezinska requested a review from a team as a code owner March 25, 2026 16:16

@eddycharly eddycharly left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @lzielezinska !
Was nice to meet you at contribfest 🙏

@eddycharly eddycharly added this to the v0.2.15 milestone Mar 26, 2026
@eddycharly
eddycharly enabled auto-merge (squash) March 26, 2026 07:54
@codecov

codecov Bot commented Mar 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.99%. Comparing base (5f2001f) to head (aaeab6c).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
pkg/engine/operations/internal/env.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2653      +/-   ##
==========================================
- Coverage   67.00%   66.99%   -0.02%     
==========================================
  Files         149      149              
  Lines        5707     5708       +1     
==========================================
  Hits         3824     3824              
- Misses       1623     1624       +1     
  Partials      260      260              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@eddycharly
eddycharly disabled auto-merge March 26, 2026 08:14
@eddycharly
eddycharly merged commit 80fd94e into kyverno:main Mar 26, 2026
14 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] NAMESPACE silently overwritten in script operation

2 participants