-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Serialize Workflow Job Template inventories by natural key - related #7798 #7805
Conversation
Build succeeded.
|
…nsible#7798 This changeset introduces two changes: 1. Update the API representation of Workflow Job Templates to use the natural key of the Inventory type instead of its id; 2. Override the related property of the CLI's WorkflowJobTemplate page type to patch the related references during the export process, allowing the resource to be serialised using the natural key of the Inventory type instead of the id. Change n.2 is a workaround that is used when exporting resources from AWX/Tower instances that don't have change n.1. It can be removed in the future.
ad0c9f1
to
5238d72
Compare
Build succeeded.
|
@@ -3404,6 +3404,12 @@ def get_related(self, obj): | |||
res['organization'] = self.reverse('api:organization_detail', kwargs={'pk': obj.organization.pk}) | |||
if obj.webhook_credential_id: | |||
res['webhook_credential'] = self.reverse('api:credential_detail', kwargs={'pk': obj.webhook_credential_id}) | |||
if obj.inventory: |
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.
👍
@@ -15,6 +15,27 @@ class WorkflowJobTemplate(HasCopy, HasCreate, HasNotifications, HasSurvey, Unifi | |||
optional_dependencies = [Organization] | |||
NATURAL_KEY = ('organization', 'name') | |||
|
|||
@property | |||
def related(self): |
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'm pretty uncomfortable with doing it this way. However, fortunately, I do note that the inventory
field shows up as of type 'id'
in the OPTIONS
call on the api endpoint even under current devel awx. I think it would be easy enough to check for the case of an id field that fails to show up in related in the _export()
method, and attempt to construct the natural key by other means (probably by doing a _filtered_list()
call).
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.
OK. Good suggestion. I'll look into it and push an update if I get something working.
I've gone ahead and rebased this branch against the latest devel, and made the change I recommended. The new PR is #8353. |
SUMMARY
Related #7798
This changeset introduces two changes:
natural key of the Inventory type instead of its id;
type to patch the related references during the export process,
allowing the resource to be serialised using the natural key of the
Inventory type instead of the id.
Change n.2 is a workaround that is used when exporting resources from
AWX/Tower instances that don't have change n.1. It can be removed in the
future.
ISSUE TYPE
COMPONENT NAME
AWX VERSION