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

Support for multiple configuration files #534

Merged
merged 2 commits into from
May 25, 2022

Conversation

FileGo
Copy link
Collaborator

@FileGo FileGo commented May 24, 2022

This adds support for multiple configuration files (in a single directory), as proposed in #512.

@FileGo
Copy link
Collaborator Author

FileGo commented May 24, 2022

Interesting, test fails on something that hasn't been changed.

@0xERR0R Any ideas?

@codecov
Copy link

codecov bot commented May 24, 2022

Codecov Report

Merging #534 (3fb5ebb) into development (8d0bd8e) will decrease coverage by 0.21%.
The diff coverage is 63.63%.

@@               Coverage Diff               @@
##           development     #534      +/-   ##
===============================================
- Coverage        93.73%   93.51%   -0.22%     
===============================================
  Files               36       36              
  Lines             3112     3131      +19     
===============================================
+ Hits              2917     2928      +11     
- Misses             145      149       +4     
- Partials            50       54       +4     
Impacted Files Coverage Δ
config/config.go 94.87% <61.90%> (-3.27%) ⬇️
cmd/root.go 58.53% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8d0bd8e...3fb5ebb. Read the comment docs.

@0xERR0R
Copy link
Owner

0xERR0R commented May 24, 2022

Interesting, test fails on something that hasn't been changed.

@0xERR0R Any ideas?

Is a flaky test which I can't reproduce locally ;(

@0xERR0R
Copy link
Owner

0xERR0R commented May 24, 2022

I created an issue to track it: #537

@0xERR0R
Copy link
Owner

0xERR0R commented May 25, 2022

Thanks for your work! If I understand your idea right, splitted files should contain distinct part of the target YAML. I mean, basically, all YAMLs in the directory will be concatenated together to a big target file. That means, there is no logical "merge" with attribute overwrite between pieces, right?

So following would (probably?) fail:
config1.yaml

upstream:
  default:
    - 5.9.164.112
    - 1.1.1.1

config2.yaml

upstream:
  someclient:
    - 1.2.3.4

I think, it can be a useful use case to separate config files per client or to split the blacklist configuration, but it could be technically difficult to merge the parts correct together (we have nested maps of maps in the config). What do you think?

Maybe we can leave it (take your implementation) but improve the documentation, so that it becomes clear that all config parts should have no overlapping. In this case it doesn't matter if the files are read in the alphabetically order or not.

@FileGo
Copy link
Collaborator Author

FileGo commented May 25, 2022

Exactly, current functionality assumes no parts of config will overlap and as you point out, it will fail the YAML unmarshal, if it does overlap.

I'll amend the documentation, to make it more clear.

@0xERR0R 0xERR0R linked an issue May 25, 2022 that may be closed by this pull request
@0xERR0R 0xERR0R merged commit 0731ebe into 0xERR0R:development May 25, 2022
@0xERR0R 0xERR0R added this to the 0.19 milestone May 25, 2022
@0xERR0R 0xERR0R added the 🔨 enhancement New feature or request label May 25, 2022
@FileGo FileGo deleted the include-directive branch May 25, 2022 14:38
@yunwu-jnpr
Copy link

I think it would be better to support include directive than blindly merging files under a directory.
You have much more control.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for multiple configuration files
3 participants