mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-11 13:57:36 -08:00
Run gofumpt on all files (#10392)
* Run gofumpt on all files Getting golangci-lint errors when building on my laptop, possibly because I have newer version of gofumpt then what it was formatted with. Run gofumpt -w -extra on all files as it will be needed in the future anyway. * Update golangci-lint to v1.44.2 v1.44.0 upgraded gofumpt so bumping version in CI will help keep formatting correct for everyone * Address golangci-lint error Getting 'error-strings: error strings should not be capitalized or end with punctuation or a newline' from revive here. Drop new line. Signed-off-by: Łukasz Mierzwa <l.mierzwa@gmail.com>
This commit is contained in:
parent
8e9d5c57ed
commit
a4317bf0ec
2
.github/workflows/golangci-lint.yml
vendored
2
.github/workflows/golangci-lint.yml
vendored
|
@ -28,4 +28,4 @@ jobs:
|
||||||
- name: Lint
|
- name: Lint
|
||||||
uses: golangci/golangci-lint-action@v2
|
uses: golangci/golangci-lint-action@v2
|
||||||
with:
|
with:
|
||||||
version: v1.42.0
|
version: v1.44.2
|
||||||
|
|
|
@ -83,7 +83,7 @@ PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_
|
||||||
|
|
||||||
GOLANGCI_LINT :=
|
GOLANGCI_LINT :=
|
||||||
GOLANGCI_LINT_OPTS ?=
|
GOLANGCI_LINT_OPTS ?=
|
||||||
GOLANGCI_LINT_VERSION ?= v1.42.0
|
GOLANGCI_LINT_VERSION ?= v1.44.2
|
||||||
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64.
|
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64.
|
||||||
# windows isn't included here because of the path separator being different.
|
# windows isn't included here because of the path separator being different.
|
||||||
ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))
|
ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))
|
||||||
|
|
|
@ -95,7 +95,8 @@ func (importer *ruleImporter) importAll(ctx context.Context) (errs []error) {
|
||||||
|
|
||||||
// importRule queries a prometheus API to evaluate rules at times in the past.
|
// importRule queries a prometheus API to evaluate rules at times in the past.
|
||||||
func (importer *ruleImporter) importRule(ctx context.Context, ruleExpr, ruleName string, ruleLabels labels.Labels, start, end time.Time,
|
func (importer *ruleImporter) importRule(ctx context.Context, ruleExpr, ruleName string, ruleLabels labels.Labels, start, end time.Time,
|
||||||
maxBlockDuration int64, grp *rules.Group) (err error) {
|
maxBlockDuration int64, grp *rules.Group,
|
||||||
|
) (err error) {
|
||||||
blockDuration := getCompatibleBlockDuration(maxBlockDuration)
|
blockDuration := getCompatibleBlockDuration(maxBlockDuration)
|
||||||
startInMs := start.Unix() * int64(time.Second/time.Millisecond)
|
startInMs := start.Unix() * int64(time.Second/time.Millisecond)
|
||||||
endInMs := end.Unix() * int64(time.Second/time.Millisecond)
|
endInMs := end.Unix() * int64(time.Second/time.Millisecond)
|
||||||
|
|
|
@ -50,7 +50,8 @@ type HypervisorDiscovery struct {
|
||||||
|
|
||||||
// newHypervisorDiscovery returns a new hypervisor discovery.
|
// newHypervisorDiscovery returns a new hypervisor discovery.
|
||||||
func newHypervisorDiscovery(provider *gophercloud.ProviderClient, opts *gophercloud.AuthOptions,
|
func newHypervisorDiscovery(provider *gophercloud.ProviderClient, opts *gophercloud.AuthOptions,
|
||||||
port int, region string, availability gophercloud.Availability, l log.Logger) *HypervisorDiscovery {
|
port int, region string, availability gophercloud.Availability, l log.Logger,
|
||||||
|
) *HypervisorDiscovery {
|
||||||
return &HypervisorDiscovery{
|
return &HypervisorDiscovery{
|
||||||
provider: provider, authOpts: opts,
|
provider: provider, authOpts: opts,
|
||||||
region: region, port: port, availability: availability, logger: l,
|
region: region, port: port, availability: availability, logger: l,
|
||||||
|
|
|
@ -59,7 +59,8 @@ type InstanceDiscovery struct {
|
||||||
|
|
||||||
// NewInstanceDiscovery returns a new instance discovery.
|
// NewInstanceDiscovery returns a new instance discovery.
|
||||||
func newInstanceDiscovery(provider *gophercloud.ProviderClient, opts *gophercloud.AuthOptions,
|
func newInstanceDiscovery(provider *gophercloud.ProviderClient, opts *gophercloud.AuthOptions,
|
||||||
port int, region string, allTenants bool, availability gophercloud.Availability, l log.Logger) *InstanceDiscovery {
|
port int, region string, allTenants bool, availability gophercloud.Availability, l log.Logger,
|
||||||
|
) *InstanceDiscovery {
|
||||||
if l == nil {
|
if l == nil {
|
||||||
l = log.NewNopLogger()
|
l = log.NewNopLogger()
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,8 +176,7 @@ func TestTargetGroupYamlUnmarshal(t *testing.T) {
|
||||||
|
|
||||||
func TestString(t *testing.T) {
|
func TestString(t *testing.T) {
|
||||||
// String() should return only the source, regardless of other attributes.
|
// String() should return only the source, regardless of other attributes.
|
||||||
group1 :=
|
group1 := Group{
|
||||||
Group{
|
|
||||||
Targets: []model.LabelSet{
|
Targets: []model.LabelSet{
|
||||||
{"__address__": "localhost:9090"},
|
{"__address__": "localhost:9090"},
|
||||||
{"__address__": "localhost:9091"},
|
{"__address__": "localhost:9091"},
|
||||||
|
@ -185,8 +184,7 @@ func TestString(t *testing.T) {
|
||||||
Source: "<source>",
|
Source: "<source>",
|
||||||
Labels: model.LabelSet{"foo": "bar", "bar": "baz"},
|
Labels: model.LabelSet{"foo": "bar", "bar": "baz"},
|
||||||
}
|
}
|
||||||
group2 :=
|
group2 := Group{
|
||||||
Group{
|
|
||||||
Targets: []model.LabelSet{},
|
Targets: []model.LabelSet{},
|
||||||
Source: "<source>",
|
Source: "<source>",
|
||||||
Labels: model.LabelSet{},
|
Labels: model.LabelSet{},
|
||||||
|
|
|
@ -84,7 +84,6 @@ func generateTargetGroups(allTargetGroups map[string][]*targetgroup.Group) map[s
|
||||||
}
|
}
|
||||||
|
|
||||||
sdGroup := customSD{
|
sdGroup := customSD{
|
||||||
|
|
||||||
Targets: newTargets,
|
Targets: newTargets,
|
||||||
Labels: newLabels,
|
Labels: newLabels,
|
||||||
}
|
}
|
||||||
|
|
|
@ -611,7 +611,6 @@ var tests = []struct {
|
||||||
{ // Nested Subquery.
|
{ // Nested Subquery.
|
||||||
input: `min_over_time(rate(foo{bar="baz"}[2s])[5m:])[4m:3s]`,
|
input: `min_over_time(rate(foo{bar="baz"}[2s])[5m:])[4m:3s]`,
|
||||||
expected: []Item{
|
expected: []Item{
|
||||||
|
|
||||||
{IDENTIFIER, 0, `min_over_time`},
|
{IDENTIFIER, 0, `min_over_time`},
|
||||||
{LEFT_PAREN, 13, `(`},
|
{LEFT_PAREN, 13, `(`},
|
||||||
{IDENTIFIER, 14, `rate`},
|
{IDENTIFIER, 14, `rate`},
|
||||||
|
@ -660,7 +659,6 @@ var tests = []struct {
|
||||||
{
|
{
|
||||||
input: `min_over_time(rate(foo{bar="baz"}[2s])[5m:] offset 6m)[4m:3s]`,
|
input: `min_over_time(rate(foo{bar="baz"}[2s])[5m:] offset 6m)[4m:3s]`,
|
||||||
expected: []Item{
|
expected: []Item{
|
||||||
|
|
||||||
{IDENTIFIER, 0, `min_over_time`},
|
{IDENTIFIER, 0, `min_over_time`},
|
||||||
{LEFT_PAREN, 13, `(`},
|
{LEFT_PAREN, 13, `(`},
|
||||||
{IDENTIFIER, 14, `rate`},
|
{IDENTIFIER, 14, `rate`},
|
||||||
|
|
|
@ -191,7 +191,6 @@ type Appender interface {
|
||||||
// Rollback rolls back all modifications made in the appender so far.
|
// Rollback rolls back all modifications made in the appender so far.
|
||||||
// Appender has to be discarded after rollback.
|
// Appender has to be discarded after rollback.
|
||||||
Rollback() error
|
Rollback() error
|
||||||
|
|
||||||
ExemplarAppender
|
ExemplarAppender
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -252,7 +252,7 @@ func TestCheckpointNoTmpFolderAfterError(t *testing.T) {
|
||||||
// Walk the wal dir to make sure there are no tmp folder left behind after the error.
|
// Walk the wal dir to make sure there are no tmp folder left behind after the error.
|
||||||
err = filepath.Walk(w.Dir(), func(path string, info os.FileInfo, err error) error {
|
err = filepath.Walk(w.Dir(), func(path string, info os.FileInfo, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "access err %q: %v\n", path, err)
|
return errors.Wrapf(err, "access err %q: %v", path, err)
|
||||||
}
|
}
|
||||||
if info.IsDir() && strings.HasSuffix(info.Name(), ".tmp") {
|
if info.IsDir() && strings.HasSuffix(info.Name(), ".tmp") {
|
||||||
return fmt.Errorf("wal dir contains temporary folder:%s", info.Name())
|
return fmt.Errorf("wal dir contains temporary folder:%s", info.Name())
|
||||||
|
|
|
@ -50,7 +50,6 @@ type WriteTo interface {
|
||||||
// Once returned, the WAL Watcher will not attempt to pass that data again.
|
// Once returned, the WAL Watcher will not attempt to pass that data again.
|
||||||
Append([]record.RefSample) bool
|
Append([]record.RefSample) bool
|
||||||
AppendExemplars([]record.RefExemplar) bool
|
AppendExemplars([]record.RefExemplar) bool
|
||||||
|
|
||||||
StoreSeries([]record.RefSeries, int)
|
StoreSeries([]record.RefSeries, int)
|
||||||
|
|
||||||
// Next two methods are intended for garbage-collection: first we call
|
// Next two methods are intended for garbage-collection: first we call
|
||||||
|
|
|
@ -23,7 +23,6 @@ import (
|
||||||
|
|
||||||
// Statfs returns the file system type (Unix only)
|
// Statfs returns the file system type (Unix only)
|
||||||
func Statfs(path string) string {
|
func Statfs(path string) string {
|
||||||
|
|
||||||
// Types of file systems that may be returned by `statfs`
|
// Types of file systems that may be returned by `statfs`
|
||||||
fsTypes := map[int32]string{
|
fsTypes := map[int32]string{
|
||||||
0xadf5: "ADFS_SUPER_MAGIC",
|
0xadf5: "ADFS_SUPER_MAGIC",
|
||||||
|
|
|
@ -23,7 +23,6 @@ import (
|
||||||
|
|
||||||
// Statfs returns the file system type (Unix only)
|
// Statfs returns the file system type (Unix only)
|
||||||
func Statfs(path string) string {
|
func Statfs(path string) string {
|
||||||
|
|
||||||
// Types of file systems that may be returned by `statfs`
|
// Types of file systems that may be returned by `statfs`
|
||||||
fsTypes := map[uint32]string{
|
fsTypes := map[uint32]string{
|
||||||
0xadf5: "ADFS_SUPER_MAGIC",
|
0xadf5: "ADFS_SUPER_MAGIC",
|
||||||
|
|
|
@ -150,7 +150,6 @@ type TSDBAdminStats interface {
|
||||||
CleanTombstones() error
|
CleanTombstones() error
|
||||||
Delete(mint, maxt int64, ms ...*labels.Matcher) error
|
Delete(mint, maxt int64, ms ...*labels.Matcher) error
|
||||||
Snapshot(dir string, withHead bool) error
|
Snapshot(dir string, withHead bool) error
|
||||||
|
|
||||||
Stats(statsByLabelName string) (*tsdb.Stats, error)
|
Stats(statsByLabelName string) (*tsdb.Stats, error)
|
||||||
WALReplayStatus() (tsdb.WALReplayStatus, error)
|
WALReplayStatus() (tsdb.WALReplayStatus, error)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue