Skip to content

Added schema and contracts for blueprints.#28

Open
nazrhom wants to merge 5 commits intonew-contract-schemafrom
blueprints-contracts-schema
Open

Added schema and contracts for blueprints.#28
nazrhom wants to merge 5 commits intonew-contract-schemafrom
blueprints-contracts-schema

Conversation

@nazrhom
Copy link
Copy Markdown

@nazrhom nazrhom commented May 21, 2018

Change-type: minor

Comment thread schema/sw.blueprint.json Outdated
"properties": {
"filename": {
"$id": "/properties/output/properties/filename",
"type": "string"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we can add a pattern here to denote an fs path in UNIX style (with slashes, etc)?

Comment thread schema/sw.blueprint.json
"definitions": {},
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"data": {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You should add a required property for this object.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

done

Comment thread schema/sw.blueprint.json Outdated
"type": "object",
"patternProperties": {
"^.*$": {
"type": "string",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Keep in mind that selectors might also be an array, so we need to support both. ie:

'sw.arch': [ 1, 3 ]

Comment thread schema/sw.blueprint.json
"$id": "/properties/output/properties/template/items",
"type": "object",
"additionalProperties": false,
"properties": {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you mark these properties as required?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

done

Comment thread schema/sw.blueprint.json
"$ref": "contract.json#/definitions/partialContract"
},
{
"properties": {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you're missing slug and type here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

slug and type come from the above reference to a partial contract (line 25). The spec says

An object describing how the resulting contexts should look like. You may use properties such as `type`, `slug`, `data`, etc. You may use blueprint results to construct certain properties by accessing children through the `children` property

Which I took to intend that output may contain any top-level field that appears in a contract, should it be restricted to a subset of those props?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, you're right. Nevermind

"template": [
{
"name": "docker-images",
"data": "{{import partial=\"from\" combination=\"sw.os+sw.arch\"}}\nLABEL io.resin.architecture=\"{{sw.arch.slug}}\"\n{{import partial=\"os-config\" combination=\"sw.os+sw.arch\"}}\n{{#sw.blob.qemu}} {{import partial=\"qemu\" combination=\"sw.os+sw.arch\"}} {{/sw.blob.qemu}}\n{{import partial=\"base-dependencies\" combination=\"sw.os+sw.arch\"}}\nCOPY {{sw.blob.resin-xbuild.assets.bin.main}} /usr/bin/\nRUN ln -s {{sw.blob.resin-xbuild.assets.bin.main}} /usr/bin/cross-build-start \\\n && ln -s {{sw.blob.resin-xbuild.assets.bin.main}} /usr/bin/cross-build-end\n\nENV TINI_VERSION {{sw.blob.tini.version}}\nRUN chmod +x {{sw.blob.tini.assets.bin.main}} \\\n && mv {{sw.blob.tini.assets.bin.main}} /sbin/tini\n\n{{import partial=\"init-system\" combination=\"sw.os+sw.arch\"}}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ugh :P Lets aim to convert contracts to YAML sometime soon :P

"componentVersion": "1",
"aliases": [],
"tags": [],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Any reason for this blank line?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

mostly to split up the generic contract props with the ones that are specific to the blueprint type, we can drop it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Guys, could you point me to some description of these general properties? Specifically, slug, type, aliases, and tags. Thanks!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@roman-mazur

  • slug: A human readable unique identifier. Both the id and the slug are considered to be primary keys of an element
  • type: The type of entity a contract defines, such as user, message, repository, etc. The properties you must define in the contract depend on the type of entity
  • aliases: Alternative slugs for the element. You can fetch an element by slug using any of the aliases, but the one in slug is the canonical one. For example, if you describe the raspberry pi 3, its canonical slug may be raspberrypi3 but we also put the following aliases [ rpi3, raspberry-pi3 ]
  • tags: An array of free form strings that you attach to the contract. Can be anything and the way they are used are context-specific. For example we use #pendinguserresponse to categorise support threads when doing support

@nghiant2710 nghiant2710 force-pushed the new-contract-schema branch 2 times, most recently from 40e9af2 to ef17200 Compare May 21, 2018 17:21
@nazrhom nazrhom force-pushed the blueprints-contracts-schema branch from bed0496 to a2e1af0 Compare May 22, 2018 09:55
@nazrhom nazrhom force-pushed the blueprints-contracts-schema branch from a2e1af0 to 11cf69c Compare May 28, 2018 09:41
@nazrhom nazrhom requested a review from jviotti May 28, 2018 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants