Skip to content

Remove global console config variables#162

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/remove-console-config-variables
Draft

Remove global console config variables#162
Copilot wants to merge 2 commits intomasterfrom
copilot/remove-console-config-variables

Conversation

Copy link

Copilot AI commented Feb 5, 2026

Removes three global variables from pkg/csconfig: CONSOLE_CONFIGS, CONSOLE_CONFIGS_HELP, and DefaultConsoleConfigFilePath.

Changes

  • pkg/csconfig/console.go: Removed variable declarations
  • pkg/csconfig/api.go: Replaced DefaultConsoleConfigFilePath with DefaultConfigPath("console.yaml")
  • cmd/crowdsec-cli/cliconsole/console.go: Replaced array/map references with inline definitions in optionFilterEnable, optionFilterDisable, newEnableCmd, newDisableCmd, and enroll
  • cmd/crowdsec-cli/cliconsole/console_table.go: Refactored to use structured slice with embedded descriptions

Before:

var CONSOLE_CONFIGS = []string{SEND_CUSTOM_SCENARIOS, SEND_MANUAL_SCENARIOS, ...}
var CONSOLE_CONFIGS_HELP = map[string]string{...}

// Usage
for _, option := range csconfig.CONSOLE_CONFIGS {
    // ...
    description := csconfig.CONSOLE_CONFIGS_HELP[option]
}

After:

validOptions := []string{
    csconfig.SEND_CUSTOM_SCENARIOS,
    csconfig.SEND_MANUAL_SCENARIOS,
    // ...
}

Console constants (SEND_CUSTOM_SCENARIOS, etc.) remain unchanged.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@semanticdiff-com
Copy link

semanticdiff-com bot commented Feb 5, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  pkg/csconfig/api.go  20% smaller
  cmd/crowdsec-cli/cliconsole/console_table.go  20% smaller
  cmd/crowdsec-cli/cliconsole/console.go  10% smaller
  pkg/csconfig/console.go  0% smaller

…gFilePath variables

Replaced global variables with inline definitions to avoid global state:
- Replaced CONSOLE_CONFIGS array with inline slice definitions where needed
- Replaced CONSOLE_CONFIGS_HELP map with inline map or direct string literals
- Replaced DefaultConsoleConfigFilePath with inline DefaultConfigPath("console.yaml") calls
- Updated console_table.go to use a structured approach with embedded descriptions
- Fixed line length linting issues by extracting allOptions variable in enable/disable commands

Co-authored-by: mmetc <92726601+mmetc@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove variables related to console configurations Remove global console config variables Feb 5, 2026
Copilot AI requested a review from mmetc February 5, 2026 16:12
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.

2 participants