diff --git a/.editorconfig b/.editorconfig index 13e98bb9..ac1d1b1a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,6 +11,9 @@ tab_width = 4 indent_style = space indent_size = 4 +[renovate.json] +indent_size = 2 + [*.{yml,yaml}] indent_style = space indent_size = 2 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 75a3e680..9e3b2e84 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -8,11 +8,9 @@ on: - master - next - main + - "0.*" + - "1.*" pull_request: - branches: - - master - - next - - main env: VERSION_PROMU: '0.14.0' diff --git a/.golangci.yaml b/.golangci.yaml index d976070c..44bf3c0d 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -29,6 +29,27 @@ linters: msg: use golang.org/x/sys/windows instead of syscall - pattern: ^windows\.NewLazyDLL$ msg: use NewLazySystemDLL instead NewLazyDLL + goheader: + values: + const: + COMPANY: The Prometheus Authors + template: |- + SPDX-License-Identifier: Apache-2.0 + + Copyright {{ YEAR }} {{ COMPANY }} + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + gomoddirectives: + toolchain-forbidden: true gosec: excludes: - G101 diff --git a/.run/all.run.xml b/.run/all.run.xml index 7773cac1..8c52f200 100644 --- a/.run/all.run.xml +++ b/.run/all.run.xml @@ -1,3 +1,20 @@ + + @@ -10,4 +27,4 @@ - \ No newline at end of file + diff --git a/cmd/windows_exporter/0_service.go b/cmd/windows_exporter/0_service.go index 9707a29b..a2260370 100644 --- a/cmd/windows_exporter/0_service.go +++ b/cmd/windows_exporter/0_service.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 +// // Copyright 2025 The Prometheus Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,6 +13,21 @@ // See the License for the specific language governing permissions and // limitations under the License. +// Copyright 2025 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build windows + package main import ( diff --git a/cmd/windows_exporter/doc.go b/cmd/windows_exporter/doc.go index 244aa7fa..c3155c2b 100644 --- a/cmd/windows_exporter/doc.go +++ b/cmd/windows_exporter/doc.go @@ -1,4 +1,6 @@ -// Copyright 2024 The Prometheus Authors +// SPDX-License-Identifier: Apache-2.0 +// +// Copyright 2025 The Prometheus Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/cmd/windows_exporter/main.go b/cmd/windows_exporter/main.go index 5c549d7f..146aaa03 100644 --- a/cmd/windows_exporter/main.go +++ b/cmd/windows_exporter/main.go @@ -1,4 +1,6 @@ -// Copyright 2024 The Prometheus Authors +// SPDX-License-Identifier: Apache-2.0 +// +// Copyright 2025 The Prometheus Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -144,7 +146,7 @@ func run(ctx context.Context, args []string) int { logger.LogAttrs(ctx, slog.LevelDebug, "logging has Started") if configFile != nil && *configFile != "" { - logger.InfoContext(ctx, "using configuration file: "+*configFile) + logger.LogAttrs(ctx, slog.LevelInfo, "using configuration file: "+*configFile) } if err = setPriorityWindows(ctx, logger, os.Getpid(), *processPriority); err != nil { @@ -175,7 +177,7 @@ func run(ctx context.Context, args []string) int { } } - logCurrentUser(logger) + logCurrentUser(ctx, logger) logger.InfoContext(ctx, "Enabled collectors: "+strings.Join(enabledCollectorList, ", ")) @@ -240,27 +242,34 @@ func run(ctx context.Context, args []string) int { ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() - _ = server.Shutdown(ctx) //nolint:contextcheck // create a new context for server shutdown - - logger.LogAttrs(ctx, slog.LevelInfo, "windows_exporter has shut down") //nolint:contextcheck + //nolint:contextcheck // create a new context for server shutdown + if err = server.Shutdown(ctx); err != nil { + //nolint:contextcheck + logger.LogAttrs(ctx, slog.LevelError, "Failed to shutdown windows_exporter", + slog.Any("err", err), + ) + } else { + //nolint:contextcheck + logger.LogAttrs(ctx, slog.LevelInfo, "windows_exporter has shut down") + } return 0 } -func logCurrentUser(logger *slog.Logger) { +func logCurrentUser(ctx context.Context, logger *slog.Logger) { u, err := user.Current() if err != nil { - logger.Warn("Unable to determine which user is running this exporter. More info: https://github.com/golang/go/issues/37348", + logger.LogAttrs(ctx, slog.LevelWarn, "Unable to determine which user is running this exporter. More info: https://github.com/golang/go/issues/37348", slog.Any("err", err), ) return } - logger.Info("Running as " + u.Username) + logger.LogAttrs(ctx, slog.LevelInfo, "Running as "+u.Username) if strings.Contains(u.Username, "ContainerAdministrator") || strings.Contains(u.Username, "ContainerUser") { - logger.Warn("Running as a preconfigured Windows Container user. This may mean you do not have Windows HostProcess containers configured correctly and some functionality will not work as expected.") + logger.LogAttrs(ctx, slog.LevelWarn, "Running as a preconfigured Windows Container user. This may mean you do not have Windows HostProcess containers configured correctly and some functionality will not work as expected.") } } diff --git a/cmd/windows_exporter/main_test.go b/cmd/windows_exporter/main_test.go index af81f454..938f0eb9 100644 --- a/cmd/windows_exporter/main_test.go +++ b/cmd/windows_exporter/main_test.go @@ -1,4 +1,6 @@ -// Copyright 2024 The Prometheus Authors +// SPDX-License-Identifier: Apache-2.0 +// +// Copyright 2025 The Prometheus Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/installer/files.wxs b/installer/files.wxs index e011b6c6..ee668a26 100644 --- a/installer/files.wxs +++ b/installer/files.wxs @@ -1,5 +1,7 @@