oasis-tcs / tosca-specs

OASIS TOSCA TC: This repository contains drafts of the TOSCA TC’s specifications and committee notes. https://github.com/oasis-tcs/tosca-specs
Other
5 stars 5 forks source link

Validate all TOSCA examples #56

Open lauwers opened 4 months ago

lauwers commented 4 months ago

Rather than using TOSCA code snippets in the examples, a recommendation was made to use complete TOSCA code that can be validated by a TOSCA parser.

pmjordan commented 1 month ago

I suggest that this could be resolved as follows:

  1. bracket snippets in the specification with a unique start and end tag using HTML comments. eg. ` <!— SNIPPET_BEGIN:TagOne -->

‘‘‘yaml metadata: creation_date: 2024-04-14 date_updated: 2024-05-01 status: developmental

<!— SNIPPET_END --> `

  1. Create a folder in the existing repo containing full, valid TOSCA documents. Bracket snippets with a matching start tag and an end tag using YAML comments e.g. ‘ tosca_definitions_version: tosca_2_0 # SNIPPET_BEGIN:TagOne metadata: creation_date: 2024-04-14 date_updated: 2024-05-01 status: developmental # SNIPPET_END‘

  2. Create a tool which, at minimum, copies the specification file except where snippets are encoutered, in those blocks subsitute the TOSCA text enclosed by the matching tag found by a search of YAML files in the new folder (taking account of the language marker string in the HTML and the differences in format of the snippet markers. Diff could then be used to compare the temp file with the specification and patch or ed used to change the spec where it contains snippets which do not match the valid TOSCA.

This assumes snippets tags are unique, not nested and always closed. Tool enhancements could be added to check those assumptions.

koppor commented 1 month ago

Discussion: Have a common tool to handle this. Regarding Python: Jinja Syntax could be something (https://jinja.palletsprojects.com/en/3.1.x/templates/). And then create a function includeToscaSnippet(id).

pmjordan commented 1 month ago

'Have a common tool to handle this.' Yes I envision the tool also being maintained in this tosca-spec repo

'Jinja Syntax could be something (https://jinja.palletsprojects.com/en/3.1.x/templates/). ' Jinja would indeed be a standard way to markup the specification so a good thought. As far as I can think so far we would still need a custom tool to parse the TOSCA examples and create a file of value assignments which could be used by the jinja renderer.

pmjordan commented 6 days ago

I am currently enclosing examples in the spec with tags like this:

<!-- EDITOR_TAG{"type":"example","id":"s1","action":"start"} -->
<!-- EDITOR_TAG{"type":"example","id":"s1","action":"end"} -->

There are more than 150 of them, so too many to name individually. I will initally give the files in the examples directory names like s1,s1.. before attempting to consolidate them into fewer files.

lauwers commented 4 days ago

You say "tags like this". I don't see any tags in your comment.

koppor commented 4 days ago

You say "tags like this". I don't see any tags in your comment.

Do you have edit rights? Most probably backticks were forgotten around the tags. It might be that when you edit the comment, you can insert them 😅.

lauwers commented 4 days ago

Thanks. I corrected it.

pmjordan commented 2 days ago

PR213 Moves towards this