1
0
mirror of https://github.com/prometheus-community/postgres_exporter.git synced 2025-08-08 04:42:07 +03:00

Add cross-compilation Makefile targets and tar-based releases.

Revamp the build system to be more inline with other Prometheus exporters.
Notably add Darwin and Windows build targets, and add support for releases
using tar files.
This commit is contained in:
Will Rouesnel
2017-11-30 03:15:53 +11:00
parent 61b93a17a6
commit 5b9fea01ee
98 changed files with 10599 additions and 1487 deletions

View File

@@ -8,12 +8,12 @@ import (
)
// Config for gometalinter. This can be loaded from a JSON file with --config.
type Config struct { // nolint: aligncheck
// A map of linter name to "<command>:<pattern>".
type Config struct { // nolint: maligned
// A map from linter name -> <LinterConfig|string>.
//
// <command> should always include {path} as the target directory to execute. Globs in <command>
// are expanded by gometalinter (not by the shell).
Linters map[string]string
// For backwards compatibility, the value stored in the JSON blob can also
// be a string of the form "<command>:<pattern>".
Linters map[string]StringOrLinterConfig
// The set of linters that should be enabled.
Enable []string
@@ -51,6 +51,35 @@ type Config struct { // nolint: aligncheck
EnableGC bool
Aggregate bool
EnableAll bool
// Warn if a nolint directive was never matched to a linter issue
WarnUnmatchedDirective bool
formatTemplate *template.Template
}
type StringOrLinterConfig LinterConfig
func (c *StringOrLinterConfig) UnmarshalJSON(raw []byte) error {
var linterConfig LinterConfig
// first try to un-marshall directly into struct
origErr := json.Unmarshal(raw, &linterConfig)
if origErr == nil {
*c = StringOrLinterConfig(linterConfig)
return nil
}
// i.e. bytes didn't represent the struct, treat them as a string
var linterSpec string
if err := json.Unmarshal(raw, &linterSpec); err != nil {
return origErr
}
linter, err := parseLinterConfigSpec("", linterSpec)
if err != nil {
return err
}
*c = StringOrLinterConfig(linter)
return nil
}
type jsonDuration time.Duration
@@ -70,17 +99,16 @@ func (td *jsonDuration) Duration() time.Duration {
return time.Duration(*td)
}
// TODO: should be a field on Config struct
var formatTemplate = &template.Template{}
var sortKeys = []string{"none", "path", "line", "column", "severity", "message", "linter"}
// Configuration defaults.
var config = &Config{
Format: "{{.Path}}:{{.Line}}:{{if .Col}}{{.Col}}{{end}}:{{.Severity}}: {{.Message}} ({{.Linter}})",
Format: DefaultIssueFormat,
Linters: map[string]StringOrLinterConfig{},
Severity: map[string]string{
"gotype": "error",
"gotypex": "error",
"test": "error",
"testify": "error",
"vet": "error",