Skip to content

Check full GVK for PodSpec helpers#144

Open
AkashKumar7902 wants to merge 2 commits into
kubewarden:mainfrom
AkashKumar7902:issue-63-podspec-gvk
Open

Check full GVK for PodSpec helpers#144
AkashKumar7902 wants to merge 2 commits into
kubewarden:mainfrom
AkashKumar7902:issue-63-podspec-gvk

Conversation

@AkashKumar7902

Copy link
Copy Markdown

Summary

  • match PodSpec helper dispatch on the full request GVK instead of kind only
  • reject unsupported group/version/kind combinations with a GVK-specific message
  • add regression coverage for argocd.io/v1 Deployment in mutate and extract paths

Fixes #63

Testing

  • make test
  • make lint
  • git diff --check

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates PodSpec extraction/mutation helpers to dispatch on full Group/Version/Kind (GVK) instead of kind-only, preventing collisions like argocd.io/v1 Deployment being treated as apps/v1 Deployment (Fixes #63).

Changes:

  • Switch PodSpec helper dispatch logic to match full GVK (group + version + kind).
  • Improve rejection messaging to reference supported group/version/kind combinations.
  • Add regression tests covering mismatched GVKs for both mutate and extract paths.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
kubewarden.go Match PodSpec helper behavior on full GVK and unify supported-object messaging.
kubewarden_test.go Update existing tests to provide full GVK; add regression tests for mismatched GVK scenarios.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread kubewarden.go Outdated
Comment thread kubewarden.go Outdated
Comment thread kubewarden.go Outdated

@jvanz jvanz 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.

Please, take a look in the copilot comments. Special the ones about panicking when using nil pointer.

@jvanz jvanz moved this from Pending review to Blocked in Kubewarden Admission Controller Apr 28, 2026
@AkashKumar7902

Copy link
Copy Markdown
Author

Thanks, I addressed the nil-deref issue now. The PodSpec mutation and extraction paths share the same decoding/target lookup logic, validate the nested spec/template fields before dereferencing them, and return an error for malformed supported objects while keeping the existing rejection response for unsupported GVKs.

I also added regression coverage for missing PodSpec/template paths across the supported resource types.

Validated with:

  • go test ./...
  • go vet ./...
  • golangci-lint run ./...
  • git diff --check

@jvanz jvanz 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.

Please, resolve the conflicts.

@jvanz

jvanz commented May 21, 2026

Copy link
Copy Markdown
Member

@AkashKumar7902, please resolve the conflicts.

Signed-off-by: Akash Kumar <meakash7902@gmail.com>
Signed-off-by: Akash Kumar <meakash7902@gmail.com>
@AkashKumar7902 AkashKumar7902 force-pushed the issue-63-podspec-gvk branch from 3a671cc to 1721dd6 Compare May 23, 2026 20:56
@AkashKumar7902

Copy link
Copy Markdown
Author

Resolved the conflicts by rebasing the branch onto current main and keeping the full-GVK PodSpec helper changes plus the nil-field guard refactor. Local validation passed with go test ./... and git diff --check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Check group and version when extracting or mutating pod spec from objects

3 participants