-
-
Notifications
You must be signed in to change notification settings - Fork 296
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
[chore] refactor test/cliparsing.sh into a go test below internal/config #1036
[chore] refactor test/cliparsing.sh into a go test below internal/config #1036
Conversation
Looks mostly good so far :) just a few points:
|
that's actually an artifact of first refactoring it into a go script, will look at changing that :)
you mean the go code? Yeah probably
yep, not too nice indeed .. best would probably not to execute a new binary but kinda load the config into the test process, if I can cleanly reset and reparse new arguments .. will look into that |
Oh another note: I'm actually doing this to have nicer test output for my refactoring of config generator stuff - generate way more things. Am quite far with that already, but the test output from the current |
instead of relying GtS to be built while this test runs, I could add a fallback to use |
thinking over this while doing laundry things .. this test shouldn't rely on either |
Ooh I'm interested to see this! Do you have a branch somewhere I can take a look at 👀
Yeah I was think you might be able to access the necessary exported parts of things in |
not yet, but plan is to have the CLI flags generated from the refactoring |
This sounds great! My solution was a little hacky at the time, I just didn't like seeing the As part of this refactor do we think it might be worth splitting up some of the configuration variables we have in the config files themselves? At some point I'd love to add a whole bunch of cache configuration variables and the main config file namespace is getting rather cluttered these days. Obviously one for @tsmethurst to weigh in on too. |
yep, my first attempt was to split this up nicely by module, so there would be stuff like this: type StorageConfiguration struct {
Backend StorageBackend
Local LocalStorageConfiguration
S3 S3StorageConfiguration
} and then modules could get their config chunk passed to Maybe I'll look at this again, annotating the individual module config structs with a comment for give them a CLI flag prefix could work great .. //gts:cli-name storage
type StorageConfiguration struct {
Backend StorageBackend `name:"backend"` // cli name: storage-backend
Local LocalStorageConfiguration
S3 S3StorageConfiguration
}
//gts:cli-name s3
type S3StorageConfiguration struct {
Endpoint string `name:"endpoint"` // cli name: storage-s3-endpoint
UseHTTPS bool `name:"use_https"` // cli name: storage-s3-use-https ('_' -> '-' automatically)
} buuut all of this would change config file format I fear... but maybe not, we have the CLI names and could use them ... Edit: wouldn't even need those |
11a243b
to
9fba01e
Compare
I think this looks a lot better now - no |
maybe I'll also tackle Buuut ... sleep now 💤 |
we could, but i'd rather save refactoring work for after 0.6.0 comes out :) especially since people are currently submitting things that involve changing config, and if we change stuff now they have to do difficult rebases |
'tis a good point! |
1d43524
to
7923af8
Compare
2de8a8a
to
06d5783
Compare
I'll tackle envparsing.sh in another PR, to get this one merged soon :) |
Also adds AddGlobalFlags and AddServerFlags as methods on ConfigState, very useful for testing.
06d5783
to
ff24da4
Compare
Thank you! :) |
It's now a normal Go test and does not need a precompiled GtS binary nor
go run
as it did before.But the most important change is it now being independent from the declaration order of Configuration fields, as we aren't comparing a JSON dump anymore but test for specific fields instead.