Skip to content

refactor: autogenerate config stub from lockfile

Clement Sam requested to merge profclems/cli:auto-config-stub into main

Description

This helps to simplify adding new configuration keys.

What changed:

  • Added internal/config/gen.go which is run by go:generate to generate config_stub.go from config.yaml.lock
  • Added internal/config/Readme.md to document how to add new configs
  • Added a makefile target gen-config to run gen.go
  • Renamed config_type.go and config_type_test.go to config.go and config_test.go repectively
  • Modified the tests to use the stub instead of manually adding a full config string
  • Added Test_configLock which test the generated stub against the config.yaml.lock
  • Moved ConfigKeyEquivalence(key string), EnvKeyEquivalence(key string) and defaultFor(key string) from config_type.go to a separate config_mapping.go.

Related Issues

Resolves #1144 (closed)

How has this been tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation
  • Chore (Related to CI or Packaging to platforms)
  • Refactor
Edited by Clement Sam

Merge request reports