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

Expand variables in file_info fields #903

Open
2 tasks done
aleroza opened this issue Feb 3, 2025 · 2 comments
Open
2 tasks done

Expand variables in file_info fields #903

aleroza opened this issue Feb 3, 2025 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@aleroza
Copy link

aleroza commented Feb 3, 2025

Is your feature request related to a problem? Please describe.

I'm unable to use NFPM in configurations like this when I externally set 'owner' and 'group' as environment variables beforehand. The same issue occurs with 'mode' and 'mtime', but in those cases, NFPM returns an error about incorrect types.

contents:
  - src: ./build/pkg_root
    dst: ${PACKAGE_PREFIX}
    type: tree
    file_info:
      owner: ${PACKAGE_USER}
      group: ${PACKAGE_GROUP}
      mode: ${PACKAGE_MODE}
      mtime: ${PACKAGE_MTIME}
    expand: true

Describe the solution you'd like

Expand environment variables in file_info fields

Describe alternatives you've considered

In my case, the only alternatives are to use a separate nfpm.yaml file or the same user for different packages. However, these approaches feel too complicated and not ideal.

Search

  • I did search for other open and closed issues before opening this.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Additional context

NFPM v2.41.2

@aleroza aleroza added the enhancement New feature or request label Feb 3, 2025
@caarlos0
Copy link
Member

caarlos0 commented Feb 5, 2025

in that case, you can probably use something like envsubst or some other templating language to pre-process the file?

@aleroza
Copy link
Author

aleroza commented Feb 5, 2025

Yes, I can use other tools to pre-process nfpm.yml, but almost all fields can expand environment variables except for file_info...

In my opinion (though I admit it may be amateurish), this seems like an extremely simple feature to implement — it would just require adding a couple (or just two) of lines to one function:
https://github.com/goreleaser/nfpm/blob/main/nfpm.go#L193

I understand that you are not here to solve problems specific to my CI setup, but using a separate templating feels like unnecessary overhead for what appears to be a easy feature.

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

No branches or pull requests

2 participants