Skip to content

feat: make gathered log directory configurable#29

Open
bdegeeter wants to merge 1 commit into
spectrocloud:masterfrom
bdegeeter:pr/configurable-log-dir
Open

feat: make gathered log directory configurable#29
bdegeeter wants to merge 1 commit into
spectrocloud:masterfrom
bdegeeter:pr/configurable-log-dir

Conversation

@bdegeeter

Copy link
Copy Markdown
Contributor

Summary

Allow callers to configure where gathered machine logs are written.

matcher.LogDir remains a public package variable and defaults to logs, preserving the existing behavior for callers that do not configure it.

Changes

  • Add the public matcher.LogDir configuration variable.
  • Support absolute and nested log directories.
  • Create missing parent directories with os.MkdirAll.
  • Construct destination paths with filepath.Join.
  • Preserve the basename of the remote log file.
  • Report directory and file creation failures without dereferencing a nil file.
  • Avoid closing the SCP client more than once.

Motivation

CI environments commonly require logs to be written directly into a designated artifact directory. Previously, gathered logs were always written to a hard-coded logs directory.

Compatibility

The default remains logs, so existing users retain the current behavior unless they explicitly change matcher.LogDir.

Validation

The following checks pass with Go 1.24.2:

  • go test ./...
  • go test -race ./...
  • go vet ./...
  • git diff --check

Unit tests cover:

  • The default directory.
  • Absolute and nested directories.
  • Preserved filenames.
  • Invalid directory paths.
  • Invalid file destinations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant