Skip to content

Commit 197fd54

Browse files
committed
fix lint
1 parent bc0dd58 commit 197fd54

File tree

4 files changed

+9
-29
lines changed

4 files changed

+9
-29
lines changed

cmd/opampsupervisor/main_windows.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ import (
99
"errors"
1010
"fmt"
1111

12-
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/opampsupervisor/supervisor"
1312
"golang.org/x/sys/windows"
1413
"golang.org/x/sys/windows/svc"
14+
15+
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/opampsupervisor/supervisor"
1516
)
1617

1718
var (
@@ -35,7 +36,7 @@ func run() error {
3536
// this means that the process is not running as a service, so run interactively.
3637

3738
// deallocate console if we're not running as service
38-
if err := freeConsole(); err != nil {
39+
if err = freeConsole(); err != nil {
3940
return fmt.Errorf("free console: %w", err)
4041
}
4142
return runInteractive()

cmd/opampsupervisor/supervisor/commander/commander_windows.go

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ import (
1616
var (
1717
kernel32API = windows.NewLazySystemDLL("kernel32.dll")
1818

19-
ctrlEventProc = kernel32API.NewProc("GenerateConsoleCtrlEvent")
20-
allocConsoleProc = kernel32API.NewProc("AllocConsole")
21-
freeConsoleProc = kernel32API.NewProc("FreeConsole")
19+
ctrlEventProc = kernel32API.NewProc("GenerateConsoleCtrlEvent")
2220
)
2321

2422
func sendShutdownSignal(process *os.Process) error {
@@ -41,23 +39,3 @@ func sysProcAttrs() *syscall.SysProcAttr {
4139
CreationFlags: syscall.CREATE_NEW_PROCESS_GROUP,
4240
}
4341
}
44-
45-
func allocConsole() error {
46-
// windows services don't get created with a console
47-
// need to allocate a console in order to send CTRL_BREAK_EVENT to agent sub process
48-
ret, _, err := allocConsoleProc.Call()
49-
if ret == 0 {
50-
return err
51-
}
52-
return nil
53-
}
54-
55-
func freeConsole() error {
56-
// windows services don't run with console, so we want to clean it up
57-
// only keep console around while it is strictly necessary
58-
ret, _, err := freeConsoleProc.Call()
59-
if ret == 0 {
60-
return err
61-
}
62-
return nil
63-
}

cmd/opampsupervisor/supervisor/supervisor_windows.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (ws *windowsService) Execute(args []string, requests <-chan svc.ChangeReque
3838

3939
changes <- svc.Status{State: svc.StartPending}
4040
if err = ws.start(elog); err != nil {
41-
elog.Error(3, fmt.Sprintf("failed to start service: %v", err))
41+
_ = elog.Error(3, fmt.Sprintf("failed to start service: %v", err))
4242
return false, uint32(windows.ERROR_EXCEPTION_IN_SERVICE) // 1064: ERROR_EXCEPTION_IN_SERVICE
4343
}
4444
changes <- svc.Status{State: svc.Running, Accepts: svc.AcceptStop | svc.AcceptShutdown}
@@ -55,7 +55,7 @@ func (ws *windowsService) Execute(args []string, requests <-chan svc.ChangeReque
5555
return false, 0
5656

5757
default:
58-
elog.Error(3, fmt.Sprintf("unexpected service control request #%d", req.Cmd))
58+
_ = elog.Error(3, fmt.Sprintf("unexpected service control request #%d", req.Cmd))
5959
return false, uint32(windows.ERROR_INVALID_SERVICE_CONTROL) // 1052: ERROR_INVALID_SERVICE_CONTROL
6060
}
6161
}
@@ -126,7 +126,7 @@ func (w windowsEventLogCore) Check(ent zapcore.Entry, ce *zapcore.CheckedEntry)
126126
func (w windowsEventLogCore) Write(ent zapcore.Entry, fields []zapcore.Field) error {
127127
buf, err := w.encoder.EncodeEntry(ent, fields)
128128
if err != nil {
129-
w.elog.Warning(2, fmt.Sprintf("failed encoding log entry %v\r\n", err))
129+
_ = w.elog.Warning(2, fmt.Sprintf("failed encoding log entry %v\r\n", err))
130130
return err
131131
}
132132
msg := buf.String()

cmd/opampsupervisor/supervisor/supervisor_windows_service_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ import (
1212
"testing"
1313
"time"
1414

15-
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/opampsupervisor/supervisor/healthchecker"
1615
"github.com/stretchr/testify/require"
1716
"golang.org/x/sys/windows/svc"
1817
"golang.org/x/sys/windows/svc/mgr"
18+
19+
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/opampsupervisor/supervisor/healthchecker"
1920
)
2021

2122
const (

0 commit comments

Comments
 (0)