carvel-dev / ytt

YAML templating tool that works on YAML structure instead of text
https://carvel.dev/ytt
Apache License 2.0
1.68k stars 137 forks source link

Marking file as type "starlark" fails to allow it to be treated as a Starlark file. #786

Closed jtigger closed 1 year ago

jtigger commented 1 year ago

Reported by @Zebradil in #carvel. Thank you. 🙏

Steps to Reproduce

  1. create the file star.test1:
    print(42)
  2. by default, ytt regards this file a "unknown type" or "data" and so it is not evaluated (expected):
    $ ytt -f test.star1
  3. rename the file to .star, and ytt regards this file a "starlark" file and evaluates it (expected):
    $ ytt -f test.star
    42
  4. mark the file directly as type starlark, and ytt should regard this file a "starlark" file and evaluate it:
    $ ytt -f test.star1 --file-mark='test.star1:type=starlark'

    (but it does not 🛑)

Anything else you would like to add:

Key symptom is the way in which a file is determined to be a "library file":

https://github.com/vmware-tanzu/carvel-ytt/blob/92f7de5ca3a11dfa5f341134f15cbc0a6b0fb31f/pkg/files/file.go#L242-L251

which only regards the extension of a file.

Environment:


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.

Zebradil commented 1 year ago

Thank you for creating the issue.

I have noticed that the code on the step 3 is incorrect. It should be something with the following:

ytt -f test.star
jtigger commented 1 year ago

Whops! Thanks, @Zebradil. I updated the description.