-
Notifications
You must be signed in to change notification settings - Fork 872
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
proposal for overriding values inside structured data files
Signed-off-by: sophie <[email protected]>
- Loading branch information
1 parent
295dee8
commit a88c656
Showing
103 changed files
with
19,668 additions
and
12,694 deletions.
There are no files selected for viewing
219 changes: 219 additions & 0 deletions
219
docs/proposals/override-values-inside-structured-data-files/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,219 @@ | ||
--- | ||
title: Support Variable in OverridePolicy | ||
authors: | ||
- "@sophiefeifeifeiya" | ||
reviewers: | ||
- "@chaunceyjiang" | ||
- TBD | ||
|
||
approvers: | ||
- "@chaunceyjiang" | ||
- TBD | ||
|
||
creation-date: 2024-08-12 | ||
|
||
--- | ||
|
||
|
||
|
||
# Overriding Values inside Structured Data Files | ||
|
||
<!-- | ||
This is the title of your KEP. Keep it short, simple, and descriptive. A good | ||
title can help communicate what the KEP is and should be considered as part of | ||
any review. | ||
--> | ||
|
||
## Summary | ||
|
||
|
||
|
||
<!-- | ||
This section is incredibly important for producing high-quality, user-focused | ||
documentation such as release notes or a development roadmap. | ||
A good summary is probably at least a paragraph in length. | ||
--> | ||
|
||
The proposal introduces a new feature, `PlaintextObjectOverrider` within the OverridePolicy in Karmada, allowing users to override values inside JSON or YAML plaintext objects. This feature expands the current capabilities of `PlaintextOverrider`, which only supports whole-field replacements, by enabling granular modifications within complex JSON or YAML structures. | ||
|
||
|
||
|
||
## Motivation | ||
|
||
<!-- | ||
This section is for explicitly listing the motivation, goals, and non-goals of | ||
this KEP. Describe why the change is important and the benefits to users. | ||
--> | ||
|
||
### Goals | ||
|
||
<!-- | ||
List the specific goals of the KEP. What is it trying to achieve? How will we | ||
know that this has succeeded? | ||
--> | ||
|
||
+ Allow users to override specific fields within JSON or YAML structures in ConfigMaps or similar resources. | ||
|
||
+ Enable operations, `replace`, `add`, and `remove` on nested fields within plaintext objects. | ||
|
||
|
||
|
||
### Non-Goals | ||
|
||
<!-- | ||
What is out of scope for this KEP? Listing non-goals helps to focus discussion | ||
and make progress. | ||
--> | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
## Proposal | ||
|
||
<!-- | ||
This is where we get down to the specifics of what the proposal actually is. | ||
This should have enough detail that reviewers can understand exactly what | ||
you're proposing, but should not include things like API designs or | ||
implementation. What is the desired outcome and how do we measure success?. | ||
The "Design Details" section below is for the real | ||
nitty-gritty. | ||
--> | ||
|
||
### User Stories (Optional) | ||
|
||
<!-- | ||
Detail the things that people will be able to do if this KEP is implemented. | ||
Include as much detail as possible so that people can understand the "how" of | ||
the system. The goal here is to make this feel real for users without getting | ||
bogged down. | ||
--> | ||
|
||
#### Story 1 | ||
|
||
As an administrator, I want to update specific fields within JSON or YAML files in ConfigMaps to customize application behavior without replacing the entire configuration, ensuring that my changes are minimal and targeted. | ||
|
||
#### Story 2 | ||
|
||
As a developer, I want to override specific environment-related configurations stored in YAML within ConfigMaps, depending on the target deployment cluster, ensuring that my application behaves consistently across environments. | ||
|
||
|
||
|
||
### Notes/Constraints/Caveats (Optional) | ||
|
||
<!-- | ||
What are the caveats to the proposal? | ||
What are some important details that didn't come across above? | ||
Go in to as much detail as necessary here. | ||
This might be a good place to talk about core concepts and how they relate. | ||
--> | ||
|
||
### Risks and Mitigations | ||
|
||
<!-- | ||
What are the risks of this proposal, and how do we mitigate? | ||
How will security be reviewed, and by whom? | ||
How will UX be reviewed, and by whom? | ||
Consider including folks who also work outside the SIG or subproject. | ||
--> | ||
|
||
+ Introducing PlaintextObjectOverrider increases the complexity of OverridePolicy. To mitigate this, thorough documentation and examples will be provided. | ||
|
||
|
||
|
||
## Design Details | ||
|
||
<!-- | ||
This section should contain enough information that the specifics of your | ||
change are understandable. This may include API specs (though not always | ||
required) or even code snippets. If there's any ambiguity about HOW your | ||
proposal will be implemented, this is the place to discuss them. | ||
--> | ||
|
||
### API Change | ||
|
||
```go | ||
type Overriders struct { | ||
... | ||
// PlaintextObjectOverrider represents the rules dedicated to handling yaml or json object overrides | ||
// +optional | ||
PlaintextObjectOverrider []PlaintextObjectOverrider `json:"plaintextObjectOverrider,omitempty"` | ||
} | ||
``` | ||
|
||
|
||
|
||
### User usage example | ||
|
||
For example, consider a ConfigMap with the following data: | ||
|
||
```yaml | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: myconfigmap | ||
data: | ||
test.json: | | ||
{"key": {"test": "value"}, {"key1": "value"}} | ||
``` | ||
Using PlaintextObjectOverrider, you can update the value of key.test from "value" to "value1" as follows: | ||
```yaml | ||
apiVersion: policy.karmada.io/v1alpha1 | ||
kind: OverridePolicy | ||
metadata: | ||
name: example | ||
spec: | ||
overrideRules: | ||
- overriders: | ||
plaintextObjectOverrider: | ||
- path: /data/test.json | ||
plaintext: | ||
- path: /key/test | ||
operator: replace | ||
value: value1 | ||
``` | ||
After applying this policy, the myconfigmap resource will reflect the updated value within the JSON structure. | ||
### Test Plan | ||
#### UT | ||
- Add unit tests to cover the new functions. | ||
#### E2E | ||
+ Write proposal in `coverage_docs/overridepolicy_test.md` : deployment PlaintextObjectOverrider testing; | ||
+ Use ginkgo to complete the code `overridepolicy_test.go`. | ||
|
||
|
||
|
||
## Alternatives | ||
|
||
<!-- | ||
What other approaches did you consider, and why did you rule them out? These do | ||
not need to be as detailed as the proposal, but should include enough | ||
information to express the idea and why it was not acceptable. | ||
--> | ||
|
||
<!-- | ||
Note: This is a simplified version of kubernetes enhancement proposal template. | ||
https://github.com/kubernetes/enhancements/tree/3317d4cb548c396a430d1c1ac6625226018adf6a/keps/NNNN-kep-template | ||
--> | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.