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

More in examples/transformerconfigs/images#adding-a-custom-resource for path that are both ScalarNode and SequenceNode #5018

Closed
1 of 2 tasks
kamok opened this issue Feb 1, 2023 · 5 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. triage/needs-information Indicates an issue needs more information in order to work on it.

Comments

@kamok
Copy link

kamok commented Feb 1, 2023

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 more examples on how to configure the image transformer to accomdate detailed fields besides ScalarNodes.

From my testing, more advanced path traversals like spec/params[name=foobar]/default is not supported. This makes the image transformer only strictly useful for SclarNode, as it isn't possible to path to a specific field if it is an Array / SequenceNode

https://github.com/kubernetes-sigs/kustomize/tree/master/examples/transformerconfigs/images#adding-a-custom-resource

It would be nice if the transformer just ignores values that are Sequence, and only worry about Scalar.

Why is this needed?

Here's an example use case:

kind: Task
spec:
    params:
      - name: image-name
         default: 'image-name-duplicated-everywhere' # string, scalar
      - name: i-dont-want-this-one
         default: ['foo'] # array, sequence

In my configuration, I point to

images:
- path: spec/params[]/default
  kind: Task

which errors out : visit traversal on path: [default]: wrong Node Kind for default expected: ScalarNode was SequenceNode: value: {[]}, as expected.

This doesn't work, fails silently

images:
- path: spec/params.[name=image-name]/default
  kind: Task

This doesn't work either, fails silently

images:
- path: spec/params[name=image-name]/default
  kind: Task

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

No

What other solutions have you considered?

I've tried other syntax like the new *, and spent a long time in the Issues for answers

Anything else we should know?

I read here #3945
that you're deprecating configurations, is it even worth spending time trying to get this to work?

Feature ownership

  • I am interested in contributing this feature myself! 🎉
@kamok kamok added the kind/feature Categorizes issue or PR as related to a new feature. label Feb 1, 2023
@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 1, 2023
@kamok kamok changed the title More in examples/transformerconfigs/images#adding-a-custom-resource for path that are both SclarNode and SequenceNode More in examples/transformerconfigs/images#adding-a-custom-resource for path that are both ScalarNode and SequenceNode Feb 1, 2023
@annasong20
Copy link
Contributor

Hi @kamok, the current documented behavior in the configurations examples for images is actually the extent of the actual behavior, more or less. The configurations path field is also capable of character escaping, but this is irrelevant to your use case. The list filtering [field=value] capability that you reference is limited to replacements.

The path field in configurations is capable of traversing sequences. For example, the setup below should work

# kustomization.yaml
resources:
- task.yaml
configurations:
- images.yaml
images:
- name: image-name-duplicated-everywhere
  newName: changed
# task.yaml
apiVersion: custom/v1
kind: Task
metadata:
  name: my-task
spec:
  params:
    - name: image-name
      image: image-name-duplicated-everywhere
    - name: nginxapp
      image: nginx:1.7.9
# images.yaml
images:
- kind: Task
  path: spec/params/image

If your issue was that you weren't aware of this behavior because the configurations documentation wasn't clear enough about its support for sequences, I can retitle and accept your issue.

Otherwise, the problem with your current setup is that kustomize does not expect a single field to have multiple types. Specifically, the spec/params/default field of Task can be either a scalar or sequence. The kubernetes specification only allows a single type for each field, with the int-or-string being the only exception. Maybe you could provide some more context on your setup?

/triage needs-information

@k8s-ci-robot k8s-ci-robot added triage/needs-information Indicates an issue needs more information in order to work on it. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Mar 21, 2023
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 19, 2023
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle rotten
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jul 19, 2023
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

@k8s-ci-robot
Copy link
Contributor

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 20, 2024
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. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. triage/needs-information Indicates an issue needs more information in order to work on it.
Projects
None yet
Development

No branches or pull requests

4 participants