Skip to content

Commit

Permalink
[ASCII-2529] Prepare golangci-lint 1.60.3 upgrade (DataDog#31216)
Browse files Browse the repository at this point in the history
  • Loading branch information
ogaca-dd authored Nov 19, 2024
1 parent 2063e4b commit cab236e
Show file tree
Hide file tree
Showing 41 changed files with 134 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ func assertStat(t assert.TestingT, svc model.Service) {
// https://github.com/shirou/gopsutil/commit/aa0b73dc6d5669de5bc9483c0655b1f9446317a9).
//
// This is due to an inherent race since the code in BootTimeWithContext
// substracts the uptime of the host from the current time, and there can be
// subtracts the uptime of the host from the current time, and there can be
// in theory an unbounded amount of time between the read of /proc/uptime
// and the retrieval of the current time. Allow a 10 second diff as a
// reasonable value.
Expand Down
2 changes: 1 addition & 1 deletion pkg/dynamicinstrumentation/codegen/codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func generateHeaderText(param ditypes.Parameter, out io.Writer) error {
return generateSliceHeader(&param, out)
} else if reflect.Kind(param.Kind) == reflect.String {
return generateStringHeader(&param, out)
} else {
} else { //nolint:revive // TODO
tmplt, err := resolveHeaderTemplate(&param)
if err != nil {
return err
Expand Down
6 changes: 3 additions & 3 deletions pkg/dynamicinstrumentation/di.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ func newGoDIStats() GoDIStats {
}
}

type OfflineOptions struct {
type OfflineOptions struct { //nolint:revive // TODO
Offline bool
ProbesFilePath string
SnapshotOutput string
DiagnosticOutput string
}

type ReaderWriterOptions struct {
type ReaderWriterOptions struct { //nolint:revive // TODO
CustomReaderWriters bool
SnapshotWriter io.Writer
DiagnosticWriter io.Writer
Expand Down Expand Up @@ -155,7 +155,7 @@ func RunDynamicInstrumentation(opts *DIOptions) (*GoDI, error) {
return goDI, nil
}

func (goDI *GoDI) printSnapshot(event *ditypes.DIEvent) {
func (goDI *GoDI) printSnapshot(event *ditypes.DIEvent) { //nolint:unused // TODO
if event == nil {
return
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/dynamicinstrumentation/diagnostics/diagnostics.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (m *DiagnosticManager) update(id probeInstanceID, d *ditypes.DiagnosticUplo
}
}

func StopGlobalDiagnostics() {
func StopGlobalDiagnostics() { //nolint:revive // TODO
close(Diagnostics.Updates)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/dynamicinstrumentation/diconfig/file_config_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/DataDog/datadog-agent/pkg/util/log"
)

func NewFileConfigManager(configFile string) (*ReaderConfigManager, func(), error) {
func NewFileConfigManager(configFile string) (*ReaderConfigManager, func(), error) { //nolint:revive // TODO
stopChan := make(chan bool)
stop := func() {
stopChan <- true
Expand All @@ -35,7 +35,7 @@ func NewFileConfigManager(configFile string) (*ReaderConfigManager, func(), erro
for {
select {
case rawBytes := <-updateChan:
cm.ConfigWriter.Write(rawBytes)
cm.ConfigWriter.Write(rawBytes) //nolint:errcheck // TODO
case <-stopChan:
log.Info("stopping file config manager")
fw.Stop()
Expand Down
20 changes: 10 additions & 10 deletions pkg/dynamicinstrumentation/diconfig/mem_config_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ type ReaderConfigManager struct {
state ditypes.DIProcs
}

type readerConfigCallback func(configsByService)
type readerConfigCallback func(configsByService) //nolint:unused // TODO
type configsByService = map[ditypes.ServiceName]map[ditypes.ProbeID]rcConfig

func NewReaderConfigManager() (*ReaderConfigManager, error) {
func NewReaderConfigManager() (*ReaderConfigManager, error) { //nolint:revive // TODO
cm := &ReaderConfigManager{
callback: applyConfigUpdate,
state: ditypes.NewDIProcs(),
Expand All @@ -55,11 +55,11 @@ func NewReaderConfigManager() (*ReaderConfigManager, error) {
return cm, nil
}

func (cm *ReaderConfigManager) GetProcInfos() ditypes.DIProcs {
func (cm *ReaderConfigManager) GetProcInfos() ditypes.DIProcs { //nolint:revive // TODO
return cm.state
}

func (cm *ReaderConfigManager) Stop() {
func (cm *ReaderConfigManager) Stop() { //nolint:revive // TODO
cm.ConfigWriter.Stop()
cm.procTracker.Stop()
}
Expand Down Expand Up @@ -131,17 +131,17 @@ func (cm *ReaderConfigManager) updateServiceConfigs(configs configsByService) {
}
}

type ConfigWriter struct {
type ConfigWriter struct { //nolint:revive // TODO
io.Writer
updateChannel chan ([]byte)
Processes map[ditypes.PID]*ditypes.ProcessInfo
configCallback ConfigWriterCallback
stopChannel chan (bool)
}

type ConfigWriterCallback func(configsByService)
type ConfigWriterCallback func(configsByService) //nolint:revive // TODO

func NewConfigWriter(onConfigUpdate ConfigWriterCallback) *ConfigWriter {
func NewConfigWriter(onConfigUpdate ConfigWriterCallback) *ConfigWriter { //nolint:revive // TODO
return &ConfigWriter{
updateChannel: make(chan []byte, 1),
configCallback: onConfigUpdate,
Expand All @@ -154,7 +154,7 @@ func (r *ConfigWriter) Write(p []byte) (n int, e error) {
return 0, nil
}

func (r *ConfigWriter) Start() error {
func (r *ConfigWriter) Start() error { //nolint:revive // TODO
go func() {
configUpdateLoop:
for {
Expand All @@ -175,14 +175,14 @@ func (r *ConfigWriter) Start() error {
return nil
}

func (cu *ConfigWriter) Stop() {
func (cu *ConfigWriter) Stop() { //nolint:revive // TODO
cu.stopChannel <- true
}

// UpdateProcesses is the callback interface that ConfigWriter uses to consume the map of ProcessInfo's
// such that it's used whenever there's an update to the state of known service processes on the machine.
// It simply overwrites the previous state of known service processes with the new one
func (cu *ConfigWriter) UpdateProcesses(procs ditypes.DIProcs) {
func (cu *ConfigWriter) UpdateProcesses(procs ditypes.DIProcs) { //nolint:revive // TODO
current := procs
old := cu.Processes
if !reflect.DeepEqual(current, old) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/dynamicinstrumentation/ebpf/ebpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func AttachBPFUprobe(procInfo *ditypes.ProcessInfo, probe *ditypes.Probe) error
}

// CompileBPFProgram compiles the code for a single probe associated with the process given by procInfo
func CompileBPFProgram(procInfo *ditypes.ProcessInfo, probe *ditypes.Probe) error {
func CompileBPFProgram(procInfo *ditypes.ProcessInfo, probe *ditypes.Probe) error { //nolint:revive // TODO
f := func(in io.Reader, out io.Writer) error {
fileContents, err := io.ReadAll(in)
if err != nil {
Expand Down Expand Up @@ -171,5 +171,5 @@ func getCFlags(config *ddebpf.Config) []string {
}

const (
compilationStepTimeout = 60 * time.Second
compilationStepTimeout = 60 * time.Second //nolint:unused // TODO
)
4 changes: 2 additions & 2 deletions pkg/dynamicinstrumentation/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Module struct {
}

// NewModule creates a new dynamic instrumentation system probe module
func NewModule(config *Config) (*Module, error) {
func NewModule(config *Config) (*Module, error) { //nolint:revive // TODO
godi, err := di.RunDynamicInstrumentation(&di.DIOptions{
RateLimitPerProbePerSecond: 1.0,
OfflineOptions: di.OfflineOptions{
Expand Down Expand Up @@ -65,7 +65,7 @@ func (m *Module) GetStats() map[string]interface{} {
// Register creates a health check endpoint for the dynamic instrumentation module
func (m *Module) Register(httpMux *module.Router) error {
httpMux.HandleFunc("/check", utils.WithConcurrencyLimit(utils.DefaultMaxConcurrentRequests,
func(w http.ResponseWriter, req *http.Request) {
func(w http.ResponseWriter, req *http.Request) { //nolint:revive // TODO
stats := []string{}
utils.WriteAsJSON(w, stats)
}))
Expand Down
6 changes: 3 additions & 3 deletions pkg/dynamicinstrumentation/testutil/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var basicCaptures = fixtures{
// "github.com/DataDog/datadog-agent/pkg/dynamicinstrumentation/testutil/sample.test_single_float64": {"x": capturedValue("float", "-1.646464")},
}

var multiParamCaptures = fixtures{
var multiParamCaptures = fixtures{ //nolint:unused // TODO
"github.com/DataDog/datadog-agent/pkg/dynamicinstrumentation/testutil/sample.test_multiple_simple_params": {
"a": capturedValue("bool", "false"),
"b": capturedValue("uint8", "42"),
Expand Down Expand Up @@ -241,14 +241,14 @@ var structCaptures = fixtures{

// TODO: this doesn't work yet:
// could not determine locations of variables from debug information could not inspect param "x" on function: no location field in parameter entry
var genericCaptures = fixtures{
var genericCaptures = fixtures{ //nolint:unused // TODO
"github.com/DataDog/datadog-agent/pkg/dynamicinstrumentation/testutil/sample.typeWithGenerics[go.shape.string].Guess": {"value": capturedValue("string", "generics work")},
}

// TODO: check how map entries should be represented, likely that entries have key / value pair fields
// instead of having the keys hardcoded as string field names
// maps are no supported at the moment so this fails anyway
var mapCaptures = fixtures{
var mapCaptures = fixtures{ //nolint:unused // TODO
"github.com/DataDog/datadog-agent/pkg/dynamicinstrumentation/testutil/sample.test_map_string_to_int": {"m": {Type: "map", Fields: fieldMap{
"foo": capturedValue("int", "1"),
"bar": capturedValue("int", "2"),
Expand Down
10 changes: 5 additions & 5 deletions pkg/dynamicinstrumentation/uploader/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ import (
"github.com/kr/pretty"
)

type WriterSerializer[T any] struct {
type WriterSerializer[T any] struct { //nolint:revive // TODO
output io.Writer
mu sync.Mutex
}

func NewWriterLogSerializer(writer io.Writer) (*WriterSerializer[ditypes.SnapshotUpload], error) {
func NewWriterLogSerializer(writer io.Writer) (*WriterSerializer[ditypes.SnapshotUpload], error) { //nolint:revive // TODO
if writer == nil {
return nil, errors.New("nil writer for creating log serializer")
}
return NewWriterSerializer[ditypes.SnapshotUpload](writer)
}

func NewWriterDiagnosticSerializer(dm *diagnostics.DiagnosticManager, writer io.Writer) (*WriterSerializer[ditypes.DiagnosticUpload], error) {
func NewWriterDiagnosticSerializer(dm *diagnostics.DiagnosticManager, writer io.Writer) (*WriterSerializer[ditypes.DiagnosticUpload], error) { //nolint:revive // TODO
if writer == nil {
return nil, errors.New("nil writer for creating diagnostic serializer")
}
Expand All @@ -51,7 +51,7 @@ func NewWriterDiagnosticSerializer(dm *diagnostics.DiagnosticManager, writer io.
return ds, nil
}

func NewWriterSerializer[T any](writer io.Writer) (*WriterSerializer[T], error) {
func NewWriterSerializer[T any](writer io.Writer) (*WriterSerializer[T], error) { //nolint:revive // TODO
if writer == nil {
return nil, errors.New("nil writer for creating serializer")
}
Expand All @@ -60,7 +60,7 @@ func NewWriterSerializer[T any](writer io.Writer) (*WriterSerializer[T], error)
}, nil
}

func (s *WriterSerializer[T]) Enqueue(item *T) error {
func (s *WriterSerializer[T]) Enqueue(item *T) error { //nolint:revive // TODO
s.mu.Lock()
defer s.mu.Unlock()
bs, err := json.Marshal(item)
Expand Down
4 changes: 2 additions & 2 deletions pkg/dynamicinstrumentation/util/file_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

//go:build linux_bpf

package util
package util //nolint:revive // TODO

import (
"os"
Expand Down Expand Up @@ -70,6 +70,6 @@ func (fw *FileWatcher) Watch() (<-chan []byte, error) {
return updateChan, nil
}

func (fw *FileWatcher) Stop() {
func (fw *FileWatcher) Stop() { //nolint:revive // TODO
fw.stop <- true
}
2 changes: 1 addition & 1 deletion pkg/ebpf/btf.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ type returnBTF struct {
moduleLoadFunc kernelModuleBTFLoadFunc
}

type BTFResultMetadata struct {
type BTFResultMetadata struct { //nolint:revive // TODO
// numLoadAttempts is how many times the loader has been invoked (doesn't include cached requests)
numLoadAttempts int
// loaderUsed the name of the loader that was used to get the BTF data
Expand Down
2 changes: 1 addition & 1 deletion pkg/ebpf/maps/generic_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

const defaultBatchSize = 100

var ErrBatchAPINotSupported = errors.New("batch API not supported for this map: check whether key is fixed-size, kernel supports batch API and if this map is not per-cpu")
var ErrBatchAPINotSupported = errors.New("batch API not supported for this map: check whether key is fixed-size, kernel supports batch API and if this map is not per-cpu") //nolint:revive // TODO

// BatchAPISupported returns true if the kernel supports the batch API for maps
var BatchAPISupported = funcs.MemoizeNoError(func() bool {
Expand Down
16 changes: 8 additions & 8 deletions pkg/ebpf/names/names.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

//go:build linux_bpf

// Package to provide types for eBPF resource names
// Package names provide types for eBPF resource names
package names

import (
Expand All @@ -21,11 +21,11 @@ type MapName struct {
n string
}

func (m *MapName) Name() string {
func (m *MapName) Name() string { //nolint:revive // TODO
return m.n
}

func NewMapNameFromManagerMap(m *manager.Map) MapName {
func NewMapNameFromManagerMap(m *manager.Map) MapName { //nolint:revive // TODO
return MapName{n: m.Name}
}

Expand All @@ -36,23 +36,23 @@ type ProgramName struct {
n string
}

func (p *ProgramName) Name() string {
func (p *ProgramName) Name() string { //nolint:revive // TODO
return p.n
}

func NewProgramNameFromProgramSpec(spec *ebpf.ProgramSpec) ProgramName {
func NewProgramNameFromProgramSpec(spec *ebpf.ProgramSpec) ProgramName { //nolint:revive // TODO
return ProgramName{n: spec.Name}
}

type ModuleName struct {
type ModuleName struct { //nolint:revive // TODO
n string
}

func (mn *ModuleName) Name() string {
func (mn *ModuleName) Name() string { //nolint:revive // TODO
return mn.n
}

func NewModuleName(mn string) ModuleName {
func NewModuleName(mn string) ModuleName { //nolint:revive // TODO
return ModuleName{n: mn}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/ebpf/telemetry/errors_telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ func (e *ebpfTelemetry) fill(maps []names.MapName, mn names.ModuleName, mapErrMa

if _, ok := e.mapErrMapsByModule[mn]; ok {
return fmt.Errorf("eBPF map for map-operation errors for module %s already exists", mn.Name())
} else {
} else { //nolint:revive // TODO
e.mapErrMapsByModule[mn] = mapErrMap
}

if _, ok := e.helperErrMapsByModule[mn]; ok {
return fmt.Errorf("eBPF map for helper-operation errors for module %s already exists", mn.Name())
} else {
} else { //nolint:revive // TODO
e.helperErrMapsByModule[mn] = helperErrMap
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/ebpf/uprobes/attacher.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ type FileRegistry interface {
// AttachCallback is a callback that is called whenever a probe is attached successfully
type AttachCallback func(*manager.Probe, *utils.FilePath)

var NopOnAttachCallback AttachCallback = nil
var NopOnAttachCallback AttachCallback = nil //nolint:revive // TODO

// UprobeAttacher is a struct that handles the attachment of uprobes to processes and libraries
type UprobeAttacher struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ebpf/uprobes/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type MockFileRegistry struct {
}

// Register is a mock implementation of the FileRegistry.Register method.
func (m *MockFileRegistry) Register(namespacedPath string, pid uint32, activationCB, deactivationCB, alreadyRegistered utils.Callback) error {
func (m *MockFileRegistry) Register(namespacedPath string, pid uint32, activationCB, deactivationCB, alreadyRegistered utils.Callback) error { //nolint:revive // TODO
args := m.Called(namespacedPath, pid, activationCB, deactivationCB)
return args.Error(0)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/gpu/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (p *Probe) initRCGPU(cfg *config.Config) error {

func (p *Probe) initCOREGPU(cfg *config.Config) error {
asset := getAssetName("gpu", cfg.BPFDebug)
var err error
var err error //nolint:gosimple // TODO
err = ddebpf.LoadCOREAsset(asset, func(ar bytecode.AssetReader, o manager.Options) error {
return p.setupManager(ar, o)
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/gpu/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type streamKey struct {

// streamData contains kernel spans and allocations for a stream
type streamData struct {
key streamKey
key streamKey //nolint:unused // TODO
spans []*kernelSpan
allocations []*memoryAllocation
}
Expand Down
Loading

0 comments on commit cab236e

Please sign in to comment.