Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: Use reflection #1480

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Sep 6, 2024

  1. config: Use reflection

    Our previous approach of playing whack-a-mole did not seem to work very
    well. This just replaces everything via reflection, with two notable
    exceptions:
    
    1. Some top-level fields in Configuration are meta-fields and not
       meant to be replaced by anything.
    2. Since subpackages support Range, we need to expand them before
       calling replace() on them.
    
    This approach won't scale very well if we add sub-fields to structs that
    shouldn't support string replacement or if we add top-level fields to
    Configuration that need replacement (we will need to update this code).
    
    One approach for dealing with both of these things would be to use
    struct tags to explicitly mark fields as non-replaceable and handle
    these exceptions in the reflection code by just skipping over them.
    That's more complicated than I intend for this change, so I'm going to
    punt on that for now, but we should consider it if this new code doesn't
    hold up to the test of time.
    
    Signed-off-by: Jon Johnson <[email protected]>
    jonjohnsonjr committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    e492941 View commit details
    Browse the repository at this point in the history