Skip to content

feat: support for status subresource patches#2654

Merged
eddycharly merged 8 commits into
kyverno:mainfrom
bakito:subresource
May 4, 2026
Merged

feat: support for status subresource patches#2654
eddycharly merged 8 commits into
kyverno:mainfrom
bakito:subresource

Conversation

@bakito

@bakito bakito commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Explanation

This PR adds the possibility to patch subresoruces. This can be helpful when the tests need to simulate updates done by external controllers.

Related issue

Discussed with @eddycharly on Contribfest

Proposed Changes

An additional filed 'subresource' is added to the Patch operation. The subresource filed defines the name of the subresource, that will be patched.

Checklist

  • I have read the contributing guidelines.
  • I have read the PR documentation guide and followed the process including adding proof manifests to this PR.
  • This is a bug fix and I have added unit tests that prove my fix is effective.

Further Comments

It was cool meeting the maintainers on Contribfest at KubeCon Amsterdam!

@bakito
bakito force-pushed the subresource branch 15 times, most recently from 11f75a4 to bdd30d5 Compare March 28, 2026 11:52
@bakito bakito changed the title Support for Subresource patch feat: Support for Subresource patch Mar 28, 2026
@bakito
bakito marked this pull request as ready for review March 30, 2026 05:47
@bakito
bakito requested a review from a team as a code owner March 30, 2026 05:47
@codecov

codecov Bot commented Apr 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.56098% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 67.70%. Comparing base (de0a923) to head (c3be2f6).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/runner/operations/patch.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2654      +/-   ##
==========================================
+ Coverage   67.08%   67.70%   +0.62%     
==========================================
  Files         149      149              
  Lines        5723     5757      +34     
==========================================
+ Hits         3839     3898      +59     
+ Misses       1624     1599      -25     
  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.

@bakito bakito changed the title feat: Support for Subresource patch feat: support for status subresource patches Apr 1, 2026
@bakito
bakito force-pushed the subresource branch 2 times, most recently from b372c16 to 154646f Compare April 1, 2026 11:28
@bakito

bakito commented Apr 1, 2026

Copy link
Copy Markdown
Contributor Author

@eddycharly is test coverage ok like this?
the current missing covered lines do not have any tests yet.

@bakito

bakito commented May 1, 2026

Copy link
Copy Markdown
Contributor Author

I have an alternative approach here:
#2699

This approach works with an annotation instated of an attribute in Patch action struct.
Resources that need a subresource patch would add the annotation chainsaw.kyverno.io/patch-subresource where the value is the name of the subresource to be patched.

This allows only using one patch action fit a file that contain resources with normal patches as well as suresoruce patches.

@eddycharly what would you prefer?

Sample:

apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
  name: basic-deployment
spec:
  steps:
    - name: deploy-application
        - description: Simulate Readiness of provider resources
          patch:
            file: 02-patch-provider-resources.yaml

with the patch file: 02-patch-provider-resources.yaml

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: basic-deployment-dev-app
  namespace: basic-deployment-dev
status:
  sync:
    status: OutOfSync
---
apiVersion: identity.vault.m.upbound.io/v1alpha1
kind: GroupAlias
metadata:
  name: basic-deployment-owner
  namespace: crossplane-resources
  annotations:
    chainsaw.kyverno.io/patch-subresource: status
status:
  conditions:
    - type: Ready
      status: "True"
      reason: ManuallySet
      message: Patched via chainsaw
      lastTransitionTime: "2026-03-28T10:51:35Z"

Signed-off-by: bakito <[email protected]>
Signed-off-by: bakito <[email protected]>
@eddycharly eddycharly added this to the v0.2.15 milestone May 4, 2026
@eddycharly
eddycharly enabled auto-merge (squash) May 4, 2026 10:24
@eddycharly
eddycharly merged commit f04748e into kyverno:main May 4, 2026
15 of 16 checks passed
@bakito
bakito deleted the subresource branch May 4, 2026 10:49
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.

2 participants