Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Fix kustomize patch target regex #197

Merged
merged 1 commit into from
Jul 28, 2022
Merged

Fix kustomize patch target regex #197

merged 1 commit into from
Jul 28, 2022

Conversation

epk
Copy link
Contributor

@epk epk commented Jul 28, 2022

Signed-off-by: Aditya Sharma [email protected]

Description of your changes

Fixes the following error when running make local.deploy.<component-name> which has been occurring since bumping the kustomize version in 3f7115e

Error: error parsing regexp: missing argument to repetition operator: `*`

I have:

  • Read and followed Upbound's contribution process.
  • Run make reviewable to ensure this PR is ready for review.
  • Added backport release-x.y labels to auto-backport this PR, as appropriate.

How has this code been tested

@tnthornton
Copy link
Member

@epk could you post how this change fixes the behavior you're seeing?

@epk epk self-assigned this Jul 28, 2022
@epk
Copy link
Contributor Author

epk commented Jul 28, 2022

Given a base and patch:

base.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80

patch-deployment.yaml

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: any
spec:
  template:
    metadata:
      annotations:
        rollme: "5298"

Before

kustomization.yaml

---
resources:
  - base.yaml
patches:
  - path: patch-deployment.yaml
    target:
      kind: Deployment
      name: "*"
kustomize version
{Version:kustomize/v4.5.5 GitCommit:daa3e5e2c2d3a4b8c94021a7384bfb06734bcd26 BuildDate:2022-05-20T20:21:22Z GoOs:darwin GoArch:arm64}
kustomize build .
Error: error parsing regexp: missing argument to repetition operator: `*`

After

kustomization.yaml

diff --git a/kustomization.yaml b/kustomization.yaml.new
index 83a5691..ca5ea53 100644
--- a/kustomization.yaml
+++ b/kustomization.yaml.new
@@ -4,4 +4,4 @@ patches:
   - path: patch-deployment.yaml
     target:
       kind: Deployment
-      name: "*"
+      name: ".*"
kustomize version
{Version:kustomize/v4.5.5 GitCommit:daa3e5e2c2d3a4b8c94021a7384bfb06734bcd26 BuildDate:2022-05-20T20:21:22Z GoOs:darwin GoArch:arm64}
kustomize build .
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: nginx
  name: nginx-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      annotations:
        rollme: "5298"
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx:1.14.2
        name: nginx
        ports:
        - containerPort: 80

@epk epk merged commit bc4f82f into master Jul 28, 2022
@epk epk deleted the epk/kustomize-fix branch July 28, 2022 23:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants