mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-23 13:16:36 +00:00
chore(deps): update golangci/golangci-lint-action action to v7 (#1976)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
@@ -26,13 +26,12 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
applicationID = "windows_exporter"
|
||||
|
||||
LocaleEnglish = "en-us"
|
||||
)
|
||||
|
||||
//nolint:gochecknoglobals
|
||||
var (
|
||||
applicationID = UTF16PtrFromString[*uint16]("windows_exporter")
|
||||
// DestinationOptionsTimeout is the key for the timeout option.
|
||||
//
|
||||
// https://github.com/microsoft/win32metadata/blob/527806d20d83d3abd43d16cd3fa8795d8deba343/generation/WinSDK/RecompiledIdlHeaders/um/mi.h#L7830
|
||||
@@ -99,21 +98,16 @@ type DestinationOptionsFT struct {
|
||||
GetInterval uintptr
|
||||
}
|
||||
|
||||
// Application_Initialize initializes the MI [Application].
|
||||
// ApplicationInitialize initializes the MI [Application].
|
||||
// It is recommended to have only one Application per process.
|
||||
//
|
||||
// https://learn.microsoft.com/en-us/windows/win32/api/mi/nf-mi-mi_application_initializev1
|
||||
func Application_Initialize() (*Application, error) {
|
||||
func ApplicationInitialize() (*Application, error) {
|
||||
application := &Application{}
|
||||
|
||||
applicationId, err := windows.UTF16PtrFromString(applicationID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
r0, _, err := procMIApplicationInitialize.Call(
|
||||
0,
|
||||
uintptr(unsafe.Pointer(applicationId)),
|
||||
uintptr(unsafe.Pointer(applicationID)),
|
||||
0,
|
||||
uintptr(unsafe.Pointer(application)),
|
||||
)
|
||||
@@ -129,7 +123,7 @@ func Application_Initialize() (*Application, error) {
|
||||
return application, nil
|
||||
}
|
||||
|
||||
// Close deinitializes the management infrastructure client API that was initialized through a call to Application_Initialize.
|
||||
// Close deinitializes the management infrastructure client API that was initialized through a call to ApplicationInitialize.
|
||||
//
|
||||
// https://learn.microsoft.com/en-us/windows/win32/api/mi/nf-mi-mi_application_close
|
||||
func (application *Application) Close() error {
|
||||
|
||||
@@ -164,29 +164,3 @@ func (instance *Instance) GetClassName() (string, error) {
|
||||
|
||||
return windows.UTF16PtrToString(classNameUTF16), nil
|
||||
}
|
||||
|
||||
func Instance_Print(instance *Instance) (string, error) {
|
||||
elementMap := map[string]any{}
|
||||
|
||||
properties := instance.classDecl.Properties()
|
||||
|
||||
count, err := instance.GetElementCount()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if count == 0 {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
for _, property := range properties {
|
||||
name := windows.UTF16PtrToString(property.Name)
|
||||
|
||||
element, _ := instance.GetElement(name)
|
||||
value, _ := element.GetValue()
|
||||
|
||||
elementMap[windows.UTF16PtrToString(property.Name)] = value
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%v", elementMap), nil
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
)
|
||||
|
||||
func Benchmark_MI_Query_Unmarshal(b *testing.B) {
|
||||
application, err := mi.Application_Initialize()
|
||||
application, err := mi.ApplicationInitialize()
|
||||
require.NoError(b, err)
|
||||
require.NotEmpty(b, application)
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ type win32Process struct {
|
||||
}
|
||||
|
||||
func Test_MI_Application_Initialize(t *testing.T) {
|
||||
application, err := mi.Application_Initialize()
|
||||
application, err := mi.ApplicationInitialize()
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, application)
|
||||
|
||||
@@ -37,7 +37,7 @@ func Test_MI_Application_Initialize(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_MI_Application_TestConnection(t *testing.T) {
|
||||
application, err := mi.Application_Initialize()
|
||||
application, err := mi.ApplicationInitialize()
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, application)
|
||||
|
||||
@@ -67,7 +67,7 @@ func Test_MI_Application_TestConnection(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_MI_Query(t *testing.T) {
|
||||
application, err := mi.Application_Initialize()
|
||||
application, err := mi.ApplicationInitialize()
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, application)
|
||||
|
||||
@@ -120,7 +120,7 @@ func Test_MI_Query(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_MI_QueryUnmarshal(t *testing.T) {
|
||||
application, err := mi.Application_Initialize()
|
||||
application, err := mi.ApplicationInitialize()
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, application)
|
||||
|
||||
@@ -155,7 +155,7 @@ func Test_MI_QueryUnmarshal(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_MI_EmptyQuery(t *testing.T) {
|
||||
application, err := mi.Application_Initialize()
|
||||
application, err := mi.ApplicationInitialize()
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, application)
|
||||
|
||||
@@ -194,7 +194,7 @@ func Test_MI_EmptyQuery(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_MI_Query_Unmarshal(t *testing.T) {
|
||||
application, err := mi.Application_Initialize()
|
||||
application, err := mi.ApplicationInitialize()
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, application)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user