Skip to content

Commit 1737b63

Browse files
committed
Refactor prepend_dist_dir_to_spec_paths in validate_manifest.py for clarity and efficiency; simplify clean_env function in env_cleaner.py by removing unused parameters.
1 parent 1fea385 commit 1737b63

2 files changed

Lines changed: 11 additions & 15 deletions

File tree

ansible/collections/ansible_collections/nhsd/apigee/plugins/module_utils/models/ansible/validate_manifest.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,15 @@ def check_service_name(cls, service_name, values):
5353
def prepend_dist_dir_to_spec_paths(cls, manifest, values):
5454
dist_dir = values.get("dist_dir")
5555
print(dist_dir)
56-
if not dist_dir:
57-
return manifest
58-
changed = False
59-
apigee = manifest["apigee"]
60-
for env_dict in apigee["environments"]:
61-
for spec_dict in env_dict["specs"]:
62-
path = spec_dict.get("path")
63-
if path is not None:
64-
spec_dict["path"] = os.path.join(dist_dir, path)
65-
changed = True
56+
if dist_dir:
57+
apigee = manifest["apigee"]
58+
for env_dict in apigee["environments"]:
59+
for spec_dict in env_dict["specs"]:
60+
path = spec_dict.get("path")
61+
if path is not None:
62+
spec_dict["path"] = os.path.join(dist_dir, path)
6663

67-
return manifest if changed else manifest
64+
return manifest
6865

6966
@pydantic.validator("manifest")
7067
def check_namespacing(cls, manifest, values):

env_cleaner.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def clean_proxies(
8888
undeploy_only: bool = False,
8989
respect_prs: bool = False,
9090
):
91+
9192
open_prs = set()
9293
if respect_prs:
9394
# Get open PRs, if there are any
@@ -153,12 +154,11 @@ def clean_env(
153154
should_clean_products: bool = False,
154155
sandboxes_only: bool = False,
155156
dry_run: bool = False,
156-
min_age: Optional[int] = None,
157157
undeploy_only: bool = False,
158158
respect_prs: bool = False,
159159
):
160160
if should_clean_specs:
161-
clean_specs(client, env, dry_run)
161+
clean_specs(client, dry_run)
162162

163163
if should_clean_proxies:
164164
clean_proxies(
@@ -167,13 +167,12 @@ def clean_env(
167167
env,
168168
dry_run,
169169
sandboxes_only,
170-
min_age,
171170
undeploy_only,
172171
respect_prs,
173172
)
174173

175174
if should_clean_products:
176-
clean_products(client, env, dry_run)
175+
clean_products(client, dry_run)
177176

178177

179178
if __name__ == "__main__":

0 commit comments

Comments
 (0)