|
88 | 88 | from ansible_collections.pulp.squeezer.plugins.module_utils.pulp_glue import PulpRemoteAnsibleModule |
89 | 89 |
|
90 | 90 | try: |
| 91 | + from pulp_glue.common.context import PluginRequirement |
91 | 92 | from pulp_glue.container.context import PulpContainerRemoteContext |
92 | 93 |
|
| 94 | + class PulpContainerRemoteContext(PulpContainerRemoteContext): |
| 95 | + def converge(self, desired_attributes, defaults=None): |
| 96 | + if self.pulp_ctx.has_plugin(PluginRequirement("container", specifier=">=2.28.0")): |
| 97 | + # Translate the old name to the new one and back afterwards. |
| 98 | + # Here specifically we can assume there are no defaults. |
| 99 | + # Eventually we expect glue to only expose the new name to us. |
| 100 | + if desired_attributes is not None: |
| 101 | + if "include_tags" in desired_attributes: |
| 102 | + desired_attributes["includes"] = desired_attributes.pop("include_tags") |
| 103 | + if "exclude_tags" in desired_attributes: |
| 104 | + desired_attributes["excludes"] = desired_attributes.pop("exclude_tags") |
| 105 | + |
| 106 | + changed, before, after = super().converge(desired_attributes, defaults=defaults) |
| 107 | + |
| 108 | + if before is not None: |
| 109 | + if "includes" in before: |
| 110 | + before["include_tags"] = before.pop("includes") |
| 111 | + if "excludes" in before: |
| 112 | + before["exclude_tags"] = before.pop("excludes") |
| 113 | + if after is not None: |
| 114 | + if "includes" in after: |
| 115 | + after["include_tags"] = after.pop("includes") |
| 116 | + if "excludes" in after: |
| 117 | + after["exclude_tags"] = after.pop("excludes") |
| 118 | + |
| 119 | + return changed, before, after |
| 120 | + return super().converge(desired_attributes, defaults=defaults) |
| 121 | + |
93 | 122 | PULP_GLUE_IMPORT_ERR = None |
94 | 123 | except ImportError: |
95 | 124 | PULP_GLUE_IMPORT_ERR = traceback.format_exc() |
|
0 commit comments