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

Unexpected anchor behaviour when using functions #481

Open
groundnuty opened this issue Aug 27, 2021 · 2 comments
Open

Unexpected anchor behaviour when using functions #481

groundnuty opened this issue Aug 27, 2021 · 2 comments
Labels
documentation This issue indicates a change to the docs should be considered good first issue An issue that will be a good candidate for a new contributor priority/unprioritized-backlog Higher priority than priority/awaiting-more-evidence but not planned. Contributions are welcome.

Comments

@groundnuty
Copy link

What steps did you take:

Input:

#@ def group_alpha():
name: alpha
#@ end
groups: &all_groups
  - #@ group_alpha()
foo:
  groups: *all_groups

Result:

groups:
- null
foo:
  groups:
  - name: alpha

Expected:

groups:
- alpha
foo:
  groups:
  - name: alpha

Expected according to limitations

groups:
- alpha
foo:
  groups:
  - null

Interactive reproduction from gist.

Anything else you would like to add:
Please explain this unexpected behaviour, as it's not consistent with #172 or #186

Environment:

  • ytt version 0.36.0
  • macos 10.14 (18A391)
@groundnuty groundnuty added bug This issue describes a defect or unexpected behavior carvel triage This issue has not yet been triaged for relevance labels Aug 27, 2021
@groundnuty groundnuty changed the title Anchor behaviour not consistent with known limitations Anchor behaviour not consistent with known limitations when using functions Aug 27, 2021
@groundnuty groundnuty changed the title Anchor behaviour not consistent with known limitations when using functions Unxpected anchor behaviour when using functions Aug 27, 2021
@cppforlife
Copy link
Contributor

hey @groundnuty, as you found this is one of the known limitations (https://carvel.dev/ytt/docs/latest/known-limitations/); however, we should have probably made more clear that results are "undefined" (instead of providing some example). currently (and that may change) last node that splats the anchor would receive data. for your example:

#@ def group_alpha():
name: alpha
#@ end
groups: &all_groups
  - #@ group_alpha()
foo:
  groups: *all_groups  <--- this will be nil
  foo: *all_groups  <--- this will actually contain it

tldr -- we should improve docs to clarify that you should not rely on this behaviour.

@cari-lynn cari-lynn added documentation This issue indicates a change to the docs should be considered good first issue An issue that will be a good candidate for a new contributor priority/unprioritized-backlog Higher priority than priority/awaiting-more-evidence but not planned. Contributions are welcome. and removed bug This issue describes a defect or unexpected behavior carvel triage This issue has not yet been triaged for relevance labels Oct 5, 2021
@pivotaljohn pivotaljohn changed the title Unxpected anchor behaviour when using functions Unexpected anchor behaviour when using functions Nov 1, 2021
@Rajdeep1311
Copy link

I want to get involved in this project can anybody please help? how to get started?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation This issue indicates a change to the docs should be considered good first issue An issue that will be a good candidate for a new contributor priority/unprioritized-backlog Higher priority than priority/awaiting-more-evidence but not planned. Contributions are welcome.
Projects
Status: To Triage
Development

No branches or pull requests

4 participants