Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposing structured field overrider API #5581

Conversation

RainbowMango
Copy link
Member

@RainbowMango RainbowMango commented Sep 21, 2024

What type of PR is this?

/kind api-change

What this PR does / why we need it:
This PR proposes the API change to address the requirement of #5449.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:
For example, if you want to modify the database's host and port in the following ConfigMap:

apiVersion: v1
kind: ConfigMap
metadata:
  name: example-config
data:
  db-config.yaml: |
    database:
      host: localhost
      port: 3306

You can do that by leveraging the proposing API:

apiVersion: karmada.io/v1alpha1
kind: OverridePolicy
metadata:
  name: example-configmap-override
spec:
  resourceSelectors:
    - apiVersion: v1
      kind: ConfigMap
      name: example-config
  overrideRules:
    - targetCluster: {}
      overriders:
        fieldOverrider:
          - fieldPath: /data/db-config.yaml
            yaml:
              - subPath: /database/host
                operator: replace
                value: "remote-db.example.com"
              - subPath: /database/port
                operator: replace
                value: "3307"

The OverridePolicy declares the replace the /database/host with remote-db.example.com and port with 3307.

The expected result should be:

apiVersion: v1
kind: ConfigMap
metadata:
  name: example-config
data:
  db-config.yaml: |
    database:
      host: remote-db.example.com
      port: 3307

Does this PR introduce a user-facing change?:

API Change: Introduced `FieldOverrider` to both OverridePolicy and ClusterOverridePolicy, which provides the ability to override structured data nested in manifest like ConfigMap or Secret.

@karmada-bot karmada-bot added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Sep 21, 2024
@karmada-bot karmada-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 21, 2024
@sophiefeifeifeiya
Copy link
Contributor

The API looks good. btw, overriders needs to be added.

apiVersion: karmada.io/v1alpha1
kind: OverridePolicy
metadata:
  name: example-configmap-override
spec:
  resourceSelectors:
    - apiVersion: v1
      kind: ConfigMap
      name: example-config
  overrideRules:
    - overriders:
        fieldOverrider:
          - fieldPath: /data/db-config.yaml
            yaml:
              - subPath: /database/host
                operator: replace
                value: "remote-db.example.com"
              - subPath: /database/port
                operator: replace
                value: "3307"

@RainbowMango
Copy link
Member Author

Thanks. Updated.

@RainbowMango RainbowMango force-pushed the pr_proposing_structured_filed_overrider branch 2 times, most recently from 06b2db5 to 0f2fc51 Compare September 23, 2024 12:32
@RainbowMango RainbowMango force-pushed the pr_proposing_structured_filed_overrider branch from 0f2fc51 to 8ad4b5a Compare September 23, 2024 12:38
@karmada-bot karmada-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 23, 2024
@RainbowMango RainbowMango marked this pull request as ready for review September 23, 2024 12:38
@karmada-bot karmada-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 23, 2024
@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 34.86%. Comparing base (721107d) to head (8ad4b5a).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5581      +/-   ##
==========================================
- Coverage   34.87%   34.86%   -0.01%     
==========================================
  Files         645      645              
  Lines       44833    44833              
==========================================
- Hits        15637    15633       -4     
- Misses      27991    27994       +3     
- Partials     1205     1206       +1     
Flag Coverage Δ
unittests 34.86% <ø> (-0.01%) ⬇️

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

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

@RainbowMango
Copy link
Member Author

Given our decision on #5449, we can now move this forward.

@RainbowMango RainbowMango added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 25, 2024
@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by:

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:

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

@RainbowMango RainbowMango added the lgtm Indicates that a PR is ready to be merged. label Sep 25, 2024
@RainbowMango RainbowMango added this to the v1.12 milestone Sep 25, 2024
@karmada-bot karmada-bot merged commit 8cee4e4 into karmada-io:master Sep 25, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants