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

Syntax for fileContents #572

Open
SirHamburger opened this issue Aug 16, 2024 · 2 comments
Open

Syntax for fileContents #572

SirHamburger opened this issue Aug 16, 2024 · 2 comments

Comments

@SirHamburger
Copy link

I try to add files via the fileContents.

My current template is the following:

    template {
      destination = "config/[[var "RETAILER_ID" .]].[[var "SYSTEM_ID" .]]/[[$settings.FILTER_CONFIG_FILE]]"
      data        = <<EOT
        [[ fileContents "../config-files/[[var "RETAILER_ID" .]].[[var "SYSTEM_ID" .]]/[[$settings.FILTER_CONFIG_FILE]]" ]]
        EOT
    }

And I get the following error:
Error: template: <file>:25: bad character U+0022 '"'

How can I add variables to the data block (with the new Syntax)?

@SirHamburger
Copy link
Author

I have found a hacky solution:

    template {
      destination = "config/[[var "RETAILER_ID" .]].[[var "SYSTEM_ID" .]]/[[$settings.FILTER_CONFIG_FILE]]"
      data        = <<EOT
[[$A:="../config-files/"]]
[[$B:=(var "RETAILER_ID" .)]]
[[$C:="."]]        
[[$D:=(var "SYSTEM_ID" .)]]
[[$E:="/"]]   
[[$F:=($settings.FILTER_CONFIG_FILE)]]
[[$concat:=(print $A $B $C $D $E $F) ]]
[[$concat  | fileContents]]
        EOT
    }
```
If anyone has a not so hacky solution, it is still appreciated.

@SirHamburger
Copy link
Author

Still not sure what the best possibility is but i've another one:

[[$baseSourcePath := list "../config-files/" (var "RETAILER_ID" .) "."  (var "SYSTEM_ID" .) | join "" ]]
[[$baseTargetPath := list "config/" (var "RETAILER_ID" .) "."  (var "SYSTEM_ID" .) | join "" ]]


...


    template {
      destination = "[[$baseTargetPath]]/[[$settings.FILTER_CONFIG_FILE]]"
      data        = <<EOT
    [[ list ($baseSourcePath) "/generated_filter_configuration/" ($settings.FILTER_CONFIG_FILE) | join "" | fileContents ]]
EOT
    }

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

No branches or pull requests

1 participant