From b9579a2c7b6421264d64b516e287a480100553f3 Mon Sep 17 00:00:00 2001 From: "Luis Gustavo S. Barreto" Date: Fri, 23 Feb 2018 16:05:50 -0300 Subject: [PATCH] metadata: add mender object Signed-off-by: Luis Gustavo S. Barreto --- pkgschema/schemas/definitions.json | 2 +- pkgschema/schemas/mender-object.json | 33 +++++++++++++++++++ pkgschema/schemas/metadata.json | 3 +- tests/pkgschema/fixture-metadata.json | 4 +++ .../mender-object/expected-document.json | 4 +++ .../invalid-filename-property-type.json | 4 +++ .../invalid-mode-property-choice.json | 4 +++ .../without-filename-property.json | 3 ++ .../mender-object/without-mode-property.json | 3 ++ 9 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 pkgschema/schemas/mender-object.json create mode 100644 tests/schemas/fixtures/mender-object/expected-document.json create mode 100644 tests/schemas/fixtures/mender-object/invalid-filename-property-type.json create mode 100644 tests/schemas/fixtures/mender-object/invalid-mode-property-choice.json create mode 100644 tests/schemas/fixtures/mender-object/without-filename-property.json create mode 100644 tests/schemas/fixtures/mender-object/without-mode-property.json diff --git a/pkgschema/schemas/definitions.json b/pkgschema/schemas/definitions.json index 66aca7a..b0a81ea 100644 --- a/pkgschema/schemas/definitions.json +++ b/pkgschema/schemas/definitions.json @@ -2,7 +2,7 @@ "mode": { "description": "Represents the install mode for the object data", "type": "string", - "enum": ["copy", "flash", "imxkobs", "raw", "tarball", "ubifs"] + "enum": ["copy", "flash", "imxkobs", "raw", "tarball", "ubifs", "mender"] }, "filename": { "description": "file name used by client to rebuild the commit", diff --git a/pkgschema/schemas/mender-object.json b/pkgschema/schemas/mender-object.json new file mode 100644 index 0000000..f27cd43 --- /dev/null +++ b/pkgschema/schemas/mender-object.json @@ -0,0 +1,33 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + + "title": "Mender object", + "description": "Object specifications for Mender mode", + + "type": "object", + + "properties": { + "mode": { + "$ref": "definitions.json#/mode" + }, + "filename": { + "$ref": "definitions.json#/filename" + } + }, + + "required": [ + "filename" + ], + + "additionalProperties": false, + + "dependencies": { + "mode": { + "properties": { + "mode": { + "enum": ["mender"] + } + } + } + } +} diff --git a/pkgschema/schemas/metadata.json b/pkgschema/schemas/metadata.json index fa96d03..7802d68 100644 --- a/pkgschema/schemas/metadata.json +++ b/pkgschema/schemas/metadata.json @@ -44,7 +44,8 @@ {"$ref": "imxkobs-object.json"}, {"$ref": "raw-object.json"}, {"$ref": "tarball-object.json"}, - {"$ref": "ubifs-object.json"} + {"$ref": "ubifs-object.json"}, + {"$ref": "mender-object.json"} ] }, "minItems": 1 diff --git a/tests/pkgschema/fixture-metadata.json b/tests/pkgschema/fixture-metadata.json index a52e902..7af7253 100644 --- a/tests/pkgschema/fixture-metadata.json +++ b/tests/pkgschema/fixture-metadata.json @@ -80,6 +80,10 @@ "target": "/dev/sda", "target-path": "/usr/bin/python", "mount-options": "-a" + }, + { + "mode": "mender", + "filename": "artifact.mender" } ] ] diff --git a/tests/schemas/fixtures/mender-object/expected-document.json b/tests/schemas/fixtures/mender-object/expected-document.json new file mode 100644 index 0000000..f7b82d6 --- /dev/null +++ b/tests/schemas/fixtures/mender-object/expected-document.json @@ -0,0 +1,4 @@ +{ + "filename": "artifact.mender", + "mode": "mender" +} diff --git a/tests/schemas/fixtures/mender-object/invalid-filename-property-type.json b/tests/schemas/fixtures/mender-object/invalid-filename-property-type.json new file mode 100644 index 0000000..e8afbd0 --- /dev/null +++ b/tests/schemas/fixtures/mender-object/invalid-filename-property-type.json @@ -0,0 +1,4 @@ +{ + "filename": 1, + "mode": "mender" +} diff --git a/tests/schemas/fixtures/mender-object/invalid-mode-property-choice.json b/tests/schemas/fixtures/mender-object/invalid-mode-property-choice.json new file mode 100644 index 0000000..2af808c --- /dev/null +++ b/tests/schemas/fixtures/mender-object/invalid-mode-property-choice.json @@ -0,0 +1,4 @@ +{ + "mode": "tarball", + "filename": "artifact.mender" +} diff --git a/tests/schemas/fixtures/mender-object/without-filename-property.json b/tests/schemas/fixtures/mender-object/without-filename-property.json new file mode 100644 index 0000000..1025629 --- /dev/null +++ b/tests/schemas/fixtures/mender-object/without-filename-property.json @@ -0,0 +1,3 @@ +{ + "mode": "mender" +} diff --git a/tests/schemas/fixtures/mender-object/without-mode-property.json b/tests/schemas/fixtures/mender-object/without-mode-property.json new file mode 100644 index 0000000..fcb111f --- /dev/null +++ b/tests/schemas/fixtures/mender-object/without-mode-property.json @@ -0,0 +1,3 @@ +{ + "filename": "artifact.mender" +}