Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate switching to jsonschema for validating the bundle in image-gather script #1059

Open
kimwnasptd opened this issue Sep 6, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@kimwnasptd
Copy link
Contributor

Context

This is a follow-up of #1038 (comment)

The current logic will validate the whole bundle beforehand by:

  1. Parsing all the applications in the bundle
  2. Check if it has the correct metadata

If not it will fail.

A proposal from @DnPlas was to use jsonschema instead for doing the validation which we can investigate.

What needs to get done

  1. Create the most simple jsonschema for validating the necessary metadata
  2. Understand when we should switch to this schema

With some hacky tinkering I managed to create the following schema:

schema = {
  "type": "object",
  "required": ["bundle", "name", "docs", "applications"],
  "properties": {
    "bundle": {"type": "string"},
    "name": {"type": "string"},
    "docs": {"type": "string", "format": "uri"},
    "applications": {
      "type": "object",
      "patternProperties": {
        "^.*": {
          "type": "object",
          "required": ["charm", "channel", "trust", "scale"],
          "properties": {
            "charm": {"type": "string"},
            "channel": {"type": "string"},
            "trust": {"type": "boolean"},
            "scale": {"type": "integer"},
            "_github_repo_name": {"type": "string"},
            "_github_repo_branch": {"type": "string"},
          },
          "oneOf": [
            {"required": ["_github_repo_name", "_github_repo_branch"]},
            {"required": ["_github_dependency_repo_name", "_github_dependency_repo_branch"]}
          ]
        }
      }
    }
  }
}

Definition of Done

We have a clear jsonschema for the bundle and decide if we want to switch to this approach

@kimwnasptd kimwnasptd added the enhancement New feature or request label Sep 6, 2024
Copy link

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/KF-6210.

This message was autogenerated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant