Skip to content

Commit de89a10

Browse files
committed
add support for pulp_labels key
1 parent f6b9b9c commit de89a10

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

plugins/modules/rpm_repository.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@
4646
- Max number of repository versions to keep
4747
type: int
4848
version_added: "0.0.16"
49+
pulp_labels:
50+
description:
51+
- A dictionary assigning pulp labels using string keys and values
52+
type: dict
53+
version_added: "0.4.0"
4954
extends_documentation_fragment:
5055
- pulp.squeezer.pulp.entity_state
5156
- pulp.squeezer.pulp
@@ -120,6 +125,7 @@
120125
"repo_config",
121126
"retain_package_versions",
122127
"retain_repo_versions",
128+
"pulp_labels",
123129
}
124130

125131

@@ -136,6 +142,7 @@ def main():
136142
"repo_config": {"type": "raw"},
137143
"retain_package_versions": {"type": "int"},
138144
"retain_repo_versions": {"type": "int"},
145+
"pulp_labels": {"type": "dict"},
139146
},
140147
required_if=[("state", "present", ["name"]), ("state", "absent", ["name"])],
141148
) as module:
@@ -158,6 +165,12 @@ def main():
158165
):
159166
desired_attributes["repo_config"] = json.loads(desired_attributes["repo_config"])
160167

168+
# Ensure `pulp_labels` contains only strings for keys and values
169+
if "pulp_labels" in desired_attributes:
170+
labels = desired_attributes["pulp_labels"]
171+
if not all(isinstance(k, str) and isinstance(v, str) for k, v in labels.items()):
172+
module.fail_json(msg="pulp_labels must be a dictionary with strings as keys and values")
173+
161174
module.process(natural_key, desired_attributes)
162175

163176

0 commit comments

Comments
 (0)