mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-19 20:57:53 +02:00
The PR formats code by removing redundant empty lines and fixes `//nolint` directives. Additionally, this PR adds two more rules to the `revive` configuration: `empty-lines` and `comment-spacings`. Removing unnecessary empty lines helps to keep the codebase clean and concise. This issue is identified by the `revive.empty-lines` rule. In the `//nolint` directive, there must be no spaces between `:` and the linter name: `//nolint:gosec`. See ["Nolint Directive"](https://golangci-lint.run/usage/false-positives/#nolint-directive). This issue is identified by the `revive.comment-spacings` rule. Note that it's not possible to add just a few additional rules to the `revive.enable` list. We need to specify all: default rules plus additional rules. See the detailed explanation [here](https://github.com/prometheus/prometheus/pull/13068).
27 lines
631 B
Go
27 lines
631 B
Go
package effectiveconfig
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/caarlos0/log"
|
|
"github.com/goreleaser/goreleaser/v2/internal/yaml"
|
|
"github.com/goreleaser/goreleaser/v2/pkg/context"
|
|
)
|
|
|
|
// Pipe that writes the effective config file to dist.
|
|
type Pipe struct{}
|
|
|
|
func (Pipe) String() string { return "" }
|
|
|
|
// Run the pipe.
|
|
func (Pipe) Run(ctx *context.Context) (err error) {
|
|
path := filepath.Join(ctx.Config.Dist, "config.yaml")
|
|
bts, err := yaml.Marshal(ctx.Config)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
log.WithField("path", path).Debug("writing effective configuration")
|
|
return os.WriteFile(path, bts, 0o644) //nolint:gosec
|
|
}
|