Skip to content

Comments

Add gazelle plugin#1

Draft
MyRedDice wants to merge 1 commit intomainfrom
gazelle-plugin
Draft

Add gazelle plugin#1
MyRedDice wants to merge 1 commit intomainfrom
gazelle-plugin

Conversation

@MyRedDice
Copy link
Owner

This commit adds a plugin for gazelle that generates nfpm_package rules and updates their dependencies.

While nfpm_package rules are small and simple to write, their dependencies must match the dependencies consumed in the corresponding .yaml file. This custom gazelle plugin automatically updates the dependencies.

There are a few ways we could distinguish between an nfpm yaml file and some other yaml file. Currently the plugin looks for a ".nfpm.yaml" file. This is faster than reading the file to determine what it is, especially for large projects with many YAML files.

Another question is whether to generate an RPM rule, a DEB rule, or both. Currently the plugin generates both. If one is unused it can be tagged as "manual". Some alternatives are choosing based on gazelle directives (eg "// gazelle:nfpm output rpm"), based on the config file extension (eg "example.rpm.yaml"), or providing one gazelle plugin for each of RPMs and DEBs.

Users who wish to set other custom attributes on the nfpm_package rules, such as tags and visibility, may do so using buildozer, for example.

This commit adds a [plugin](https://github.com/bazelbuild/bazel-gazelle/blob/master/extend.rst) for [gazelle](https://github.com/bazelbuild/bazel-gazelle) that generates nfpm_package rules and updates their dependencies.

While nfpm_package rules are small and simple to write, their dependencies must match the dependencies consumed in the corresponding .yaml file. This custom gazelle plugin automatically updates the dependencies.

There are a few ways we could distinguish between an nfpm yaml file and some other yaml file. Currently the plugin looks for a ".nfpm.yaml" file. This is faster than reading the file to determine what it is, especially for large projects with many YAML files.

Another question is whether to generate an RPM rule, a DEB rule, or both. Currently the plugin generates both. If one is unused it can be tagged as "manual". Some alternatives are choosing based on gazelle directives (eg "// gazelle:nfpm output rpm"), based on the config file extension (eg "example.rpm.yaml"), or providing one gazelle plugin for each of RPMs and DEBs.

Users who wish to set other custom attributes on the nfpm_package rules, such as tags and visibility, may do so using buildozer, for example.
@leungster
Copy link

A directive for overriding default output type seems reasonable for a generally used package like this.

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

Successfully merging this pull request may close these issues.

2 participants