Skip to content

Add namespace-admin support in E2E test framework and automate MTC-290 initContainer migration test#222

Merged
msajidmansoori12 merged 9 commits intomigtools:mainfrom
msajidmansoori12:add-ns-user
Apr 7, 2026
Merged

Add namespace-admin support in E2E test framework and automate MTC-290 initContainer migration test#222
msajidmansoori12 merged 9 commits intomigtools:mainfrom
msajidmansoori12:add-ns-user

Conversation

@msajidmansoori12
Copy link
Copy Markdown
Contributor

@msajidmansoori12 msajidmansoori12 commented Apr 1, 2026

Summary

This PR adds support for running Crane E2E scenarios with non-admin (namespace-admin) users and extends CI/workflows to pass non-admin contexts.
It also adds automated coverage for MTC-290 to validate migration of an app with an init container using namespace-admin permissions.

Changes Included

  • Added non-admin context flags to the E2E suite:
    • --source-nonadmin-context
    • --target-nonadmin-context
  • Extended scenario/framework plumbing to support non-admin runners for:
    • kubectl
    • k8sdeploy app handles
    • crane runner
  • Added namespace-admin RBAC helpers to:
    • resolve username from kube context
    • grant/revoke namespace-admin rolebinding
    • setup source/target non-admin users for a scenario
  • Added RoleBinding template:
    • e2e-tests/testdata/rolebinding_namespace_admin.yaml
  • Added non-admin apply path:
    • ApplyOutputToTargetNonAdmin(...) (apply without namespace creation)
  • Added new automated test:
    • e2e-tests/tests/mtc_290_initcontainer_test.go
    • validates initContainer presence in output deployment manifest
  • Updated workflows to create/use non-admin users and pass non-admin contexts:
    • .github/workflows/e2e-pr-tester.yaml
    • .github/workflows/run-e2e-tests.yml
  • Updated docs:
    • e2e-tests/README.md now reflects namespace-admin/non-admin support

Why

This improves E2E coverage to better match restricted real-world permission models, while still validating migration behavior end-to-end.

Follow-up (Optional)

In a follow-up PR, we can incrementally update more already-automated scenarios to also run under namespace-admin user contexts.

Signed-off-by: M Sajid Mansoori <mmansoor@redhat.com>
@msajidmansoori12 msajidmansoori12 self-assigned this Apr 1, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 1, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds tooling and CI to create Minikube client-cert users/contexts, wire new inputs through the composite action and setup script, and introduce RBAC e2e tests and a workflow that verifies authorization before and after applying namespace RoleBindings.

Changes

Cohort / File(s) Summary
Minikube user creation script
hack/minikube-create-user.sh
New executable Bash script: parses args, validates environment and CA files, generates RSA key/CSR, signs a client cert with the Minikube CA (openssl), writes artifacts, and updates kubeconfig via kubectl config set-credentials and kubectl config set-context.
Cluster setup script
hack/setup-minikube-same-network.sh
Added env-driven flags (CREATE_USERS, SRC_USER, TGT_USER, SRC_USER_CONTEXT, TGT_USER_CONTEXT, USER_ORG, USER_CERT_DAYS) and create_user_context() helper that invokes hack/minikube-create-user.sh to create user contexts conditionally.
Composite action inputs
.github/actions/setup-minikube-clusters/action.yml
Exposes new optional inputs for user creation and exports them as environment variables to action steps (CREATE_USERS, SRC_USER, TGT_USER, SRC_USER_CONTEXT, TGT_USER_CONTEXT, USER_ORG, USER_CERT_DAYS).
CI workflows
.github/workflows/test-minikube-user-rbac.yml, .github/workflows/e2e-pr-tester.yaml
New workflow test-minikube-user-rbac.yml to provision clusters with user creation and validate RBAC pre/post RoleBinding; updated e2e-pr-tester.yaml to enable user creation and pass non-admin context flags.
E2E config & flags
e2e-tests/config/config.go, e2e-tests/tests/e2e_suite_test.go
Added exported vars SourceNonAdminContext, TargetNonAdminContext and CLI flags -source-nonadmin-context, -target-nonadmin-context.
Kubectl helper & client
e2e-tests/framework/kubectl.go, e2e-tests/framework/client.go
Added KubectlRunner.CanI(...) to wrap kubectl auth can-i with exit-code semantics; added ResolveUsernameForContext(...) to extract the kubeconfig user for a context and extracted kubeconfig loading helper.
RBAC helpers, tests & data
e2e-tests/framework/rbac.go, e2e-tests/tests/mtc_rbac_ns_admin_test.go, e2e-tests/testdata/rolebinding_namespace_admin.yaml
Added RBAC helpers (GrantNamespaceAdminToUser, RevokeNamespaceAdminFromUser, SetupNamespaceAdminUser/cleanup), RoleBinding template, and a Ginkgo test validating pre/post RoleBinding permissions.
Scenario & pipeline adjustments
e2e-tests/framework/scenario.go, e2e-tests/framework/pipeline.go, e2e-tests/framework/crane.go
Added non-admin fields to MigrationScenario and constructed non-admin runners/apps; added ApplyOutputToTargetNonAdmin and refactored manifest-apply helper; removed TargetContext field from CraneRunner.

Sequence Diagram(s)

sequenceDiagram
    participant GH as "GitHub Actions"
    participant Action as "setup-minikube-clusters\n(composite action)"
    participant Setup as "setup-minikube-same-network.sh"
    participant Minikube as "Minikube profiles"
    participant Script as "minikube-create-user.sh"
    participant OpenSSL as "openssl"
    participant Kubectl as "kubectl / kubeconfig"

    GH->>Action: workflow triggers (create_users=true, src/tgt user)
    Action->>Setup: invoke setup script with env vars
    Setup->>Minikube: provision src & tgt clusters/profiles
    Setup->>Script: create_user_context(profile,user,context)
    Script->>Minikube: read CA cert/key for profile
    Script->>OpenSSL: generate key/CSR and sign client cert
    OpenSSL-->>Script: return key/cert
    Script->>Kubectl: set-credentials (embed certs)
    Script->>Kubectl: set-context (new user context)
    GH->>Kubectl: run auth can-i (pre-binding)
    GH->>Kubectl: apply RoleBinding
    GH->>Kubectl: run auth can-i (post-binding)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • stillalearner
  • aufi
  • midays

Poem

🐇 I hop between contexts in the night,
I forge a key and sign it just right.
I bind a role, then watch permissions flow,
Two clusters hum where once they were low. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 64.71% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title broadly describes adding namespace-admin support and automating a test, which aligns with the changeset's introduction of user creation and RBAC framework capabilities.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (3)
hack/minikube-create-user.sh (3)

138-146: Suppressing stderr hides useful diagnostic information on failure.

If openssl commands fail, set -e will exit the script but with no indication of what went wrong. Consider showing errors or adding explicit error handling.

🔧 Proposed improvement
-openssl genrsa -out "$USER_KEY" 2048 >/dev/null 2>&1
+if ! openssl genrsa -out "$USER_KEY" 2048 2>&1; then
+  printf 'Error: failed to generate private key\n' >&2
+  exit 1
+fi

Apply similar pattern to other openssl commands, or at minimum redirect only stdout while preserving stderr:

-openssl genrsa -out "$USER_KEY" 2048 >/dev/null 2>&1
+openssl genrsa -out "$USER_KEY" 2048 >/dev/null
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@hack/minikube-create-user.sh` around lines 138 - 146, The openssl commands
(openssl genrsa, openssl req, openssl x509) are redirecting both stdout and
stderr to /dev/null which hides useful diagnostics; change them to only silence
stdout (redirect only > /dev/null) or add explicit error handling: run each
command for USER_KEY, USER_CSR and USER_CRT, check its exit status ($?), and on
failure write a clear error message including the failing command and relevant
variables (USER_NAME, ORG_NAME, CA_CERT, CA_KEY, DAYS) to stderr and exit
non‑zero so failures are visible instead of silently swallowed.

154-161: Consider warning if user or context already exists in kubeconfig.

If credentials for $USER_NAME or context $CONTEXT_NAME already exist, they will be silently overwritten. This may be intentional for idempotency, but a warning could prevent accidental data loss.

💡 Optional: Add overwrite warning
+if kubectl config get-contexts "$CONTEXT_NAME" >/dev/null 2>&1; then
+  printf 'Warning: context "%s" already exists and will be overwritten\n' "$CONTEXT_NAME" >&2
+fi
+
 kubectl config set-credentials "$USER_NAME" \
   --client-certificate="$USER_CRT" \
   --client-key="$USER_KEY" \
   --embed-certs=true >/dev/null
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@hack/minikube-create-user.sh` around lines 154 - 161, The script currently
unconditionally calls "kubectl config set-credentials" for "$USER_NAME" and
"kubectl config set-context" for "$CONTEXT_NAME", which will silently overwrite
existing entries; add a pre-check that queries the kubeconfig for existing
credentials and contexts (e.g., via "kubectl config get-users" and "kubectl
config get-contexts" or suitable kubectl config view jsonpath), and if
"$USER_NAME" or "$CONTEXT_NAME" is found emit a clear warning to stdout/stderr
before proceeding (optionally prompt or require a FORCE/OVERWRITE env var to
continue); update the block around the kubectl calls so it warns when an
existing user/context is detected and only proceeds to run "kubectl config
set-credentials" / "kubectl config set-context" after the warning/confirmation.

56-59: Missing argument value causes silent misbehavior or cryptic error.

If a flag like --profile is passed without a value (e.g., --profile --user dev), PROFILE silently gets set to --user. If it's the last argument, shift 2 fails with an unhelpful error.

🛡️ Proposed fix to validate argument values
     --profile)
+      if [[ -z "${2:-}" || "${2:-}" == --* ]]; then
+        printf 'Error: --profile requires a value\n' >&2
+        exit 1
+      fi
       PROFILE="${2:-}"
       shift 2
       ;;

Apply the same pattern to --user, --context, --org, --days, and --output-dir.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@hack/minikube-create-user.sh` around lines 56 - 59, The flag parsing for
--profile currently assigns the next positional argument to PROFILE without
validation, causing silent misassignment or shift errors; update the parsing
logic in the argument-handling case blocks (the --profile branch and similarly
for --user, --context, --org, --days, --output-dir) to first check that the next
argument exists and does not begin with "-" (i.e., is not another flag), and if
it is missing or is another flag, emit a clear error and exit; otherwise assign
the value to the respective variable (e.g., PROFILE, USER, CONTEXT, ORG, DAYS,
OUTPUT_DIR) and then shift 2 as before.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@hack/minikube-create-user.sh`:
- Around line 102-105: The validation for DAYS currently accepts "0" (using
regex ^[0-9]+$) which would produce an immediately expired cert; update the
check in the DAYS validation block to require a positive integer > 0 (e.g.,
change the regex to ^[1-9][0-9]*$ or test numerically with an integer parse and
a DAYS -gt 0 check) and ensure the error message still reads something like
"--days must be a positive integer" when the validation fails; locate the check
using the DAYS variable and the if ! [[ "$DAYS" =~ ... ]] conditional to make
this change.
- Line 138: The private key created by the openssl genrsa command (openssl
genrsa -out "$USER_KEY" 2048) may inherit a permissive umask; restrict file
access by either setting umask 077 immediately before the key generation or by
applying chmod 600 "$USER_KEY" right after the openssl command and checking for
errors; ensure you reference the USER_KEY variable and preserve any existing
error handling around openssl.

---

Nitpick comments:
In `@hack/minikube-create-user.sh`:
- Around line 138-146: The openssl commands (openssl genrsa, openssl req,
openssl x509) are redirecting both stdout and stderr to /dev/null which hides
useful diagnostics; change them to only silence stdout (redirect only >
/dev/null) or add explicit error handling: run each command for USER_KEY,
USER_CSR and USER_CRT, check its exit status ($?), and on failure write a clear
error message including the failing command and relevant variables (USER_NAME,
ORG_NAME, CA_CERT, CA_KEY, DAYS) to stderr and exit non‑zero so failures are
visible instead of silently swallowed.
- Around line 154-161: The script currently unconditionally calls "kubectl
config set-credentials" for "$USER_NAME" and "kubectl config set-context" for
"$CONTEXT_NAME", which will silently overwrite existing entries; add a pre-check
that queries the kubeconfig for existing credentials and contexts (e.g., via
"kubectl config get-users" and "kubectl config get-contexts" or suitable kubectl
config view jsonpath), and if "$USER_NAME" or "$CONTEXT_NAME" is found emit a
clear warning to stdout/stderr before proceeding (optionally prompt or require a
FORCE/OVERWRITE env var to continue); update the block around the kubectl calls
so it warns when an existing user/context is detected and only proceeds to run
"kubectl config set-credentials" / "kubectl config set-context" after the
warning/confirmation.
- Around line 56-59: The flag parsing for --profile currently assigns the next
positional argument to PROFILE without validation, causing silent misassignment
or shift errors; update the parsing logic in the argument-handling case blocks
(the --profile branch and similarly for --user, --context, --org, --days,
--output-dir) to first check that the next argument exists and does not begin
with "-" (i.e., is not another flag), and if it is missing or is another flag,
emit a clear error and exit; otherwise assign the value to the respective
variable (e.g., PROFILE, USER, CONTEXT, ORG, DAYS, OUTPUT_DIR) and then shift 2
as before.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6d79ea81-86b7-4c8a-bd2c-3522490ef78e

📥 Commits

Reviewing files that changed from the base of the PR and between 6e9b9fe and 2a8a1ba.

📒 Files selected for processing (1)
  • hack/minikube-create-user.sh

Comment thread hack/minikube-create-user.sh
Comment thread hack/minikube-create-user.sh
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/test-minikube-user-rbac.yml (1)

45-55: Don't blanket-ignore RoleBinding creation errors.

These clusters are recreated for each run, so AlreadyExists should not be the normal path here. || true will also swallow real API/auth failures and make the post-check harder to diagnose. Prefer an idempotent apply flow, or only ignore the specific AlreadyExists case.

🔧 Safer idempotent pattern
-          kubectl --context src create rolebinding sajid-admin \
-            --clusterrole=admin \
-            --user=sajid \
-            --namespace=default || true
+          kubectl --context src create rolebinding sajid-admin \
+            --clusterrole=admin \
+            --user=sajid \
+            --namespace=default \
+            --dry-run=client -o yaml | kubectl --context src apply -f -

-          kubectl --context tgt create rolebinding sajid-admin \
-            --clusterrole=admin \
-            --user=sajid \
-            --namespace=default || true
+          kubectl --context tgt create rolebinding sajid-admin \
+            --clusterrole=admin \
+            --user=sajid \
+            --namespace=default \
+            --dry-run=client -o yaml | kubectl --context tgt apply -f -
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/test-minikube-user-rbac.yml around lines 45 - 55, The
current kubectl create rolebinding commands for sajid-admin (contexts src and
tgt, namespace default) use "|| true" which silences all failures; change to an
idempotent approach: either switch to kubectl apply with a RoleBinding manifest
or perform a create and explicitly handle the AlreadyExists case by checking for
that specific error (or testing for existence with kubectl get rolebinding
sajid-admin --namespace=default) and only ignore that condition while letting
other API/auth errors surface; remove the blanket "|| true" so real failures are
not swallowed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@hack/setup-minikube-same-network.sh`:
- Around line 46-52: The kubeconfig credentials are being keyed by raw username
(USER_NAME) so calling create_user_context twice with the same SRC_USER/TGT_USER
("dev") causes the second set-credentials call to overwrite the first; change
the kubectl config set-credentials invocation in create_user_context to use the
context identifier (CONTEXT_NAME) instead of USER_NAME so credentials are stored
under distinct keys (e.g., src-dev and tgt-dev) and no longer collide when
SRC_USER and TGT_USER default to the same value.

---

Nitpick comments:
In @.github/workflows/test-minikube-user-rbac.yml:
- Around line 45-55: The current kubectl create rolebinding commands for
sajid-admin (contexts src and tgt, namespace default) use "|| true" which
silences all failures; change to an idempotent approach: either switch to
kubectl apply with a RoleBinding manifest or perform a create and explicitly
handle the AlreadyExists case by checking for that specific error (or testing
for existence with kubectl get rolebinding sajid-admin --namespace=default) and
only ignore that condition while letting other API/auth errors surface; remove
the blanket "|| true" so real failures are not swallowed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 874b831a-e8ff-4a60-ad70-8286b5dfbbf4

📥 Commits

Reviewing files that changed from the base of the PR and between 2a8a1ba and 5402ada.

📒 Files selected for processing (3)
  • .github/actions/setup-minikube-clusters/action.yml
  • .github/workflows/test-minikube-user-rbac.yml
  • hack/setup-minikube-same-network.sh

Comment thread hack/setup-minikube-same-network.sh
Signed-off-by: M Sajid Mansoori <mmansoor@redhat.com>
@msajidmansoori12 msajidmansoori12 marked this pull request as draft April 1, 2026 12:54
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
hack/setup-minikube-same-network.sh (1)

55-55: Redundant set -x statement.

This duplicates line 3. Consider removing it for cleaner code.

♻️ Proposed fix
 USER_CERT_DAYS="${USER_CERT_DAYS:-365}"
 RESET_PROFILES="${RESET_PROFILES:-true}"
 RECREATE_NETWORK="${RECREATE_NETWORK:-true}"
-set -x
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@hack/setup-minikube-same-network.sh` at line 55, Remove the redundant shell
debug flag: delete the duplicate "set -x" statement (the one repeated later in
the script) so only the initial "set -x" remains; locate the second occurrence
of "set -x" in the hack/setup-minikube-same-network.sh script and remove that
line to avoid duplicate debugging toggles.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@hack/setup-minikube-same-network.sh`:
- Line 55: Remove the redundant shell debug flag: delete the duplicate "set -x"
statement (the one repeated later in the script) so only the initial "set -x"
remains; locate the second occurrence of "set -x" in the
hack/setup-minikube-same-network.sh script and remove that line to avoid
duplicate debugging toggles.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d8a9408e-5832-434b-a8fc-f69831ac440a

📥 Commits

Reviewing files that changed from the base of the PR and between 5402ada and 8aa59c6.

📒 Files selected for processing (3)
  • .github/actions/setup-minikube-clusters/action.yml
  • .github/workflows/test-minikube-user-rbac.yml
  • hack/setup-minikube-same-network.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/test-minikube-user-rbac.yml

…t framework

Signed-off-by: M Sajid Mansoori <mmansoor@redhat.com>
Signed-off-by: M Sajid Mansoori <mmansoor@redhat.com>
@msajidmansoori12 msajidmansoori12 marked this pull request as ready for review April 2, 2026 07:52
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
e2e-tests/framework/client.go (1)

90-117: Consider deduplicating kubeconfig loading logic.

Line 90–117 repeats the loading/env handling pattern already present in NewClientSetForContext (Line 38–46). A small shared helper would reduce drift risk and keep error handling consistent across framework clients.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@e2e-tests/framework/client.go` around lines 90 - 117, The kubeconfig loading
and env handling in ResolveUsernameForContext is duplicated from
NewClientSetForContext; extract that logic into a shared helper (e.g.,
LoadRawKubeConfig or ResolveRawKubeConfig) and have both
ResolveUsernameForContext and NewClientSetForContext call it. The helper should
read KUBECONFIG env, set loadingRules.ExplicitPath when present, call
loadingRules.Load(), and return the rawConfig or wrapped error so both functions
reuse identical error handling and avoid drift.
.github/workflows/test-minikube-user-rbac.yml (1)

53-61: Avoid suppressing all rolebinding creation errors with || true.

At Line 53–61, blanket suppression hides real failures (RBAC API errors, context issues) and makes root-cause diagnosis harder. Prefer idempotent apply behavior instead.

Suggested change
-          kubectl --context src create rolebinding dev-admin \
-            --clusterrole=admin \
-            --user=dev \
-            --namespace=default || true
+          kubectl --context src create rolebinding dev-admin \
+            --clusterrole=admin \
+            --user=dev \
+            --namespace=default \
+            --dry-run=client -o yaml | kubectl --context src apply -f -

-          kubectl --context tgt create rolebinding dev-admin \
-            --clusterrole=admin \
-            --user=dev \
-            --namespace=default || true
+          kubectl --context tgt create rolebinding dev-admin \
+            --clusterrole=admin \
+            --user=dev \
+            --namespace=default \
+            --dry-run=client -o yaml | kubectl --context tgt apply -f -
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/test-minikube-user-rbac.yml around lines 53 - 61, Remove
the blanket "|| true" suppression and make the rolebinding creation idempotent:
instead of the two lines that run "kubectl --context <ctx> create rolebinding
dev-admin --clusterrole=admin --user=dev --namespace=default || true" (for
contexts "src" and "tgt"), generate the RoleBinding YAML via "kubectl create
rolebinding ... --dry-run=client -o yaml" and pipe it to "kubectl apply -f -"
(or apply a static manifest), and remove the "|| true" so failures surface;
update both the "kubectl --context src ..." and "kubectl --context tgt ..."
invocations accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/test-minikube-user-rbac.yml:
- Around line 45-46: Update the two echo log lines that currently print
"src-sajid" and "tgt-sajid" to reflect the actual user names used by the
workflow (src-dev and tgt-dev); locate the echo statements (the lines that
output "${SRC_CAN_I} (rc=${SRC_ALLOWED_RC})" and "${TGT_CAN_I}
(rc=${TGT_ALLOWED_RC})") and change their static labels from "src-sajid" →
"src-dev" and "tgt-sajid" → "tgt-dev" so CI logs accurately represent the
provisioned users.

In `@e2e-tests/framework/rbac.go`:
- Around line 77-80: In SetupNamespaceAdminUser, the returned KubectlRunner is
hardcoded to Bin: "kubectl" which ignores the validated adminKubectl.Bin and can
break subsequent CanI calls; update the construction of userKubectl to use
adminKubectl.Bin (i.e., set Bin to adminKubectl.Bin) so the runner uses the same
kubectl binary/path validated earlier (ensure you update the KubectlRunner
instance referenced by userKubectl in that function).

In `@e2e-tests/tests/mtc_rbac_ns_admin_test.go`:
- Around line 14-17: The test sets adminContext := config.SourceContext but does
not validate it, which can cause commands to run in an unintended kube context;
add an explicit guard similar to the existing nonadminContext check by asserting
adminContext (or config.SourceContext) is not empty before using it to build the
admin runner (the symbol adminContext and config.SourceContext should be
validated), and update any code that constructs the admin runner to rely on the
validated adminContext.

---

Nitpick comments:
In @.github/workflows/test-minikube-user-rbac.yml:
- Around line 53-61: Remove the blanket "|| true" suppression and make the
rolebinding creation idempotent: instead of the two lines that run "kubectl
--context <ctx> create rolebinding dev-admin --clusterrole=admin --user=dev
--namespace=default || true" (for contexts "src" and "tgt"), generate the
RoleBinding YAML via "kubectl create rolebinding ... --dry-run=client -o yaml"
and pipe it to "kubectl apply -f -" (or apply a static manifest), and remove the
"|| true" so failures surface; update both the "kubectl --context src ..." and
"kubectl --context tgt ..." invocations accordingly.

In `@e2e-tests/framework/client.go`:
- Around line 90-117: The kubeconfig loading and env handling in
ResolveUsernameForContext is duplicated from NewClientSetForContext; extract
that logic into a shared helper (e.g., LoadRawKubeConfig or
ResolveRawKubeConfig) and have both ResolveUsernameForContext and
NewClientSetForContext call it. The helper should read KUBECONFIG env, set
loadingRules.ExplicitPath when present, call loadingRules.Load(), and return the
rawConfig or wrapped error so both functions reuse identical error handling and
avoid drift.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2c9174b8-30ce-4dba-b10d-149614c8aa3c

📥 Commits

Reviewing files that changed from the base of the PR and between 8aa59c6 and dc709cc.

📒 Files selected for processing (10)
  • .github/workflows/e2e-pr-tester.yaml
  • .github/workflows/test-minikube-user-rbac.yml
  • e2e-tests/config/config.go
  • e2e-tests/framework/client.go
  • e2e-tests/framework/kubectl.go
  • e2e-tests/framework/rbac.go
  • e2e-tests/testdata/rolebinding_namespace_admin.yaml
  • e2e-tests/tests/e2e_suite_test.go
  • e2e-tests/tests/mtc_rbac_ns_admin_test.go
  • hack/minikube-create-user.sh
✅ Files skipped from review due to trivial changes (1)
  • e2e-tests/testdata/rolebinding_namespace_admin.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • hack/minikube-create-user.sh

Comment thread .github/workflows/test-minikube-user-rbac.yml Outdated
Comment thread e2e-tests/framework/rbac.go
Comment thread e2e-tests/tests/mtc_rbac_ns_admin_test.go Outdated
Signed-off-by: M Sajid Mansoori <mmansoor@redhat.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 6, 2026

Test Coverage Report

Total: 8.0%

Per-package coverage

  • github.com/konveyor/crane — 0.0%
  • github.com/konveyor/crane/cmd/apply — 0.0%
  • github.com/konveyor/crane/cmd/convert — 0.0%
  • github.com/konveyor/crane/cmd/export — 29.0%
  • github.com/konveyor/crane/cmd/plugin-manager — 0.0%
  • github.com/konveyor/crane/cmd/plugin-manager/add — 0.0%
  • github.com/konveyor/crane/cmd/plugin-manager/list — 0.0%
  • github.com/konveyor/crane/cmd/plugin-manager/remove — 0.0%
  • github.com/konveyor/crane/cmd/runfn — 0.0%
  • github.com/konveyor/crane/cmd/skopeo-sync-gen — 0.0%
  • github.com/konveyor/crane/cmd/transfer-pvc — 9.2%
  • github.com/konveyor/crane/cmd/transform — 0.0%
  • github.com/konveyor/crane/cmd/transform/listplugins — 0.0%
  • github.com/konveyor/crane/cmd/transform/optionals — 0.0%
  • github.com/konveyor/crane/cmd/tunnel-api — 0.0%
  • github.com/konveyor/crane/cmd/version — 0.0%
  • github.com/konveyor/crane/e2e-tests/framework — 0.0%
  • github.com/konveyor/crane/e2e-tests/utils — 0.0%
  • github.com/konveyor/crane/internal/file — 55.6%
  • github.com/konveyor/crane/internal/flags — 0.0%
  • github.com/konveyor/crane/internal/plugin — 32.9%
Full function-level details
github.com/konveyor/crane/cmd/apply/apply.go:36:			Complete				0.0%
github.com/konveyor/crane/cmd/apply/apply.go:41:			Validate				0.0%
github.com/konveyor/crane/cmd/apply/apply.go:46:			Run					0.0%
github.com/konveyor/crane/cmd/apply/apply.go:50:			NewApplyCommand				0.0%
github.com/konveyor/crane/cmd/apply/apply.go:82:			addFlagsForOptions			0.0%
github.com/konveyor/crane/cmd/apply/apply.go:88:			run					0.0%
github.com/konveyor/crane/cmd/convert/convert.go:30:			NewConvertOptions			0.0%
github.com/konveyor/crane/cmd/convert/convert.go:63:			addFlagsForConvertOptions		0.0%
github.com/konveyor/crane/cmd/convert/convert.go:74:			Complete				0.0%
github.com/konveyor/crane/cmd/convert/convert.go:83:			Run					0.0%
github.com/konveyor/crane/cmd/convert/convert.go:87:			run					0.0%
github.com/konveyor/crane/cmd/convert/convert.go:112:			getClientFromContext			0.0%
github.com/konveyor/crane/cmd/convert/convert.go:134:			getRestConfigFromContext		0.0%
github.com/konveyor/crane/cmd/export/cluster.go:29:			NewClusterScopeHandler			0.0%
github.com/konveyor/crane/cmd/export/cluster.go:35:			isClusterScopedResource			0.0%
github.com/konveyor/crane/cmd/export/cluster.go:44:			filterRbacResources			0.0%
github.com/konveyor/crane/cmd/export/cluster.go:102:			NewClusterScopedRbacHandler		100.0%
github.com/konveyor/crane/cmd/export/cluster.go:113:			exportedSANamespaces			100.0%
github.com/konveyor/crane/cmd/export/cluster.go:126:			groupMatchesExportedSANamespaces	100.0%
github.com/konveyor/crane/cmd/export/cluster.go:143:			parseServiceAccountUserSubject		100.0%
github.com/konveyor/crane/cmd/export/cluster.go:154:			prepareForFiltering			0.0%
github.com/konveyor/crane/cmd/export/cluster.go:187:			filteredResourcesOfKind			0.0%
github.com/konveyor/crane/cmd/export/cluster.go:213:			accept					0.0%
github.com/konveyor/crane/cmd/export/cluster.go:223:			acceptClusterRoleBinding		90.5%
github.com/konveyor/crane/cmd/export/cluster.go:260:			acceptClusterRole			0.0%
github.com/konveyor/crane/cmd/export/cluster.go:284:			acceptSecurityContextConstraints	39.3%
github.com/konveyor/crane/cmd/export/cluster.go:336:			anyServiceAccountInNamespace		80.0%
github.com/konveyor/crane/cmd/export/crd.go:17:				normalizeGroupSet			85.7%
github.com/konveyor/crane/cmd/export/crd.go:29:				shouldSkipCRDGroup			100.0%
github.com/konveyor/crane/cmd/export/crd.go:50:				crdFailureAPIResourceName		100.0%
github.com/konveyor/crane/cmd/export/crd.go:58:				collectRelatedCRDs			89.7%
github.com/konveyor/crane/cmd/export/discover.go:39:			hasClusterScopedManifests		0.0%
github.com/konveyor/crane/cmd/export/discover.go:57:			prepareClusterResourceDir		0.0%
github.com/konveyor/crane/cmd/export/discover.go:73:			prepareFailuresDir			0.0%
github.com/konveyor/crane/cmd/export/discover.go:85:			writeResources				0.0%
github.com/konveyor/crane/cmd/export/discover.go:133:			writeErrors				0.0%
github.com/konveyor/crane/cmd/export/discover.go:174:			getFilePath				0.0%
github.com/konveyor/crane/cmd/export/discover.go:185:			discoverPreferredResources		0.0%
github.com/konveyor/crane/cmd/export/discover.go:214:			resourceToExtract			0.0%
github.com/konveyor/crane/cmd/export/discover.go:283:			isAdmittedResource			0.0%
github.com/konveyor/crane/cmd/export/discover.go:292:			getObjects				0.0%
github.com/konveyor/crane/cmd/export/discover.go:326:			iterateItemsByGet			0.0%
github.com/konveyor/crane/cmd/export/discover.go:349:			iterateItemsInList			0.0%
github.com/konveyor/crane/cmd/export/export.go:46:			Complete				0.0%
github.com/konveyor/crane/cmd/export/export.go:75:			Validate				0.0%
github.com/konveyor/crane/cmd/export/export.go:84:			Run					0.0%
github.com/konveyor/crane/cmd/export/export.go:173:			NewExportCommand			0.0%
github.com/konveyor/crane/cmd/plugin-manager/add/add.go:42:		Complete				0.0%
github.com/konveyor/crane/cmd/plugin-manager/add/add.go:47:		Validate				0.0%
github.com/konveyor/crane/cmd/plugin-manager/add/add.go:90:		Run					0.0%
github.com/konveyor/crane/cmd/plugin-manager/add/add.go:94:		NewAddCommand				0.0%
github.com/konveyor/crane/cmd/plugin-manager/add/add.go:126:		addFlagsForOptions			0.0%
github.com/konveyor/crane/cmd/plugin-manager/add/add.go:131:		run					0.0%
github.com/konveyor/crane/cmd/plugin-manager/add/add.go:195:		downloadBinary				0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:46:		Complete				0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:51:		Validate				0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:56:		Run					0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:60:		NewListCommand				0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:90:		addFlagsForOptions			0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:98:		run					0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:167:		printInstalledInformation		0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:177:		groupInformationForPlugins		0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:196:		printInformation			0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:208:		printParamsInformation			0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:222:		getOptionalFields			0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:247:		printTable				0.0%
github.com/konveyor/crane/cmd/plugin-manager/plugin-manager.go:33:	Complete				0.0%
github.com/konveyor/crane/cmd/plugin-manager/plugin-manager.go:38:	Validate				0.0%
github.com/konveyor/crane/cmd/plugin-manager/plugin-manager.go:43:	Run					0.0%
github.com/konveyor/crane/cmd/plugin-manager/plugin-manager.go:47:	NewPluginManagerCommand			0.0%
github.com/konveyor/crane/cmd/plugin-manager/plugin-manager.go:78:	addFlagsForOptions			0.0%
github.com/konveyor/crane/cmd/plugin-manager/plugin-manager.go:86:	run					0.0%
github.com/konveyor/crane/cmd/plugin-manager/remove/remove.go:33:	Complete				0.0%
github.com/konveyor/crane/cmd/plugin-manager/remove/remove.go:38:	Validate				0.0%
github.com/konveyor/crane/cmd/plugin-manager/remove/remove.go:43:	Run					0.0%
github.com/konveyor/crane/cmd/plugin-manager/remove/remove.go:47:	NewRemoveCommand			0.0%
github.com/konveyor/crane/cmd/plugin-manager/remove/remove.go:77:	run					0.0%
github.com/konveyor/crane/cmd/runfn/runfn.go:33:			NewFnRunCommand				0.0%
github.com/konveyor/crane/cmd/runfn/runfn.go:49:			addFlagsForOptions			0.0%
github.com/konveyor/crane/cmd/runfn/runfn.go:59:			runE					0.0%
github.com/konveyor/crane/cmd/runfn/runfn.go:70:			preRunE					0.0%
github.com/konveyor/crane/cmd/runfn/runfn.go:112:			getFunctionImage			0.0%
github.com/konveyor/crane/cmd/runfn/runfn.go:124:			getContainerFunctions			0.0%
github.com/konveyor/crane/cmd/runfn/runfn.go:151:			getFunctionAnnotation			0.0%
github.com/konveyor/crane/cmd/runfn/runfn.go:170:			getFunctionConfig			0.0%
github.com/konveyor/crane/cmd/runfn/util.go:14:				WriteOutput				0.0%
github.com/konveyor/crane/cmd/runfn/util.go:31:				GetDestinationDir			0.0%
github.com/konveyor/crane/cmd/runfn/util.go:58:				ValidateFunctionImageURL		0.0%
github.com/konveyor/crane/cmd/runfn/util.go:80:				checkIfDirExists			0.0%
github.com/konveyor/crane/cmd/skopeo-sync-gen/skopeo-sync-gen.go:61:	Complete				0.0%
github.com/konveyor/crane/cmd/skopeo-sync-gen/skopeo-sync-gen.go:65:	Validate				0.0%
github.com/konveyor/crane/cmd/skopeo-sync-gen/skopeo-sync-gen.go:69:	NewSkopeoSyncGenCommand			0.0%
github.com/konveyor/crane/cmd/skopeo-sync-gen/skopeo-sync-gen.go:103:	shouldAddImageStream			0.0%
github.com/konveyor/crane/cmd/skopeo-sync-gen/skopeo-sync-gen.go:114:	Run					0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:37:		NewRsyncLogStream			0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:50:		Init					0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:138:		writeProgressToFile			0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:148:		Close					0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:154:		Streams					0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:190:		addDataSize				0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:215:		String					100.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:219:		MarshalJSON				0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:223:		AsString				0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:271:		NewProgress				100.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:291:		Completed				0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:296:		Status					38.5%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:321:		Merge					0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:376:		newDataSize				72.7%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:399:		parseRsyncLogs				76.1%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:479:		waitForPodRunning			0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:513:		getFinalPodStatus			0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:89:		Validate				0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:117:		Validate				0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:133:		NewTransferPVCCommand			0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:169:		addFlagsToTransferPVCCommand		0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:189:		Complete				0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:220:		Validate				0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:246:		Run					0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:250:		getClientFromContext			0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:271:		getRestConfigFromContext		0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:278:		run					0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:485:		getValidatedResourceName		0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:495:		getNodeNameForPVC			0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:515:		getIDsForNamespace			0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:541:		getRsyncClientPodSecurityContext	0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:553:		getRsyncServerPodSecurityContext	0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:565:		garbageCollect				0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:602:		deleteResourcesIteratively		0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:628:		deleteResourcesForGVK			0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:649:		followClientLogs			0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:678:		waitForEndpoint				0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:690:		createEndpoint				0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:735:		getRouteHostName			0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:752:		buildDestinationPVC			0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:773:		ApplyTo					0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:793:		ApplyTo					0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:805:		ApplyTo					0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:821:		String					0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:825:		Set					0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:835:		Type					0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:841:		parseSourceDestinationMapping		100.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:863:		String					0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:867:		Set					0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:876:		Type					0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:880:		String					0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:884:		Set					0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:894:		Type					0.0%
github.com/konveyor/crane/cmd/transform/listplugins/listplugins.go:31:	Complete				0.0%
github.com/konveyor/crane/cmd/transform/listplugins/listplugins.go:36:	Validate				0.0%
github.com/konveyor/crane/cmd/transform/listplugins/listplugins.go:41:	Run					0.0%
github.com/konveyor/crane/cmd/transform/listplugins/listplugins.go:45:	NewListPluginsCommand			0.0%
github.com/konveyor/crane/cmd/transform/listplugins/listplugins.go:77:	run					0.0%
github.com/konveyor/crane/cmd/transform/optionals/optionals.go:31:	Complete				0.0%
github.com/konveyor/crane/cmd/transform/optionals/optionals.go:36:	Validate				0.0%
github.com/konveyor/crane/cmd/transform/optionals/optionals.go:41:	Run					0.0%
github.com/konveyor/crane/cmd/transform/optionals/optionals.go:45:	NewOptionalsCommand			0.0%
github.com/konveyor/crane/cmd/transform/optionals/optionals.go:77:	run					0.0%
github.com/konveyor/crane/cmd/transform/transform.go:43:		Complete				0.0%
github.com/konveyor/crane/cmd/transform/transform.go:48:		Validate				0.0%
github.com/konveyor/crane/cmd/transform/transform.go:53:		Run					0.0%
github.com/konveyor/crane/cmd/transform/transform.go:57:		NewTransformCommand			0.0%
github.com/konveyor/crane/cmd/transform/transform.go:91:		addFlagsForOptions			0.0%
github.com/konveyor/crane/cmd/transform/transform.go:105:		run					0.0%
github.com/konveyor/crane/cmd/transform/transform.go:237:		getPluginPrioritiesMap			0.0%
github.com/konveyor/crane/cmd/transform/transform.go:249:		optionalFlagsToLower			0.0%
github.com/konveyor/crane/cmd/tunnel-api/tunnel-api.go:35:		NewTunnelAPIOptions			0.0%
github.com/konveyor/crane/cmd/tunnel-api/tunnel-api.go:65:		addFlagsForTunnelAPIOptions		0.0%
github.com/konveyor/crane/cmd/tunnel-api/tunnel-api.go:77:		Complete				0.0%
github.com/konveyor/crane/cmd/tunnel-api/tunnel-api.go:100:		Validate				0.0%
github.com/konveyor/crane/cmd/tunnel-api/tunnel-api.go:116:		Run					0.0%
github.com/konveyor/crane/cmd/tunnel-api/tunnel-api.go:120:		getClientFromContext			0.0%
github.com/konveyor/crane/cmd/tunnel-api/tunnel-api.go:129:		getRestConfigFromContext		0.0%
github.com/konveyor/crane/cmd/tunnel-api/tunnel-api.go:136:		run					0.0%
github.com/konveyor/crane/cmd/version/version.go:20:			Complete				0.0%
github.com/konveyor/crane/cmd/version/version.go:25:			Validate				0.0%
github.com/konveyor/crane/cmd/version/version.go:30:			Run					0.0%
github.com/konveyor/crane/cmd/version/version.go:34:			NewVersionCommand			0.0%
github.com/konveyor/crane/cmd/version/version.go:60:			run					0.0%
github.com/konveyor/crane/e2e-tests/framework/app.go:27:		Deploy					0.0%
github.com/konveyor/crane/e2e-tests/framework/app.go:49:		Validate				0.0%
github.com/konveyor/crane/e2e-tests/framework/app.go:71:		Cleanup					0.0%
github.com/konveyor/crane/e2e-tests/framework/app.go:93:		buildCommand				0.0%
github.com/konveyor/crane/e2e-tests/framework/app.go:100:		envWithBinDir				0.0%
github.com/konveyor/crane/e2e-tests/framework/app.go:116:		withExtraVars				0.0%
github.com/konveyor/crane/e2e-tests/framework/client.go:14:		ListPVCs				0.0%
github.com/konveyor/crane/e2e-tests/framework/client.go:36:		NewClientSetForContext			0.0%
github.com/konveyor/crane/e2e-tests/framework/client.go:57:		GetClusterNodeIP			0.0%
github.com/konveyor/crane/e2e-tests/framework/client.go:85:		ResolveUsernameForContext		0.0%
github.com/konveyor/crane/e2e-tests/framework/crane.go:26:		Export					0.0%
github.com/konveyor/crane/e2e-tests/framework/crane.go:40:		Transform				0.0%
github.com/konveyor/crane/e2e-tests/framework/crane.go:54:		Apply					0.0%
github.com/konveyor/crane/e2e-tests/framework/crane.go:68:		TransferPVC				0.0%
github.com/konveyor/crane/e2e-tests/framework/kubectl.go:19:		Run					0.0%
github.com/konveyor/crane/e2e-tests/framework/kubectl.go:25:		RunWithStdin				0.0%
github.com/konveyor/crane/e2e-tests/framework/kubectl.go:30:		executeWithStdin			0.0%
github.com/konveyor/crane/e2e-tests/framework/kubectl.go:51:		normalizeKubectlArgs			0.0%
github.com/konveyor/crane/e2e-tests/framework/kubectl.go:59:		CreateNamespace				0.0%
github.com/konveyor/crane/e2e-tests/framework/kubectl.go:78:		ApplyDir				0.0%
github.com/konveyor/crane/e2e-tests/framework/kubectl.go:94:		ApplyYAMLSpec				0.0%
github.com/konveyor/crane/e2e-tests/framework/kubectl.go:103:		ValidateApplyDir			0.0%
github.com/konveyor/crane/e2e-tests/framework/kubectl.go:119:		ScaleDeployment				0.0%
github.com/konveyor/crane/e2e-tests/framework/kubectl.go:177:		ScaleDeploymentIfPresent		0.0%
github.com/konveyor/crane/e2e-tests/framework/kubectl.go:198:		CanI					0.0%
github.com/konveyor/crane/e2e-tests/framework/logging.go:11:		logVerboseCommand			0.0%
github.com/konveyor/crane/e2e-tests/framework/logging.go:19:		logVerboseOutput			0.0%
github.com/konveyor/crane/e2e-tests/framework/pipeline.go:11:		RunCranePipeline			0.0%
github.com/konveyor/crane/e2e-tests/framework/pipeline.go:25:		RunCranePipelineWithChecks		0.0%
github.com/konveyor/crane/e2e-tests/framework/pipeline.go:43:		PrepareSourceApp			0.0%
github.com/konveyor/crane/e2e-tests/framework/pipeline.go:57:		ApplyOutputToTarget			0.0%
github.com/konveyor/crane/e2e-tests/framework/pipeline.go:65:		ApplyOutputToTargetNonAdmin		0.0%
github.com/konveyor/crane/e2e-tests/framework/pipeline.go:69:		applyOutputManifests			0.0%
github.com/konveyor/crane/e2e-tests/framework/pipeline.go:80:		checkAndLogStageFiles			0.0%
github.com/konveyor/crane/e2e-tests/framework/rbac.go:14:		GrantNamespaceAdminToUser		0.0%
github.com/konveyor/crane/e2e-tests/framework/rbac.go:41:		RevokeNamespaceAdminFromUser		0.0%
github.com/konveyor/crane/e2e-tests/framework/rbac.go:56:		SetupNamespaceAdminUser			0.0%
github.com/konveyor/crane/e2e-tests/framework/rbac.go:115:		SetupNamespaceAdminUsersForScenario	0.0%
github.com/konveyor/crane/e2e-tests/framework/scenario.go:29:		NewMigrationScenario			0.0%
github.com/konveyor/crane/e2e-tests/framework/scenario.go:80:		NewScenarioPaths			0.0%
github.com/konveyor/crane/e2e-tests/framework/scenario.go:97:		CleanupScenario				0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:13:			CreateTempDir				0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:18:			ListFilesRecursively			0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:40:			ListFilesRecursivelyAsList		0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:64:			HasFilesRecursively			0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:74:			ReadTestdataFile			0.0%
github.com/konveyor/crane/internal/file/file_helper.go:22:		ReadFiles				0.0%
github.com/konveyor/crane/internal/file/file_helper.go:32:		readFiles				0.0%
github.com/konveyor/crane/internal/file/file_helper.go:83:		GetWhiteOutFilePath			100.0%
github.com/konveyor/crane/internal/file/file_helper.go:87:		GetTransformPath			100.0%
github.com/konveyor/crane/internal/file/file_helper.go:91:		GetIgnoredPatchesPath			0.0%
github.com/konveyor/crane/internal/file/file_helper.go:95:		updateTransformDirPath			100.0%
github.com/konveyor/crane/internal/file/file_helper.go:99:		updateIgnoredPatchesDirPath		0.0%
github.com/konveyor/crane/internal/file/file_helper.go:106:		updatePath				100.0%
github.com/konveyor/crane/internal/file/file_helper.go:113:		GetOutputFilePath			100.0%
github.com/konveyor/crane/internal/flags/global_flags.go:14:		ApplyFlags				0.0%
github.com/konveyor/crane/internal/flags/global_flags.go:21:		GetLogger				0.0%
github.com/konveyor/crane/internal/flags/global_flags.go:29:		initConfig				0.0%
github.com/konveyor/crane/internal/plugin/plugin_helper.go:21:		GetPlugins				0.0%
github.com/konveyor/crane/internal/plugin/plugin_helper.go:38:		getBinaryPlugins			0.0%
github.com/konveyor/crane/internal/plugin/plugin_helper.go:63:		IsExecAny				0.0%
github.com/konveyor/crane/internal/plugin/plugin_helper.go:67:		GetFilteredPlugins			0.0%
github.com/konveyor/crane/internal/plugin/plugin_helper.go:106:		isPluginInList				0.0%
github.com/konveyor/crane/internal/plugin/plugin_manager_helper.go:24:	BuildManifestMap			0.0%
github.com/konveyor/crane/internal/plugin/plugin_manager_helper.go:68:	GetYamlFromUrl				75.0%
github.com/konveyor/crane/internal/plugin/plugin_manager_helper.go:82:	YamlToManifest				72.7%
github.com/konveyor/crane/internal/plugin/plugin_manager_helper.go:104:	FilterPluginForOsArch			100.0%
github.com/konveyor/crane/internal/plugin/plugin_manager_helper.go:122:	GetDefaultSource			0.0%
github.com/konveyor/crane/internal/plugin/plugin_manager_helper.go:131:	LocateBinaryInPluginDir			0.0%
github.com/konveyor/crane/internal/plugin/plugin_manager_helper.go:143:	IsUrl					100.0%
github.com/konveyor/crane/internal/plugin/plugin_manager_helper.go:149:	getData					80.0%
github.com/konveyor/crane/main.go:21:					main					0.0%
total:									(statements)				8.0%

Posted by CI

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
e2e-tests/framework/rbac.go (1)

77-80: ⚠️ Potential issue | 🟠 Major

Use the validated admin kubectl binary for the returned non-admin runner.

At Line 77–80, userKubectl.Bin is hardcoded to "kubectl" even though adminKubectl.Bin was already validated. This can fail when tests use a custom kubectl path.

Suggested fix
 	userKubectl := KubectlRunner{
-		Bin:     "kubectl",
+		Bin:     adminKubectl.Bin,
 		Context: nonAdminContext,
 	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@e2e-tests/framework/rbac.go` around lines 77 - 80, The non-admin
KubectlRunner is hardcoded to "kubectl" which ignores the validated admin
binary; change the user runner construction so userKubectl.Bin uses the
already-validated adminKubectl.Bin (i.e., set Bin to adminKubectl.Bin) while
keeping Context set to nonAdminContext so the returned KubectlRunner uses the
same validated kubectl binary as adminKubectl.
🧹 Nitpick comments (1)
e2e-tests/framework/scenario.go (1)

45-60: Prefer explicit non-admin context inputs over package-global reads.

At Line 45–60, NewMigrationScenario pulls config.SourceNonAdminContext/config.TargetNonAdminContext directly, which makes scenario construction depend on global state and can defer empty-context failures to later RBAC setup. Passing non-admin contexts as constructor args would make setup deterministic.

Refactor sketch
-func NewMigrationScenario(appName, namespace, k8sDeployBin, craneBin, srcCtx, tgtCtx string) MigrationScenario {
+func NewMigrationScenario(appName, namespace, k8sDeployBin, craneBin, srcCtx, tgtCtx, srcNonAdminCtx, tgtNonAdminCtx string) MigrationScenario {
 	return MigrationScenario{
 		...
 		SrcAppNonAdmin: K8sDeployApp{
 			...
-			Context:   config.SourceNonAdminContext,
+			Context:   srcNonAdminCtx,
 		},
 		TgtAppNonAdmin: K8sDeployApp{
 			...
-			Context:   config.TargetNonAdminContext,
+			Context:   tgtNonAdminCtx,
 		},
 		...
-		KubectlSrcNonAdmin: KubectlRunner{Bin: "kubectl", Context: config.SourceNonAdminContext},
-		KubectlTgtNonAdmin: KubectlRunner{Bin: "kubectl", Context: config.TargetNonAdminContext},
+		KubectlSrcNonAdmin: KubectlRunner{Bin: "kubectl", Context: srcNonAdminCtx},
+		KubectlTgtNonAdmin: KubectlRunner{Bin: "kubectl", Context: tgtNonAdminCtx},
 		...
 		CraneNonAdmin: CraneRunner{
 			Bin:           craneBin,
-			SourceContext: config.SourceNonAdminContext,
+			SourceContext: srcNonAdminCtx,
 		},
 	}
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@e2e-tests/framework/scenario.go` around lines 45 - 60, NewMigrationScenario
currently reads package-global config.SourceNonAdminContext and
config.TargetNonAdminContext when initializing SrcAppNonAdmin, TgtAppNonAdmin,
KubectlSrcNonAdmin and KubectlTgtNonAdmin, causing hidden/global-state failures;
change NewMigrationScenario signature to accept explicit non-admin context
parameters (e.g., srcNonAdminCtx, tgtNonAdminCtx) and use those values to
populate the Context fields for K8sDeployApp (SrcAppNonAdmin, TgtAppNonAdmin)
and KubectlRunner (KubectlSrcNonAdmin, KubectlTgtNonAdmin) instead of
referencing config.SourceNonAdminContext/config.TargetNonAdminContext so
scenario construction is deterministic and test inputs are explicit.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@e2e-tests/framework/client.go`:
- Around line 14-21: The function newKubeConfigLoadingRules currently reads
KUBECONFIG and assigns it to loadingRules.ExplicitPath, which disables the
default multi-file merge/precedence behavior; remove the manual override so the
loading rules produced by clientcmd.NewDefaultClientConfigLoadingRules() are
returned unmodified. In practice, delete the KUBECONFIG lookup and any
assignment to loadingRules.ExplicitPath in newKubeConfigLoadingRules so it
simply returns the default loadingRules.

In `@e2e-tests/framework/rbac.go`:
- Around line 82-88: The RBAC preflight error path after calling
userKubectl.CanI leaves the previously created RoleBinding/grant in place;
update the error branch so that before returning you revoke/delete the
RoleBinding that was created earlier (the grant made at Line ~73) using the same
kubectl runner or cleanup helper, and if the cleanup fails include that cleanup
error (or log it) while still returning the original CanI error; reference the
CanI call and the earlier RoleBinding/grant creation and ensure the cleanup
invocation runs in the error path so no permission is left behind.

---

Duplicate comments:
In `@e2e-tests/framework/rbac.go`:
- Around line 77-80: The non-admin KubectlRunner is hardcoded to "kubectl" which
ignores the validated admin binary; change the user runner construction so
userKubectl.Bin uses the already-validated adminKubectl.Bin (i.e., set Bin to
adminKubectl.Bin) while keeping Context set to nonAdminContext so the returned
KubectlRunner uses the same validated kubectl binary as adminKubectl.

---

Nitpick comments:
In `@e2e-tests/framework/scenario.go`:
- Around line 45-60: NewMigrationScenario currently reads package-global
config.SourceNonAdminContext and config.TargetNonAdminContext when initializing
SrcAppNonAdmin, TgtAppNonAdmin, KubectlSrcNonAdmin and KubectlTgtNonAdmin,
causing hidden/global-state failures; change NewMigrationScenario signature to
accept explicit non-admin context parameters (e.g., srcNonAdminCtx,
tgtNonAdminCtx) and use those values to populate the Context fields for
K8sDeployApp (SrcAppNonAdmin, TgtAppNonAdmin) and KubectlRunner
(KubectlSrcNonAdmin, KubectlTgtNonAdmin) instead of referencing
config.SourceNonAdminContext/config.TargetNonAdminContext so scenario
construction is deterministic and test inputs are explicit.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7e61edd5-4b6f-417e-935c-d0ac08eefef4

📥 Commits

Reviewing files that changed from the base of the PR and between dc709cc and ea79e71.

📒 Files selected for processing (5)
  • e2e-tests/framework/client.go
  • e2e-tests/framework/crane.go
  • e2e-tests/framework/pipeline.go
  • e2e-tests/framework/rbac.go
  • e2e-tests/framework/scenario.go
💤 Files with no reviewable changes (1)
  • e2e-tests/framework/crane.go

Comment thread e2e-tests/framework/client.go Outdated
Comment thread e2e-tests/framework/rbac.go
@msajidmansoori12 msajidmansoori12 force-pushed the add-ns-user branch 4 times, most recently from 93cef81 to 850af96 Compare April 6, 2026 05:49
…iner app

Signed-off-by: M Sajid Mansoori <mmansoor@redhat.com>
Signed-off-by: M Sajid Mansoori <mmansoor@redhat.com>
Signed-off-by: M Sajid Mansoori <mmansoor@redhat.com>
@msajidmansoori12 msajidmansoori12 changed the title Add script to add a user to minikube cluster Add namespace-admin support in E2E test framework and automate MTC-290 initContainer migration test Apr 6, 2026
Copy link
Copy Markdown
Contributor

@stillalearner stillalearner left a comment

Choose a reason for hiding this comment

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

Please add appropriate title,summary

Copy link
Copy Markdown
Contributor

@stillalearner stillalearner left a comment

Choose a reason for hiding this comment

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

lgtm

Signed-off-by: M Sajid Mansoori <mmansoor@redhat.com>
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.

3 participants