From 13181a52ee1931a0e21cb7c546d53249d6429891 Mon Sep 17 00:00:00 2001 From: benne-dee <78043691+benne-dee@users.noreply.github.com> Date: Wed, 27 Jan 2021 22:38:40 +0530 Subject: [PATCH 1/3] Define schema for groups in netinstall.schema.yaml --- src/modules/netinstall/netinstall.schema.yaml | 60 ++++++++++++++++++- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/src/modules/netinstall/netinstall.schema.yaml b/src/modules/netinstall/netinstall.schema.yaml index a66c877d1..61ab1c8f4 100644 --- a/src/modules/netinstall/netinstall.schema.yaml +++ b/src/modules/netinstall/netinstall.schema.yaml @@ -1,8 +1,64 @@ # SPDX-FileCopyrightText: 2020 Adriaan de Groot # SPDX-License-Identifier: GPL-3.0-or-later --- -$schema: https://json-schema.org/schema# +$schema: http://json-schema.org/draft-07/schema# $id: https://calamares.io/schemas/netinstall +definitions: + package: + $id: '#definitions/package' + oneOf: + - + type: string + description: bare package - actual package name as passed to the package manager + (e.g. `qt5-creator-dev`). + - + type: object + description: rich package - one with a package-name (for the package-manager) and + a description (for the human). + properties: + name: { type: string } + description: { type: string } + group: + $id: '#definitions/group' + type: object + description: Longer discussion in `netinstall.conf` file under 'Groups Format' + properties: + name: { type: string } + description: { type: string } + packages: + type: array + items: { $ref: '#definitions/package' } + hidden: { type: boolean, default: false } + selected: { type: boolean } + critical: { type: boolean, default: false } + immutable: { type: boolean } + expanded: { type: boolean } + subgroups: + type: array + items: { $ref: '#definitions/group' } + pre-install: + type: string + description: an optional command to run within the new system before the group's + packages are installed. It will run before **each** package in the group + is installed. + post-install: + type: string + description: an optional command to run within the new system after the group's + packages are installed. It will run after **each** package in the group + is installed. + required: [name, description] # Always required, at any level in the subgroups hirearchy + if: + properties: + subgroups: + maxItems: 0 + then: + required: [name, description, packages] # bottom-most (sub)group requires some package (otherwise, why bother?) + # This should validate `netinstall.yaml` also. + groups: + $id: '#definitions/groups' + type: array + items: { $ref: '#definitions/group' } + additionalProperties: false type: object properties: @@ -14,5 +70,5 @@ properties: properties: sidebar: { type: string } title: { type: string } - groups: { type: array } # TODO: the schema for the whole groups file + groups: { $ref: '#definitions/groups' } # DONE: the schema for groups required: [ groupsUrl ] From f8385d2cb8912f9cdcf5cdebd52a002535a7016a Mon Sep 17 00:00:00 2001 From: benne-dee <78043691+benne-dee@users.noreply.github.com> Date: Wed, 27 Jan 2021 23:12:29 +0530 Subject: [PATCH 2/3] Fix https in URL --- src/modules/netinstall/netinstall.schema.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/netinstall/netinstall.schema.yaml b/src/modules/netinstall/netinstall.schema.yaml index 61ab1c8f4..e1db5715e 100644 --- a/src/modules/netinstall/netinstall.schema.yaml +++ b/src/modules/netinstall/netinstall.schema.yaml @@ -1,7 +1,7 @@ # SPDX-FileCopyrightText: 2020 Adriaan de Groot # SPDX-License-Identifier: GPL-3.0-or-later --- -$schema: http://json-schema.org/draft-07/schema# +$schema: https://json-schema.org/draft-07/schema# $id: https://calamares.io/schemas/netinstall definitions: package: From f0aa515c8bcd59e8bc0449dd6c29fc6cd6d8ad08 Mon Sep 17 00:00:00 2001 From: benne-dee <78043691+benne-dee@users.noreply.github.com> Date: Mon, 22 Feb 2021 22:17:06 +0530 Subject: [PATCH 3/3] [netinstall] Schema validates also groups file --- src/modules/netinstall/netinstall.schema.yaml | 45 ++++++++++++------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/src/modules/netinstall/netinstall.schema.yaml b/src/modules/netinstall/netinstall.schema.yaml index e1db5715e..05ab4cd08 100644 --- a/src/modules/netinstall/netinstall.schema.yaml +++ b/src/modules/netinstall/netinstall.schema.yaml @@ -1,4 +1,5 @@ # SPDX-FileCopyrightText: 2020 Adriaan de Groot +# SPDX-FileContributor: benne-dee ( worked on groups schema ) # SPDX-License-Identifier: GPL-3.0-or-later --- $schema: https://json-schema.org/draft-07/schema# @@ -7,11 +8,11 @@ definitions: package: $id: '#definitions/package' oneOf: - - + - type: string description: bare package - actual package name as passed to the package manager (e.g. `qt5-creator-dev`). - - + - type: object description: rich package - one with a package-name (for the package-manager) and a description (for the human). @@ -59,16 +60,30 @@ definitions: type: array items: { $ref: '#definitions/group' } -additionalProperties: false -type: object -properties: - groupsUrl: { type: string } - required: { type: boolean, default: false } - label: # Translatable labels - type: object - additionalProperties: true - properties: - sidebar: { type: string } - title: { type: string } - groups: { $ref: '#definitions/groups' } # DONE: the schema for groups -required: [ groupsUrl ] +oneOf: +- # netinstall.conf + type: object + description: netinstall.conf schema + additionalProperties: false + properties: + groupsUrl: { type: string } + required: { type: boolean, default: false } + label: # Translatable labels + type: object + additionalProperties: true + properties: + sidebar: { type: string } + title: { type: string } + groups: { $ref: '#definitions/groups' } + required: [ groupsUrl ] + +- # Groups file with top level *groups* key + type: object + description: Groups file with top level *groups* key + additionalProperties: false + properties: + groups: { $ref: '#definitions/groups' } + required: [ groups ] + +- # Groups file bare + { $ref: '#definitions/groups' }