1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-26 04:22:05 +02:00

fix: linter fixes

This commit is contained in:
Carlos Alexandro Becker 2018-11-07 22:04:49 -02:00 committed by Carlos Alexandro Becker
parent aef63d2fcb
commit 6c349c1759
13 changed files with 21 additions and 15 deletions

View File

@ -19,8 +19,10 @@ import (
)
// Default builder instance
// nolint: gochecknoglobals
var Default = &Builder{}
// nolint: gochecknoinits
func init() {
api.Register("go", Default)
}

View File

@ -91,6 +91,7 @@ func valid(target target) bool {
}
// list from https://golang.org/doc/install/source#environment
// nolint: gochecknoglobals
var validTargets = []string{
"androidarm",
"darwin386",

View File

@ -37,8 +37,11 @@ type asset struct {
type assetOpenFunc func(string, *artifact.Artifact) (*asset, error)
// nolint: gochecknoglobals
var assetOpen assetOpenFunc
// TODO: fix this.
// nolint: gochecknoinits
func init() {
assetOpenReset()
}
@ -123,6 +126,7 @@ func Upload(ctx *context.Context, puts []config.Put, kind string, check Response
// Handle every configured put
for _, put := range puts {
put := put
filters := []artifact.Filter{}
if put.Checksum {
filters = append(filters, artifact.ByType(artifact.Checksum))

View File

@ -62,6 +62,7 @@ func (Pipe) Publish(ctx *context.Context) error {
// Check requirements for every instance we have configured.
// If not fulfilled, we can skip this pipeline
for _, instance := range ctx.Config.Artifactories {
instance := instance
if skip := http.CheckConfig(ctx, &instance, "artifactory"); skip != nil {
return pipe.Skip(skip.Error())
}

View File

@ -143,6 +143,7 @@ func previous(tag string) (result string, err error) {
return
}
// nolint: gochecknoglobals
var validSHA1 = regexp.MustCompile(`^[a-fA-F0-9]{40}$`)
// isSHA1 te lets us know if the ref is a SHA1 or not

View File

@ -41,6 +41,7 @@ func (Pipe) Run(ctx *context.Context) error {
return validate(ctx)
}
// nolint: gochecknoglobals
var fakeInfo = context.GitInfo{
CurrentTag: "v0.0.0",
Commit: "none",

View File

@ -34,6 +34,7 @@ type Publisher interface {
Publish(ctx *context.Context) error
}
// nolint: gochecknoglobals
var publishers = []Publisher{
s3.Pipe{},
put.Pipe{},
@ -47,15 +48,13 @@ var publishers = []Publisher{
scoop.Pipe{},
}
var bold = color.New(color.Bold)
// Run the pipe
func (Pipe) Run(ctx *context.Context) error {
if ctx.SkipPublish {
return pipe.ErrSkipPublishEnabled
}
for _, publisher := range publishers {
log.Infof(bold.Sprint(publisher.String()))
log.Infof(color.New(color.Bold).Sprint(publisher.String()))
if err := handle(publisher.Publish(ctx)); err != nil {
return errors.Wrapf(err, "%s: failed to publish artifacts", publisher.String())
}

View File

@ -32,6 +32,7 @@ func (Pipe) Publish(ctx *context.Context) error {
// Check requirements for every instance we have configured.
// If not fulfilled, we can skip this pipeline
for _, instance := range ctx.Config.Puts {
instance := instance
if skip := http.CheckConfig(ctx, &instance, "put"); skip != nil {
return pipe.Skip(skip.Error())
}

View File

@ -19,12 +19,6 @@ const bodyTemplateText = `{{ .ReleaseNotes }}
{{- end }}
`
var bodyTemplate *template.Template
func init() {
bodyTemplate = template.Must(template.New("release").Parse(bodyTemplateText))
}
func describeBody(ctx *context.Context) (bytes.Buffer, error) {
var out bytes.Buffer
// nolint:prealloc
@ -32,6 +26,7 @@ func describeBody(ctx *context.Context) (bytes.Buffer, error) {
for _, a := range ctx.Artifacts.Filter(artifact.ByType(artifact.DockerImage)).List() {
dockers = append(dockers, a.Name)
}
var bodyTemplate = template.Must(template.New("release").Parse(bodyTemplateText))
err := bodyTemplate.Execute(&out, struct {
ReleaseNotes string
DockerImages []string

View File

@ -31,6 +31,7 @@ type Piper interface {
}
// Pipeline contains all pipe implementations in order
// nolint: gochecknoglobals
var Pipeline = []Piper{
defaults.Pipe{}, // load default configs
before.Pipe{}, // run global hooks before build

10
main.go
View File

@ -18,6 +18,7 @@ import (
"github.com/goreleaser/goreleaser/pkg/context"
)
// nolint: gochecknoglobals
var (
version = "dev"
commit = "none"
@ -37,15 +38,13 @@ type releaseOptions struct {
Timeout time.Duration
}
func init() {
func main() {
// enable colored output on travis
if os.Getenv("CI") != "" {
color.NoColor = false
}
log.SetHandler(cli.Default)
}
func main() {
fmt.Println()
defer fmt.Println()
@ -134,14 +133,12 @@ func releaseProject(options releaseOptions) error {
return doRelease(ctx)
}
var bold = color.New(color.Bold)
func doRelease(ctx *context.Context) error {
defer func() { cli.Default.Padding = 3 }()
var release = func() error {
for _, pipe := range pipeline.Pipeline {
cli.Default.Padding = 3
log.Infof(bold.Sprint(strings.ToUpper(pipe.String())))
log.Infof(color.New(color.Bold).Sprint(strings.ToUpper(pipe.String())))
cli.Default.Padding = 6
if err := handle(pipe.Run(ctx)); err != nil {
return err
@ -197,6 +194,7 @@ func loadConfig(path string) (config.Project, error) {
return config.Project{}, nil
}
// nolint: gochecknoglobals
var exampleConfig = `# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
before:

View File

@ -8,6 +8,7 @@ import (
"github.com/goreleaser/goreleaser/pkg/context"
)
// nolint: gochecknoglobals
var (
builders = map[string]Builder{}
lock sync.Mutex

View File

@ -33,6 +33,7 @@ type Defaulter interface {
}
// Defaulters is the list of defaulters
// nolint: gochecknoglobals
var Defaulters = []Defaulter{
env.Pipe{},
snapshot.Pipe{},