Skip to content

Remove global config state from csconfig package#161

Draft
Copilot wants to merge 7 commits intomasterfrom
copilot/remove-global-config-variable
Draft

Remove global config state from csconfig package#161
Copilot wants to merge 7 commits intomasterfrom
copilot/remove-global-config-variable

Conversation

Copy link

Copilot AI commented Feb 5, 2026

Removes globalConfig variable and GetConfig() function from pkg/csconfig. Config is now passed explicitly through function parameters.

Changes

csconfig package

  • Removed globalConfig variable and GetConfig() function
  • Removed assignment in NewConfig()

apiserver

  • GetUsageMetrics() now uses existing a.consoleConfig field instead of csconfig.GetConfig()

acquisition package

  • Added clientConfig *csconfig.LocalApiClientCfg parameter to:
    • DataSourceConfigure()
    • LoadAcquisitionFromDSN()
    • ParseSourceConfig()
    • sourcesFromFile()
    • LoadAcquisitionFromFiles()

cmd/crowdsec

  • Extracts clientConfig once and passes through acquisition call chain

tests

  • Updated test signatures with new parameter
  • Added mock clientConfig for appsec datasource tests

Example

Before:

// In acquisition code
cConfig := csconfig.GetConfig()
lapiClientAware.SetClientConfig(cConfig.API.Client)

After:

// Passed explicitly
func DataSourceConfigure(..., clientConfig *csconfig.LocalApiClientCfg) {
    if lapiClientAware, ok := dataSrc.(types.LAPIClientAware); ok {
        if clientConfig != nil {
            lapiClientAware.SetClientConfig(clientConfig)
        }
    }
}

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@semanticdiff-com
Copy link

semanticdiff-com bot commented Feb 5, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  pkg/acquisition/config_test.go  20% smaller
  pkg/acquisition/acquisition.go  12% smaller
  pkg/apiserver/apic_metrics.go  2% smaller
  .gitignore Unsupported file format
  cmd/crowdsec/main.go  0% smaller
  pkg/acquisition/acquisition_test.go  0% smaller
  pkg/csconfig/config.go  0% smaller

Copilot AI and others added 6 commits February 5, 2026 15:39
Co-authored-by: mmetc <92726601+mmetc@users.noreply.github.com>
Co-authored-by: mmetc <92726601+mmetc@users.noreply.github.com>
Co-authored-by: mmetc <92726601+mmetc@users.noreply.github.com>
Co-authored-by: mmetc <92726601+mmetc@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove global variable and GetConfig function Remove global config state from csconfig package Feb 5, 2026
Copilot AI requested a review from mmetc February 5, 2026 15:52
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