Skip to content
This repository was archived by the owner on Dec 12, 2023. It is now read-only.

Update YAML Schema Validation #70

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

krafugo
Copy link
Contributor

@krafugo krafugo commented Sep 11, 2023

Update yaml schemas validation

Changes:

  • Updated manifest and profile YAML schemas
  • Added YAML schema validation functionality from remote repository

Types of changes

  • Modified profile_schema.yml and manifest_schela.yml
  • Added ValidateFromRepository function
  • Added an example to validate all profile,manifest yaml files from mock-avs repository

Testing

Requires testing, No

In case you checked yes, did you write tests? No

Comments about testing, should you have some (optional)

return nil
}

func cloneRepository(url string, path string) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that this function is unnecessary. The responsibility of cloning the repository should be on the NewPackageHandlerFromURL method. Subsequent actions should be performed using the methods of the PackageHandler type returned by it.


//go:embed schema/*
var fs embed.FS

func validateYAMLSchema(schemaFile, documentFile string) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest creating two private methods in PackageHandler:

  • checksProfileSchema
  • checkManifestSchema

return nil
}

func walkDirectories(root string) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this function is unnecessary because the Packagehandler already knows the exact location of the profile.yml and manifest.yml files by following the specification, so there is no need to walk through the entire directory tree. Additionally, this function checks for manifest.yml and profile.yml files that may not be necessary for the specification, as they might be located in a different directory than the one declared in the spec.

Comment on lines +237 to +255
OptionID:
type: object
properties:
name:
type: string
target:
type: string
help:
type: string
type:
const: "id"
default:
type: string
required:
- name
- target
- help
- type
additionalProperties: false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We deprecated ID, this should be removed

Comment on lines +186 to +215
OptionSelect:
type: object
properties:
name:
type: string
target:
type: string
help:
type: string
type:
const: "select"
default:
type: string
validate:
type: object
properties:
options:
type: array
minItems: 1
items:
type: string
required:
- options
additionalProperties: false
required:
- name
- target
- help
- type
additionalProperties: false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validate field must be required for Select. A Select without options makes no sense

- $ref: '#/definitions/OptionURI'
- $ref: '#/definitions/OptionSelect'
- $ref: '#/definitions/OptionPort'
- $ref: '#/definitions/OptionID'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove OptionID, as noted in the above comment.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants