Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
hush-hush committed Nov 24, 2022
1 parent 57ee25b commit 021ffb2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ linters-settings:
errcheck:
# Disable warnings for `fmt` and `log` packages. Also ignore `Write` functions from `net/http` package.
# Disable warnings for select Windows functions
ignore: fmt:.*,github.com/DataDog/datadog-agent/pkg/util/log:.*,github.com/DataDog/datadog-agent/comp/core/log:.*,net/http:Write,github.com/DataDog/datadog-agent/pkg/trace/metrics:.*,github.com/DataDog/datadog-agent/pkg/collector/corechecks:Warnf?,golang.org/x/sys/windows:(CloseHandle|FreeLibrary|FreeSid|RegCloseKey|SetEvent),syscall:CloseHandle,golang.org/x/sys/windows/svc/mgr:Disconnect,golang.org/x/sys/windows/svc/debug:(Close|Error|Info|Warning),github.com/lxn/walk:Dispose
ignore: fmt:.*,github.com/DataDog/datadog-agent/pkg/util/log:.*,github.com/DataDog/datadog-agent/comp/core/log:.*,net/http:Write,github.com/DataDog/datadog-agent/pkg/trace/metrics:.*,github.com/DataDog/datadog-agent/pkg/collector/corechecks:Warnf?,golang.org/x/sys/windows:(CloseHandle|FreeLibrary|FreeSid|RegCloseKey|SetEvent),syscall:CloseHandle,golang.org/x/sys/windows/svc/mgr:Disconnect,golang.org/x/sys/windows/svc/debug:(Close|Error|Info|Warning),github.com/lxn/walk:Dispose,github.com/DataDog/datadog-agent/comp/core/flare/helpers:(AddFile.*|CopyDir.*|CopyFile.*)
staticcheck:
go: "1.17"
checks: ["all",
Expand Down
10 changes: 1 addition & 9 deletions pkg/flare/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ import (
"gopkg.in/yaml.v2"
)

const (
// Maximum size for the root directory name
directoryNameMaxSize = 32
)

var (
pprofURL = fmt.Sprintf("http://127.0.0.1:%s/debug/pprof/goroutine?debug=2",
config.Datadog.GetString("expvar_port"))
Expand All @@ -51,9 +46,6 @@ var (

// Match .yaml and .yml to ship configuration files in the flare.
cnfFileExtRx = regexp.MustCompile(`(?i)\.ya?ml`)

// Filter to clean the directory name from invalid file name characters
directoryNameFilter = regexp.MustCompile(`[^a-zA-Z0-9_-]+`)
)

// SearchPaths is just an alias for a map of strings
Expand Down Expand Up @@ -188,7 +180,7 @@ func createArchive(fb flarehelpers.FlareBuilder, confSearchPaths SearchPaths, lo
fb.CopyFile(filepath.Join(config.FileUsedDir(), "install_info"))

getConfigFiles(fb, confSearchPaths)
getExpVar(fb)
getExpVar(fb) //nolint:errcheck
getWindowsData(fb)

if config.Datadog.GetBool("telemetry.enabled") {
Expand Down
12 changes: 6 additions & 6 deletions pkg/flare/archive_dca.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ func createDCAArchive(fb flarehelpers.FlareBuilder, local bool, confSearchPaths

getLogFiles(fb, logFilePath)
getConfigFiles(fb, confSearchPaths)
getClusterAgentConfigCheck(fb)
getExpVar(fb)
getMetadataMap(fb)
getClusterAgentClusterChecks(fb)
getClusterAgentDiagnose(fb)
getClusterAgentConfigCheck(fb) //nolint:errcheck
getExpVar(fb) //nolint:errcheck
getMetadataMap(fb) //nolint:errcheck
getClusterAgentClusterChecks(fb) //nolint:errcheck
getClusterAgentDiagnose(fb) //nolint:errcheck
fb.AddFileFromFunc("envvars.log", getEnvVars)
fb.AddFileFromFunc("telemetry.log", QueryDCAMetrics)

if config.Datadog.GetBool("external_metrics_provider.enabled") {
getHPAStatus(fb)
getHPAStatus(fb) //nolint:errcheck
}
}

Expand Down
18 changes: 9 additions & 9 deletions pkg/flare/archive_security.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ func createSecurityAgentArchive(fb flarehelpers.FlareBuilder, local bool, logFil

getLogFiles(fb, logFilePath)
getConfigFiles(fb, SearchPaths{})
getComplianceFiles(fb)
getRuntimeFiles(fb)
getExpVar(fb)
getComplianceFiles(fb) //nolint:errcheck
getRuntimeFiles(fb) //nolint:errcheck
getExpVar(fb) //nolint:errcheck
fb.AddFileFromFunc("envvars.log", getEnvVars)
getLinuxKernelSymbols(fb)
getLinuxPid1MountInfo(fb)
getLinuxDmesg(fb)
getLinuxKprobeEvents(fb)
getLinuxTracingAvailableEvents(fb)
getLinuxTracingAvailableFilterFunctions(fb)
getLinuxKernelSymbols(fb) //nolint:errcheck
getLinuxPid1MountInfo(fb) //nolint:errcheck
getLinuxDmesg(fb) //nolint:errcheck
getLinuxKprobeEvents(fb) //nolint:errcheck
getLinuxTracingAvailableEvents(fb) //nolint:errcheck
getLinuxTracingAvailableFilterFunctions(fb) //nolint:errcheck
}

func getComplianceFiles(fb flarehelpers.FlareBuilder) error {
Expand Down

0 comments on commit 021ffb2

Please sign in to comment.