Skip to content

Commit

Permalink
Make sure to ship the schema.yaml and image definitions in package (#828
Browse files Browse the repository at this point in the history
)

Signed-off-by: Gondermann <[email protected]>
  • Loading branch information
gndrmnn authored Aug 29, 2024
1 parent 0944a3a commit 46e933b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Empty file added etc/__init__.py
Empty file.
9 changes: 8 additions & 1 deletion openstack_image_manager/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from typing import Dict, Set
import yamale
import urllib.parse
import pkgutil

from datetime import datetime, date
from decimal import Decimal, ROUND_UP
Expand Down Expand Up @@ -1114,7 +1115,13 @@ def manage_outdated_images(self, managed_images: set) -> list:

def validate_yaml_schema(self):
"""Validate all image.yaml files against the SCS Metadata spec"""
schema = yamale.make_schema("etc/schema.yaml")
try:
# We are a pip package
schema_data = pkgutil.get_data(__name__, "etc/schema.yaml").decode("utf-8")
schema = yamale.make_schema(content=schema_data)
except Exception:
# We are a cloned repo
schema = yamale.make_schema("etc/schema.yaml")
try:
validation_error_log = []
for file in os.listdir(self.CONF.images):
Expand Down
9 changes: 6 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ dynamic = ["dependencies", "version"]
[tool.mypy]
exclude = ["doc"]

[tool.setuptools]
packages = ["openstack_image_manager", "openstack_image_manager.etc"]
package-dir = {"openstack_image_manager.etc" = "etc"}

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}

[tool.setuptools.packages.find]
where = ["."]
include = ["openstack_image_manager"]
[tool.setuptools.package-data]
"openstack_image_manager.etc" = ["**/*"]

[tool.setuptools-git-versioning]
enabled = true
Expand Down

0 comments on commit 46e933b

Please sign in to comment.