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

Loading custom library not working when listing files individually #62

Closed
guludo opened this issue Oct 17, 2019 · 6 comments
Closed

Loading custom library not working when listing files individually #62

guludo opened this issue Oct 17, 2019 · 6 comments
Labels
discussion This issue is not a bug or feature and a conversation is needed to find an appropriate resolution helping with an issue Debugging happening to identify the problem

Comments

@guludo
Copy link
Contributor

guludo commented Oct 17, 2019

Hi,

I get an error when running ytt against example-load-custom-library when I specify the files one by one:

$ ytt -f _ytt_lib/github.com/k14s/test-lib/funcs.star -f config.yml
Error: 
- cannot load @github.com/k14s/test-lib:funcs.star: Could not find private library (directory '_ytt_lib' missing?)
    config.yml:11 in <toplevel>
     L #@ load("@github.com/k14s/test-lib:funcs.star", "testfunc")
@cppforlife
Copy link
Contributor

@guludo right, when loading individual files they all get their "basename" file names. e.g.

$ ytt -f examples/eirini/config-alt1.yml -f examples/eirini/config.lib.yaml --files-inspect
config-alt1.yml
config.lib.yaml

this was done because there is no obvious way to normalize cases such as ../../config.lib.yml and https://something.com/something.yml except with the current approach. this might be surprising though.

in your example you would have to load directory that contains _ytt_lib via -f .

@cppforlife cppforlife added discussion This issue is not a bug or feature and a conversation is needed to find an appropriate resolution helping with an issue Debugging happening to identify the problem labels Oct 17, 2019
@guludo
Copy link
Contributor Author

guludo commented Oct 17, 2019

I see. That makes sense. Additionally to the examples you showed, it would also be hard to know the the "root" directory intended by the user...

I think two things could be done regarding documentation then:

  1. Fix documentation on load(), by removing or changing the following: "equivalently, ytt -f app1.yml -f helpers.lib.yml -f _ytt_lib/apps/apps.lib.yml will also make above possible".
  2. Make clear the different semantics of -f. That is:
    i. when the argument is a file, ytt adds only the file name to its internal "file list";
    ii. then the argument is a directory, the files under it are added as paths relative to that directory.

Does that make sense?

@cppforlife
Copy link
Contributor

👍 on both.

@nimakaviani
Copy link
Contributor

@guludo would you be willing to send in a PR?

@guludo
Copy link
Contributor Author

guludo commented Oct 17, 2019

Yes.

@nimakaviani
Copy link
Contributor

closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion This issue is not a bug or feature and a conversation is needed to find an appropriate resolution helping with an issue Debugging happening to identify the problem
Projects
None yet
Development

No branches or pull requests

3 participants