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

renderer: add path information to the metadata to aid file template funcs #103

Open
jrasell opened this issue Oct 14, 2021 · 4 comments
Open
Labels

Comments

@jrasell
Copy link
Member

jrasell commented Oct 14, 2021

When utilising file template functions such as fileContents it is preferable to specify the path relative to the pack. This causes problems when running across different environments such as a developer laptop or CI SaaS platform. Ideally we would provide a function or piece of data to allow specifying this relative path which is converted at render time to an absolute path.

@jrasell jrasell added stage/accepted theme/template/render Relates to the rendering of templates type/enhancement labels Oct 19, 2021
@malmz
Copy link

malmz commented Jan 23, 2023

Im trying to use nomad pack and want to split out config files and use fileContents to include them. This does not seem to work at all. fileContents seems to be relative to the working directory of the caller. Is there currently any way to include files relative to the pack?

@gregory112
Copy link

@malmz @jrasell I too have the same concern. All fileContents function seem to take files from the caller, and not from the repository. I think for now the workaround is static files can be converted into templates first with define and be imported with template function instead of using fileContents.

@slonopotamus
Copy link
Contributor

I +1 this. Ordinary Nomad job files also suffer from the same issue - there is no way to build a path that would be relative to job file.

It looks like that what we need is a template variable that would expand to pack directory path.

@josegonzalez
Copy link

I took an alternative here by creating a packFileContents template function.

I looked at putting it into metas but that seems to map to metadata.hcl so it didn't seem correct to place it there. That said, maybe a packPath is better, as then that could reference anything in the pack's directory as opposed to just the templates subfolder. I'll update my PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants