Skip to content

Conversation

@manusa
Copy link
Member

@manusa manusa commented Oct 23, 2025

Creates the required infrastructure for downstream forks to be able to provide default config overrides without modifying the original source code.

Downstream forks should be able to create merge/rebase scripts that automatically accepted downstream merge conflicts in config_default_overrides.go since this file will never change upstream.

Example usage for downstream forks:

To customize defaults, simply populate fields in the returned StaticConfig:

func defaultOverrides() *StaticConfig {
  return &StaticConfig{
    ListOutput: "json",           // Override default list output format
    Toolsets:   []string{"core"}, // Override default enabled toolsets
    Port:       "9000",           // Override default port
  }
}

Any fields specified here will override the base defaults defined in config_default.go. Fields not specified will preserve their base default values.


The second commit fixes #391 (AFAIU)

The full toolset metadata tests are skipped in case there are config overrides.

If downstream follows the convention:

  • Not to mutate the original toolsets
  • Provide config overrides in the appropriate pkg/config/config_default_overrides.go file

The tests should not fail.

… overrides

Creates the required infrastructure for downstream forks to be able to provide
default config overrides without modifying the original source code.

Downstream forks should be able to create merge/rebase scripts that
automatically accepted downstream merge conflicts in config_default_overrides.go
since this file will never change upstream.

Example usage for downstream forks:

To customize defaults, simply populate fields in the returned StaticConfig:

```go
func defaultOverrides() *StaticConfig {
  return &StaticConfig{
    ListOutput: "json",           // Override default list output format
    Toolsets:   []string{"core"}, // Override default enabled toolsets
    Port:       "9000",           // Override default port
  }
}
```

Any fields specified here will override the base defaults defined in config_default.go.
Fields not specified will preserve their base default values.

Signed-off-by: Marc Nuri <[email protected]>
Skips toolset metadata tests in case there are config overrides.
This is useful in downstream forks where the default toolsets
might be different to those upstream.

Signed-off-by: Marc Nuri <[email protected]>
Comment on lines +14 to +15
overrides := defaultOverrides()
mergedConfig := mergeConfig(defaultConfig, overrides)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this approach

}

func (s *ToolsetsSuite) TestDefaultToolsetsTools() {
if configuration.HasDefaultOverrides() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is a good hook, for downstream.

Copy link
Collaborator

@Cali0707 Cali0707 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I really like this approach @manusa

Comment on lines +4 to +7
return StaticConfig{
// IMPORTANT: this file is used to override default config values in downstream builds.
// This is intentionally left blank.
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great @manusa !

@Cali0707 Cali0707 merged commit 07783a4 into containers:main Oct 23, 2025
6 checks passed
@manusa manusa deleted the feat/config-defaults branch October 23, 2025 13:33
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.

Refactor tests to merge multiple json files

3 participants