-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #151 from mdellweg/bump-glue-version
Bump glue version
- Loading branch information
Showing
7 changed files
with
155 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import os | ||
from pathlib import Path | ||
|
||
import yaml | ||
|
||
|
||
def main() -> None: | ||
modules_path = Path("plugins/modules") | ||
runtime_path = Path("meta/runtime.yml") | ||
modules = sorted([module.stem for module in modules_path.glob("*.py")]) | ||
action_groups = {"squeezer": modules} | ||
runtime = yaml.safe_load(runtime_path.read_text()) | ||
if runtime.get("action_groups") != action_groups: | ||
print("Updating action groups. 🌓") | ||
runtime["action_groups"] = action_groups | ||
runtime_path.write_text(yaml.safe_dump(runtime, explicit_start=True, explicit_end=True)) | ||
else: | ||
print("Action groups are up to date. 🎬") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import re | ||
import sys | ||
from pathlib import Path | ||
|
||
from packaging.requirements import Requirement | ||
from packaging.specifiers import Specifier, SpecifierSet | ||
from packaging.version import Version | ||
|
||
|
||
def fix_requirements_file(path: Path, check: bool, name: str, specifier: SpecifierSet) -> None: | ||
lines = path.read_text().split("\n") | ||
for num, line in enumerate(lines): | ||
try: | ||
requirement = Requirement(line) | ||
except: | ||
pass | ||
else: | ||
if requirement.name == name: | ||
if requirement.specifier == specifier: | ||
print(f"{path} is up to date.") | ||
break | ||
elif check: | ||
print(f"{path} has unmatched pulp-glue requirement.") | ||
sys.exit(1) | ||
else: | ||
print(f"Update {path}.") | ||
requirement.specifier = specifier | ||
lines[num] = str(requirement) | ||
path.write_text("\n".join(lines)) | ||
break | ||
else: | ||
print(f"{name} requirement missing from {path}.") | ||
sys.exit(1) | ||
|
||
|
||
def main(check: bool) -> None: | ||
pulp_glue_path = Path("plugins/module_utils/pulp_glue.py") | ||
requirements_path = Path("requirements.txt") | ||
lower_bounds_path = Path("lower_bounds_constraints.lock") | ||
|
||
with pulp_glue_path.open("r") as fp: | ||
for line in fp.readlines(): | ||
if match := re.search(r"GLUE_VERSION_SPEC\s*=\s*\"(.*)\"", line): | ||
GLUE_VERSION_SPEC = SpecifierSet(match.group(1)) | ||
break | ||
else: | ||
print("GLUE_VERSION_SPEC not found!") | ||
sys.exit(1) | ||
try: | ||
min_version = min( | ||
[Version(spec.version) for spec in GLUE_VERSION_SPEC if spec.operator == ">="] | ||
) | ||
except ValueError: | ||
print("No lower bound requirement specified for pulp-glue.") | ||
sys.exit(1) | ||
lower_bounds_spec = Specifier(f"=={min_version}") | ||
|
||
fix_requirements_file(requirements_path, check, "pulp-glue", GLUE_VERSION_SPEC) | ||
fix_requirements_file(lower_bounds_path, check, "pulp-glue", lower_bounds_spec) | ||
|
||
|
||
if __name__ == "__main__": | ||
check = len(sys.argv) == 2 and sys.argv[1] == "--check" | ||
main(check) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,45 @@ | ||
--- | ||
requires_ansible: ">=2.8" | ||
action_groups: | ||
squeezer: | ||
- access_policy | ||
- ansible_distribution | ||
- ansible_remote | ||
- ansible_repository | ||
- ansible_role | ||
- ansible_sync | ||
- api_call | ||
- artifact | ||
- container_distribution | ||
- container_remote | ||
- container_repository | ||
- container_sync | ||
- deb_distribution | ||
- deb_publication | ||
- deb_remote | ||
- deb_repository | ||
- deb_sync | ||
- delete_orphans | ||
- file_content | ||
- file_distribution | ||
- file_publication | ||
- file_remote | ||
- file_repository | ||
- file_repository_content | ||
- file_sync | ||
- purge_tasks | ||
- python_distribution | ||
- python_publication | ||
- python_remote | ||
- python_repository | ||
- python_sync | ||
- repair | ||
- rpm_distribution | ||
- rpm_publication | ||
- rpm_remote | ||
- rpm_repository | ||
- rpm_sync | ||
- status | ||
- task | ||
- x509_cert_guard | ||
- access_policy | ||
- ansible_distribution | ||
- ansible_remote | ||
- ansible_repository | ||
- ansible_role | ||
- ansible_sync | ||
- api_call | ||
- artifact | ||
- container_distribution | ||
- container_remote | ||
- container_repository | ||
- container_sync | ||
- deb_distribution | ||
- deb_publication | ||
- deb_remote | ||
- deb_repository | ||
- deb_sync | ||
- delete_orphans | ||
- file_content | ||
- file_distribution | ||
- file_publication | ||
- file_remote | ||
- file_repository | ||
- file_repository_content | ||
- file_sync | ||
- purge_tasks | ||
- python_distribution | ||
- python_publication | ||
- python_remote | ||
- python_repository | ||
- python_sync | ||
- repair | ||
- rpm_distribution | ||
- rpm_publication | ||
- rpm_remote | ||
- rpm_repository | ||
- rpm_sync | ||
- status | ||
- task | ||
- x509_cert_guard | ||
requires_ansible: '>=2.8' | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters