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

Replacement with regex support for selectors #5862

Open
2 tasks done
sda399 opened this issue Feb 16, 2025 · 2 comments
Open
2 tasks done

Replacement with regex support for selectors #5862

sda399 opened this issue Feb 16, 2025 · 2 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@sda399
Copy link

sda399 commented Feb 16, 2025

Eschewed features

  • This issue is not requesting templating, unstuctured edits, build-time side-effects from args or env vars, or any other eschewed feature.

What would you like to have added?

I would like to add regex support in replacement selectors

Why is this needed?

Supporting regex in replacement selectors would:

  • reduce redundancy of replacement blocks, by targeting multiple objects with regex
  • harmonize replacement selectors with the patch selectors that already support regex
  • make it possible to migrate from patches to replacements

Can you accomplish the motivating task without this feature, and if so, how?

example: replace image tag using deploy1 into depoly2, st1 and st2:

apiVersion: v1
kind: Deployment
metadata:
  name: deploy1
spec:
  template:
    spec:
      containers:
      - image: nginx:1.27.4
        name: nginx-tagged
---
apiVersion: v1
kind: Deployment
metadata:
  name: deploy2
spec:
  template:
    spec:
      containers:
      - image: nginx:1.5
        name: nginx-tagged
---
apiVersion: v1
kind: Statefulset
metadata:
  name: st1
spec:
  template:
    spec:
      containers:
      - image: nginx:1.5
        name: nginx-tagged
---
apiVersion: v1
kind: Statefulset
metadata:
  name: st2
spec:
  template:
    spec:
      containers:
      - image: nginx:1.5
        name: nginx-tagged

current solution:

replacements:
- source:
    kind: Deployment
    name: deploy1
    fieldPath: spec.template.spec.containers.0.image
  targets:
  - select:
      kind: Deployment
      name: deploy2
    fieldPaths:
    - spec.template.spec.containers.0.image
  - select:
      kind: StatefulSet
      name: st1
    fieldPaths:
    - spec.template.spec.containers.0.image
 - select:
      kind: StatefulSet
      name: st2
    fieldPaths:
    - spec.template.spec.containers.0.image

What other solutions have you considered?

proposed solution:

replacements:
- source:
    kind: Deployment
    name: deploy1
    fieldPath: spec.template.spec.containers.0.image
  targets:
  - select:
      kind: Deployment|StatefulSet
      name: deploy2|st.*
    fieldPaths:
    - spec.template.spec.containers.0.image

Anything else we should know?

No response

Feature ownership

  • I am interested in contributing this feature myself! 🎉
@sda399 sda399 added the kind/feature Categorizes issue or PR as related to a new feature. label Feb 16, 2025
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Feb 16, 2025
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions 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.

@sda399
Copy link
Author

sda399 commented Feb 19, 2025

If the projects' PR or triage process, requires any missing step or more details, I'll be happy to help 💯
@koba1t @stormqueen1990

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
None yet
Development

No branches or pull requests

2 participants