-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/114 add django setup configuration #115
Conversation
fc242eb
to
c9f80ed
Compare
c60c2e3
to
6a447fc
Compare
6e001b1
to
aca7802
Compare
Mostly copied Example of it being used here open-zaak/open-zaak#1728 |
20f406b
to
aca9492
Compare
I am also unsure about the package/file names |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took a preliminary glance, haven't looked into much details yet, but I have some concerns - perhaps about the way django-setup-configuration itself works:
amount of settings
there are a lot of settings being defined purely to facilitate bootstrapping configuration. Some of these setting names also have a big potential to cause confusion with settings that actually have some meaning at runtime. I don't think this will improve the developer experience
settings datatypes
I noticed in OIP that settings are used so that envvars can be used to specify them, but the datatypes of these settings (like lists of strings, periods/comma's having special meaning...) but also dict/mappings complicates passing them via the env
you basically have a Helm chart or Ansible playbook where the datatype is properly defined in YAML, this is then templated out to a string so it can be passed as an envvar, after which the application deserializes it again from a string into the expected datatype
I would much prefer one of the options below (with the first having my preference):
- load a YAML/TOML/JSON file that contains the data/config to initialize. you then only need to point to which file to load, plus it will scale in the future when we don't have solo models anymore but instead regular models. it's basically a django-agnostic fixture format
- read the values directly from the env and remove the need to define them as settings. the library knows how to interpret each envvar and parse it into the expected data-structure
IMO the former approach makes documenting the format a lot easier, you can simply provide an example template, you can add comments if you use YAML/TOML and the processing step of that file is able to populate missing information (the endpoints!) from the discovery endpoint if that's all that is specified.
FYI for Conor, Paul is working on a related issue: https://taiga.maykinmedia.nl/project/open-inwoner/issue/2563 |
92960f5
to
68d3a61
Compare
3bc045b
to
93f6c66
Compare
|
||
if groups := all_settings.get("default_groups"): | ||
all_settings["default_groups"] = create_missing_groups( | ||
groups, all_settings["sync_groups_glob_pattern"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it use the glob pattern here? I do not think it did in the original Open Inwoner step but does in the middleware
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I should probably make a test for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I read this correctly it will always create missing groups, regardless of the value of sync_groups
? I would either remove sync_groups
from the model and always set it to True then, or add it as a conditional here to make sure it works the same as in the admin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an oversite and I assume it should use the sync_group value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Useful to see the API being battle tested. I'll update the docs at least regarding defaults and testing best practices based on this. Otherwise LGTM.
Co-authored-by: Sidney Richards <[email protected]>
* Pin django-setup-configuration >= 0.4.0 * Use Pydantic model defaults, remove defaults from step * Remove now unneeded OIDCSetupConfigForm * Set non-default values for test_configure_use_defaults * Update Documentation
623d37d
to
1d0bdbf
Compare
* Set non default values in model in test_configure_use_defaults * Remove model fixtures in favour of file yml fixtures * Move from build_step_config_from_sources in fixture to execute_single_step in test * Remove model validaiton tests
@stevenbal @SonnyBA This is ready to re-review if either of you have time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically done I think, just a few questions/comments mainly about the use of defaults.
2321306
to
4e51bd9
Compare
4e51bd9
to
ecad85b
Compare
Optional Fields: | ||
"""""""""""""""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@swrichards perhaps this could be an alternative to the generate documentation functionality?
|
||
if groups := all_settings.get("default_groups"): | ||
all_settings["default_groups"] = create_missing_groups( | ||
groups, all_settings["sync_groups_glob_pattern"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I read this correctly it will always create missing groups, regardless of the value of sync_groups
? I would either remove sync_groups
from the model and always set it to True then, or add it as a conditional here to make sure it works the same as in the admin
@stevenbal It's definitely a good stopgap until the documentation generation is fixed, though I think we should add the auto-generation eventually (but later, because it's non-blocking for the MVP). Doing the extra work here and now makes sense because this is a library with consumers, but I think for the downstream projects we can afford to wait until the documentation generator is back up. |
* Explicitly use model values * Rename create_missing_groups to get_groups_by_name * Move sync_groups condition to get_groups_by_name * Fix sync_group doing nothing in step * Test sync_group & sync_groups_glob_pattern * Test idempotent and overwrite
a2c8e7d
to
d6c8846
Compare
fixes: #114
Implements django setup configuration in OIDC itself