josephburnett / jd

JSON diff and patch
MIT License
1.86k stars 51 forks source link

Patch YAML by id fails to find #25

Closed josephburnett closed 3 years ago

josephburnett commented 3 years ago

a.yaml:

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

patch:

@ ["spec","template","spec","containers",{"name":"nginx"},"ports",0]
- 8080
+ 8081

error:

Invalid diff. Expected object with id {"name":"nginx"} but found none

Expected clean apply.

josephburnett commented 3 years ago

Fixed with https://github.com/josephburnett/jd/commit/3adfe95b44d25c16c40c6615e7d02c4af3e05eae which infers set keys from the path.