feat: add prefix and suffix options to replacements for targeting con...#6090
feat: add prefix and suffix options to replacements for targeting con...#6090Br1an67 wants to merge 1 commit intokubernetes-sigs:masterfrom
Conversation
…tainer args Add prefix and suffix options to FieldOptions for replacements. This allows targeting specific elements in string arrays (like container args) that match a prefix and/or suffix pattern. The matched prefix/suffix is preserved in the resulting value. This enables replacements like: - spec.template.spec.containers.[name=cert-manager].args with prefix: "--leader-election-namespace=" to replace args like "--leader-election-namespace=kube-system"
|
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Br1an67 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @Br1an67. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Please pass the CLA. |
b35db85 to
9624549
Compare
|
PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Fixes #4080
Summary
Add
prefixandsuffixoptions to theFieldOptionstype for replacements. This enables targeting specific elements in string arrays (like containerargs) that match a prefix and/or suffix pattern. The matched prefix and suffix are preserved in the resulting value.This addresses the issue where replacements couldn't reliably target
--key=valuestyle container arguments without relying on array index ordering.Changes
PrefixandSuffixstring fields toFieldOptionsinapi/types/replacement.gosetFieldValuefunction inapi/filters/replacement/replacement.goto handle prefix/suffix matching for both scalar and sequence (array) nodessetFieldValueInSequencehelper function to iterate over array elements and replace values that match the prefix/suffix patternmatchesPrefixAndSuffixhelper function for prefix/suffix validationUsage Example
This replaces any arg starting with
--leader-election-namespace=(e.g.,--leader-election-namespace=kube-system) with--leader-election-namespace=my-namespace.Testing
All existing tests pass, plus new test cases for the prefix/suffix functionality.