add support for pulp_labels key in rpm_repository#240
Conversation
|
Please take a look at the docs testing this. |
e0020bd to
9da1857
Compare
|
Did read the docs on testing and adjusted PR accordingly. |
9da1857 to
2a65ced
Compare
| pulp_labels: | ||
| description: | ||
| - A JSON document or data structure assigning pulp labels | ||
| type: dict[str, str] |
There was a problem hiding this comment.
let's hope ansible-lint tells us whether this is the supposed language here. ;)
There was a problem hiding this comment.
Actually, this looks a bit different:
https://docs.ansible.com/projects/ansible/latest/dev_guide/developing_program_flow_modules.html#argument-spec
There was a problem hiding this comment.
According to this discussion and the linked issue it seems that the argument spec does not offer any way to define the data types of dictionary elements.
So this can only be done via runtime validation in the modules code from what I understood.
| # Encode the pulp_labels unless its a string, then assume it is a pre-formatted JSON | ||
| if "pulp_labels" in desired_attributes and isinstance( | ||
| desired_attributes["pulp_labels"], string_types | ||
| ): |
There was a problem hiding this comment.
And now this part is superfluous, right?
There was a problem hiding this comment.
This implementation is indeed. I replaced it with an actual check for strings.
| - name: Add pulp_labels (string) to repository (Validate no change) | ||
| pulp.squeezer.rpm_repository: | ||
| name: test_rpm_repository | ||
| pulp_labels: '{"test_label": "1"}' |
There was a problem hiding this comment.
Also we don't expect that to work anymore.
Maybe:
| pulp_labels: '{"test_label": "1"}' | |
| pulp_labels: "{{ '{\"test_label\": \"1\"}' | from_json }}" |
There was a problem hiding this comment.
I assumed that too but the tests still made it through. It seems that Ansible does convert inputs for dict parameters through some filter already before the data arrives at the module.
2a65ced to
2f9e290
Compare
|
Thank you! |
Resolves #239
Adds the
pulp_labelsparameter to the rpm_repository module and extends the tests based on the ones fromrepo_configparameter.Other repository modules might require this enhancement as well but for now I only need this one.