-
Notifications
You must be signed in to change notification settings - Fork 10
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
[#467] setup objecttypes through django-setup-configuration #489
Conversation
This will be replaced by #485
@danielmursa-dev I made some changes to the |
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.
Looks good generally, though I think the ObjectType
configuration stuff is out of scope
|
||
def execute(self, model: SitesConfigurationModel) -> None: | ||
for item in model.items: | ||
site_kwargs = dict(domain=item.domain, name=item.name) |
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 implemented the same step when refactoring it in Open Notificaties: https://github.com/open-zaak/open-notificaties/pull/201/files#diff-9d74a1ba740219a222b8fb9dea30f135ebe2f5ad67f77ca87074ae55c13cb1ceR23
The behavior of the original step is a bit different, since it would let you specify an organization
which would be used to create the name (Objects {organization}
). To be honest I'm fine with either option (specifying organization
or specifying name
directly), but I think it would be good to pick one of these and be consistent.
Perhaps we could define this step in django-setup-configuration
itself, so that we can reuse it?
@swrichards do you have an opinion on 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.
I think it indeed makes sense to put this in django-setup-configuration
itself. I am bit reluctant to delay these PRs though, so I would recommend leaving this in given that it works. It would be good if the two of you agree on whose step is leading to avoid divergence on the yaml structures, so the upgrade will be easier later on.
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 guess the points to consider here (and in other projects?) are:
- Upgrade the site related configuration and allow multiple sites to be configured (as is done in this PR)
- Upgrade the site related configuration and allow configuration of one site (or update the current site, behavior of the previous site step for this project)
- Remove the step altogether
- Move the step to
django-setup-configuration
Edit: made the list ordered to make referencing a bit easier
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 am bit reluctant to delay these PRs
agree, though I think in that case it's important that the format is the same everywhere, otherwise we'll still end up with breaking changes. Let's use the step as it's implemented here
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.
So we're gonna apply point 1 to all projects which use a site configuration step?
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.
So we're gonna apply point 1 to all projects which use a site configuration step?
That sounds right to me.
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.
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.
Discussed this morning, this will be replaced by a configuration step from django-setup-configuration
DEMO_PERSON="Demo", | ||
DEMO_EMAIL="[email protected]", | ||
) | ||
class SetupConfigurationTests(TestCase): |
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.
Not sure if we want a similar test for the new setup. It might feel a bit excessive but I guess it does verify that all expected steps are executed and work together when used with an example.yaml file
@swrichards what do you think about this?
from objects.core.models import ObjectType | ||
|
||
|
||
class ObjectTypeConfigurationModel(ConfigurationModel): |
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 @joeribekker I don't think this was very clear from the issue, but I think the scope of setup-configuration here was to be able to configure the connection from Objects API to Objecttypes API, and not to be able to configure objecttypes, right?
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 think the question here is whether an objects-api
/objecttypes-api
can meaningfully function without being seeded with some object types of which objects-api
has knowledge. I can imagine the bar of "minimum viable connectivity" here includes a certain level of seeding core objects, but I don't know enough about the Objects API to say for sure.
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.
Objecttypes can be created with the API once a token is obtained. So, no, objecttypes should not be created via the YAML file.
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.
Changed this behavior in 4a256d9. I'm wondering though if we should use a fixed identifier
(for example objecttypes-api
) and remove the ability to modify it.
|
||
def execute(self, model: SitesConfigurationModel) -> None: | ||
for item in model.items: | ||
site_kwargs = dict(domain=item.domain, name=item.name) |
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 think it indeed makes sense to put this in django-setup-configuration
itself. I am bit reluctant to delay these PRs though, so I would recommend leaving this in given that it works. It would be good if the two of you agree on whose step is leading to avoid divergence on the yaml structures, so the upgrade will be easier later on.
docs/installation/config_cli.rst
Outdated
Objecttypes require a corresponding ``Service`` to work correctly. Creating | ||
these ``Service``'s can be done by defining these in the same yaml file. ``Service`` | ||
instances will be created before the ``ObjectType``'s are created. |
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.
Objecttypes require a corresponding ``Service`` to work correctly. Creating | |
these ``Service``'s can be done by defining these in the same yaml file. ``Service`` | |
instances will be created before the ``ObjectType``'s are created. | |
Objecttypes require a corresponding ``Service`` to work correctly. Creating | |
these ``Service``'s can be done by defining these in the same yaml file (i.e. in the ``zgw_consumers`` block above). ``Service`` | |
instances will be created before the ``ObjectType``'s are created. |
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.
See thread, this description is not relevant anymore.
docs/installation/config_cli.rst
Outdated
zgw_consumers: | ||
services: |
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.
zgw_consumers: | |
services: | |
zgw_consumers: | |
services: |
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.
See #489 (comment)
docs/installation/config_cli.rst
Outdated
service_identifier: objecttypen-bar | ||
... | ||
|
||
.. note:: The ``uuid`` field will be used to lookup existing ``ObjectType``'s. |
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.
.. note:: The ``uuid`` field will be used to lookup existing ``ObjectType``'s. | |
.. note:: The `uuid` field is used to look up existing `ObjectType` entries through the `object-types` API of the service specified by `service_identifier`. |
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.
See #489 (comment)
|
||
|
||
class ObjectTypesConfigurationModel(ConfigurationModel): | ||
items: list[ObjectTypeConfigurationModel] = Field() |
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.
items: list[ObjectTypeConfigurationModel] = Field() | |
items: list[ObjectTypeConfigurationModel] |
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.
See #489 (comment)
from objects.core.models import ObjectType | ||
|
||
|
||
class ObjectTypeConfigurationModel(ConfigurationModel): |
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 think the question here is whether an objects-api
/objecttypes-api
can meaningfully function without being seeded with some object types of which objects-api
has knowledge. I can imagine the bar of "minimum viable connectivity" here includes a certain level of seeding core objects, but I don't know enough about the Objects API to say for sure.
namespace = "sites" | ||
enable_setting = "sites_config_enable" |
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.
In this regard, I suggest having a unique naming convention for all projects and apps, so as not to create problems with different yaml files.
%s_%s' % (app_label, model_name)
- something like how the url is made in admin
namespace = "sites" | |
enable_setting = "sites_config_enable" | |
namespace = "sites_site" | |
enable_setting = "sites_site_config_enable" |
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.
Good point, although the suggested namespace probably will clash whenever other projects allow their Site
to be configured as well. Consider for instance the following configuration file:
# Objects-api
sites_site_config_enable: true
sites_site:
items:
....
# Objecttypes-api
sites_site_config_enable: true
sites_site:
items:
....
I think prefixing it with the project name will fix this, for example objects_api_sites_config
and objects_api_sites_config_enable
.
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.
@danielmursa-dev I think the collision of the namespaces, like mentioned above, also applies to the token configuration for certain projects?
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.
yes exactly, everywhere the same namespaces must be used
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.
@danielmursa-dev I think the collision of the namespaces, like mentioned above, also applies to the token configuration for certain projects?
Discussed through the chat, this comment can be ignored as the namespace collision will not happen (different configuration file per project). The project prefix is not necessary for Site
configuration.
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.
@SonnyBA OK , so let's continue with this format yes?
# %s_%s' % (app_label, model_name)
sites_site_config_enable:` true
sites_site:
items:
....
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 don't think it's necessary to change this in the steps in existing projects but this might be a good scheme for steps that are going to be added.
This reverts commit 433867d.
docker/setup_configuration/data.yaml
Outdated
objects_api_objecttypes_connection: | ||
identifier: objecttypes-api | ||
label: Objecttypen API | ||
api_root: https://objecttypes.nl/api/v1/ | ||
api_connection_check_path: objecttypes | ||
api_type: orc | ||
auth_type: zgw | ||
header_key: Authorization | ||
header_value: Token foo | ||
client_id: client | ||
secret: secret | ||
nlx: http://some-outway-adress.local:8080/ | ||
user_id: objects-api | ||
user_representation: Objects API | ||
timeout: 60 |
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.
Discussed off-line: revert back to using zgw_consumers
, this basically just replicates that logic. We found that there is no central config model that has a ForeignKey to a Service
(as in other projects), rather each Object Type has such a foreign key. But because we said we wouldn't be configuring the actual object types here, we only have to configure Services (without having other models point to those services). TLDR: zgw_consumers
is sufficient.
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.
See https://github.com/maykinmedia/objects-api/pull/489/files#r1880529232 -- will do a final review after that.
The objecttypes connection part is now handled through the zgw-consumers configuration step. It might be practical to leave this PR open until there also is a configuration step provided from django-setup-configuration to setup site objects. There should also be decided upon loading in objecttypes (locally) so that tokens also can be loaded in (as they will have no function without any objecttype attached to it). |
Closing this PR in favor of #492 |
Fixes #467
Changes
Updates the existing django-setup-configuration steps and removed the
DemoUserStep
as that will be replaced by #482