Skip to content

zarf tries to apply template replacements to large files that might be incorrectly assessed as text #2308

@WeaponX314

Description

@WeaponX314

Environment

Device and OS: linux/amd64
App version: 0.32.3
Kubernetes distro being used: k3s (Not applicable for this problem)
Other:

Steps to reproduce

  1. Create a zarf package that pulls a self-executing script like the NVIDIA script:
    files:
      - source: https://us.download.nvidia.com/XFree86/Linux-x86_64/535.154.05/NVIDIA-Linux-x86_64-535.154.05.run
        target: /tmp/nvidia-driver.run
        executable: true
  1. Attempt to deploy it using zarf package deploy

Expected result

FIle is simply copied to location

Actual Result

This particular type of file is technically a script with an archive concatenated with it and it is rather large. Zarf detects it as a text file since it has text up front and tries to apply templating (###ZARF_VAR_*) to it.

There should be a way perhaps in the zarf.yaml to force it to not take this behavior. Maybe something like this?

    files:
      - source: https://us.download.nvidia.com/XFree86/Linux-x86_64/535.154.05/NVIDIA-Linux-x86_64-535.154.05.run
        target: /tmp/nvidia-driver.run
        executable: true
        noTemplate: true                  // new optional boolean

OR

Change the detection to also check the last couple of bytes at the end of the file too, should not be text for these type of installers.

If you opt for the latter, I can probably submit a PR myself. If you want to do the former, I would prefer your team discuss how you want to proceed. Happy to help where I can!

Visual Proof (screenshots, videos, text, etc)

  📦 DRIVERS COMPONENT                                                                                
                                                                                                      

  ⠦  Templating /tmp/nvidia-driver.run (9m10s)  

Severity/Priority

I can work around this by using an action to tar.gz it up beforehand but would be nice if I didn't have to do that.

Additional Context

Looks like this is the area of concern:

https://github.com/defenseunicorns/zarf/blob/7e91d3b9823b52fe6d0f563d692c8af57faa6005/src/pkg/packager/deploy.go#L360

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐞Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions