Skip to content

Commit

Permalink
Fix minor bugs to get validation scripts working
Browse files Browse the repository at this point in the history
  • Loading branch information
sonicaj committed Apr 23, 2024
1 parent a95994b commit cc3d5a1
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion apps_validation/catalog_reader/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def get_app_version_details(
) -> dict:
version_data = {'location': version_path, 'required_features': set()}
for key, filename, parser in (
('chart_metadata', 'Chart.yaml', yaml.safe_load),
('chart_metadata', 'app.yaml', yaml.safe_load),
('app_metadata', 'metadata.yaml', yaml.safe_load),
('schema', 'questions.yaml', yaml.safe_load),
('readme', 'README.md', markdown.markdown), # TODO: Has been changed, make sure json schema accounts for it
Expand Down
2 changes: 1 addition & 1 deletion apps_validation/catalog_reader/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def get_apps_in_trains(trains_to_traverse: list, catalog_location: str) -> dict:
for train in trains_to_traverse:
items.update({
f'{i}_{train}': train for i in os.listdir(os.path.join(get_train_path(catalog_location), train))
if os.path.isdir(os.path.join(catalog_location, train, i))
if os.path.isdir(os.path.join(get_train_path(catalog_location), train, i))
})

return items
Expand Down
2 changes: 1 addition & 1 deletion apps_validation/schema/attrs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SchemaMeta(type):

def __new__(cls, name, bases, dct):
klass = type.__new__(cls, name, bases, dct)
if getattr(klass, 'SCHEMA_NAME', NotImplementedError) is NotImplementedError:
if klass.__name__ != 'BaseSchema' and getattr(klass, 'SCHEMA_NAME', NotImplementedError) is NotImplementedError:
raise ValueError(f'{name!r} attr schema does not has SCHEMA_NAME defined')

ATTRIBUTES_SCHEMA[klass.SCHEMA_NAME] = klass
Expand Down
2 changes: 1 addition & 1 deletion apps_validation/schema/attrs/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class URISchema(BaseSchema):

class IPAddrSchema(BaseSchema):
DEFAULT_TYPE = 'string'
SCHEMA_NAME = 'uri'
SCHEMA_NAME = 'ipaddr'

def __init__(self, data):
self.ipv4 = self.ipv6 = self.cidr = None
Expand Down
7 changes: 4 additions & 3 deletions apps_validation/scripts/catalog_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
get_app_version, get_ci_development_directory, get_to_keep_versions, OPTIONAL_METADATA_FILES,
REQUIRED_METADATA_FILES, version_has_been_bumped,
)
from apps_validation.catalog_reader.train_utils import get_train_path
from apps_validation.ci.names import CACHED_CATALOG_FILE_NAME, CACHED_VERSION_FILE_NAME
from apps_validation.exceptions import ValidationErrors
from apps_validation.validation.json_schema_utils import CATALOG_JSON_SCHEMA
Expand All @@ -21,7 +22,7 @@

def get_trains(location: str) -> typing.Tuple[dict, dict]:
preferred_trains: list = []
trains_to_traverse = retrieve_train_names(location)
trains_to_traverse = retrieve_train_names(get_train_path(location))
catalog_data = {}
versions_data = {}
for train_name, train_data in retrieve_trains_data(
Expand Down Expand Up @@ -88,7 +89,7 @@ def publish_updated_apps(catalog_path: str) -> None:

for train_name, apps in get_apps_to_publish(catalog_path).items():
dev_train_path = os.path.join(ci_dev_directory, train_name)
publish_train_path = os.path.join(catalog_path, train_name)
publish_train_path = os.path.join(get_train_path(catalog_path), train_name)
os.makedirs(publish_train_path, exist_ok=True)

for app in apps:
Expand Down Expand Up @@ -141,7 +142,7 @@ def update_catalog_file(location: str) -> None:

for train_name, train_data in versions_data.items():
for app_name, app_data in train_data.items():
version_path = os.path.join(location, train_name, app_name, CACHED_VERSION_FILE_NAME)
version_path = os.path.join(get_train_path(location), train_name, app_name, CACHED_VERSION_FILE_NAME)
with open(version_path, 'w') as f:
f.write(json.dumps(app_data['versions'], indent=4))

Expand Down
2 changes: 1 addition & 1 deletion apps_validation/validation/validate_dev_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def validate_upgrade_strategy(app_path: str, schema: str, verrors: ValidationErr

def validate_app(app_dir_path: str, schema: str) -> None:
app_name = os.path.basename(app_dir_path)
chart_version_path = os.path.join(app_dir_path, 'Chart.yaml')
chart_version_path = os.path.join(app_dir_path, 'app.yaml')
verrors = validate_app_version_file(ValidationErrors(), chart_version_path, schema, app_name)
validate_keep_versions(app_dir_path, app_name, verrors)
verrors.check()
Expand Down

0 comments on commit cc3d5a1

Please sign in to comment.