`keyMatcher.Path` cannot resolve images nested within a list
- Dominant language
- Go
- Stars
- 329
- Forks
- 52
- PR merge metrics
- No merged PRs in 30d
Description
**What steps did you take:**
I followed [this documentation](https://carvel.dev/kbld/docs/latest/config/#schema) to reference a nested key. Specifically, the following instruction:
> path (optional; array) specifies key path from the root of the YAML document (e.g. [data, sidecarImage], [spec, images, {allIndexes: true}])
To demonstrate the issue, here is a repro, containing a kbld config, an imgpkg lockfile and a manifest I wish to transform:
```yaml
---
apiVersion: kbld.k14s.io/v1alpha1
kind: Config
minimumRequiredVersion: 0.29.0
searchRules:
- keyMatcher:
path: [spec, default]
- keyMatcher:
path: [spec, list, {name: first-item}, default]
- keyMatcher:
path: [spec, list, {name: second-item}, nested, default]
---
apiVersion: imgpkg.carvel.dev/v1alpha1
images:
- annotations:
kbld.carvel.dev/id: original-image:1.2.3
image: updated-image@sha256:2005721c33a949d82bab23099aa3f577932c350bc24d5931932e7440856f6276
kind: ImagesLock
---
spec:
default: original-image:1.2.3
list:
- name: first-item
default: original-image:1.2.3
- name: second-item
nested:
default: original-image:1.2.3
```
**What happened:**
I ran the kbld command, and only some of the image references were replaced with the resolved image path:
```bash
$ kbld -f manifest.yaml
resolve | final: original-image:1.2.3 -> updated-image@sha256:2005721c33a949d82bab23099aa3f577932c350bc24d5931932e7440856f6276
---
metadata:
annotations:
kbld.k14s.io/images: |
- Metas:
- Type: preresolved
URL: updated-image@sha256:2005721c33a949d82bab23099aa3f577932c350bc24d5931932e7440856f6276
URL: updated-image@sha256:2005721c33a949d82bab23099aa3f577932c350bc24d5931932e7440856f6276
spec:
default: updated-image@sha256:2005721c33a949d82bab23099aa3f577932c350bc24d5931932e7440856f6276
list:
- default: original-image:1.2.3
name: first-item
- name: second-item
nested:
default: original-image:1.2.3
```
**What did you expect:**
I expected all instances of `original-image:1.2.3` in the manifest to be replaced with `updated-image@sha256:2005721c33a949d82bab23099aa3f577932c350bc24d5931932e7440856f6276`. I also expected to be able to reference the list items with the syntax `{name: first-item}`, `{name: second-item}`, etc.
**Anything else you would like to add:**
I had expected this to work like the select function in `jq`, e.g.:
```bash
$ cat manifest.yaml | yq -j eval | jq -r '.spec.list[] | select(.name == "first-item").default'
original-image:1.2.3
```
**Environment:**
- kbld version (use `kbld --version`): 0.39.0
- Docker registry used (e.g. `Docker HUB`): N/A
- OS (e.g. from `/etc/os-release`): Ubuntu 18.04.5 LTS
If building images using `docker`:
- Docker CLI Version (e.g. `docker version`): N/A
If building images using `buildkit`:
- Buildkit version (e.g. `kubectl buildkit version`): N/A
- Kubernetes version (e.g. `kubectl version`): N/A
If building images using `pack`
- Pack Version (e.g. `pack version`): N/A
---
Vote on this request
This is an invitation to the community to vote on issues, to help us prioritize our backlog. Use the "smiley face" up to the right of this comment to vote.
👍 "I would like to see this addressed as soon as possible"
👎 "There are other more important things to focus on right now"
We are also happy to receive and review Pull Requests if you want to help working on this issue.
Contributor guide
Research direction
Start by reproducing the issue with the provided kbld config, imgpkg lockfile, and manifest, then inspect the keyMatcher.Path entry point and its handling of list selectors such as {name: first-item}. Confirm the behavior with kbld 0.39.0. Done means image references nested in matching list items are resolved as expected, including the nested example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100