From 7c00fd2761e6efffe763ece5d08d9a6d3fb95092 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Mon, 5 Oct 2020 19:46:28 -0700 Subject: Add interface with json schema, fix flake-less issues, put setActivate and jsonSchema check in flake lib --- interface/README.md | 32 ++++++++++++++++ interface/deploy.json | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 interface/README.md create mode 100644 interface/deploy.json (limited to 'interface') diff --git a/interface/README.md b/interface/README.md new file mode 100644 index 0000000..c6b52bd --- /dev/null +++ b/interface/README.md @@ -0,0 +1,32 @@ +A flake must have a `deploy` output with the following structure: + +``` +deploy +├── +└── nodes + ├── + │   ├── + │   ├── hostname + │   └── profiles + │   ├── + │   │   ├── + │   │   ├── bootstrap + │   │   └── path + │   └── ... + └── ... + +``` + +Where `` are all optional and can be one or multiple of: + +- `sshUser` -- user to connect as +- `user` -- user to install and activate profiles with +- `sshOpts` -- options passed to `nix copy` and `ssh` +- `fastConnection` -- whether the connection from this host to the target one is fast (if it is, don't substitute on target and copy the entire closure) [default: `false`] +- `autoRollback` -- whether to roll back when the deployment fails [default: `false`] + +A formal definition for the structure can be found in [the JSON schema](./deploy.json) + +For every profile of every node, arguments are merged with `` taking precedence over `` and `` taking precedence over top-level. + +Values can be overridden for all the profiles deployed by setting environment variables with the same names as the profile, for example `sshUser=foobar nix run github:serokell/deploy .` will connect to all nodes as `foobar@.hostname`. diff --git a/interface/deploy.json b/interface/deploy.json new file mode 100644 index 0000000..aaa6534 --- /dev/null +++ b/interface/deploy.json @@ -0,0 +1,103 @@ +{ + "$schema": "http://json-schema.org/draft/2019-09/schema#", + "title": "Deploy", + "description": "Matches a correct deploy attribute of a flake", + "definitions": { + "generic_settings": { + "type": "object", + "properties": { + "sshUser": { + "type": "string" + }, + "user": { + "type": "string" + }, + "sshOpts": { + "type": "array", + "items": { + "type": "string" + } + }, + "fastConnection": { + "type": "boolean" + }, + "autoRollback": { + "type": "boolean" + } + } + }, + "node_settings": { + "type": "object", + "properties": { + "hostname": { + "type": "string" + } + }, + "required": [ + "hostname" + ] + }, + "profile_settings": { + "type": "object", + "properties": { + "path": { + "type": "string" + }, + "bootstrap": { + "type": "string" + } + }, + "required": [ + "path" + ] + } + }, + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/generic_settings" + }, + { + "type": "object", + "properties": { + "nodes": { + "type": "object", + "patternProperties": { + "[A-z][A-z0-9_-]*": { + "allOf": [ + { + "$ref": "#/definitions/generic_settings" + }, + { + "$ref": "#/definitions/node_settings" + }, + { + "type": "object", + "properties": { + "profiles": { + "type": "object", + "patternProperties": { + "[A-z][A-z0-9_-]*": { + "allOf": [ + { + "$ref": "#/definitions/generic_settings" + }, + { + "$ref": "#/definitions/profile_settings" + } + ] + } + }, + "additionalProperties": false + } + } + } + ] + } + }, + "additionalProperties": false + } + } + } + ] +} \ No newline at end of file -- cgit v1.2.3 From aabcf6b77d4159100a49b143cbb8da4bad194f14 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Mon, 5 Oct 2020 20:10:41 -0700 Subject: Improve schema a bit, fix flake locks for examples --- interface/deploy.json | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) (limited to 'interface') diff --git a/interface/deploy.json b/interface/deploy.json index aaa6534..310e926 100644 --- a/interface/deploy.json +++ b/interface/deploy.json @@ -31,6 +31,29 @@ "properties": { "hostname": { "type": "string" + }, + "profilesOrder": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "profiles": { + "type": "object", + "patternProperties": { + "[A-z][A-z0-9_-]*": { + "allOf": [ + { + "$ref": "#/definitions/generic_settings" + }, + { + "$ref": "#/definitions/profile_settings" + } + ] + } + }, + "additionalProperties": false } }, "required": [ @@ -70,27 +93,6 @@ }, { "$ref": "#/definitions/node_settings" - }, - { - "type": "object", - "properties": { - "profiles": { - "type": "object", - "patternProperties": { - "[A-z][A-z0-9_-]*": { - "allOf": [ - { - "$ref": "#/definitions/generic_settings" - }, - { - "$ref": "#/definitions/profile_settings" - } - ] - } - }, - "additionalProperties": false - } - } } ] } -- cgit v1.2.3 From 518f7f5b4f1db83cab61941ab8887b0df76ce8d8 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Thu, 8 Oct 2020 18:13:26 -0700 Subject: Update documentation --- interface/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'interface') diff --git a/interface/README.md b/interface/README.md index c6b52bd..bfca01e 100644 --- a/interface/README.md +++ b/interface/README.md @@ -7,6 +7,7 @@ deploy ├── │   ├── │   ├── hostname + │   ├── profilesOrder │   └── profiles │   ├── │   │   ├── @@ -14,7 +15,6 @@ deploy │   │   └── path │   └── ... └── ... - ``` Where `` are all optional and can be one or multiple of: @@ -29,4 +29,4 @@ A formal definition for the structure can be found in [the JSON schema](./deploy For every profile of every node, arguments are merged with `` taking precedence over `` and `` taking precedence over top-level. -Values can be overridden for all the profiles deployed by setting environment variables with the same names as the profile, for example `sshUser=foobar nix run github:serokell/deploy .` will connect to all nodes as `foobar@.hostname`. +Certain read values can be overridden by supplying flags to the deploy binary, for example `deploy --auto-rollback true .` will enable automatic rollback for all nodes being deployed to, regardless of settings. \ No newline at end of file -- cgit v1.2.3 From db8301a45796cd919cbfa085f85ac6288e73a8db Mon Sep 17 00:00:00 2001 From: notgne2 Date: Sat, 10 Oct 2020 10:31:55 -0700 Subject: Add profile path option to profiles --- interface/deploy.json | 3 +++ 1 file changed, 3 insertions(+) (limited to 'interface') diff --git a/interface/deploy.json b/interface/deploy.json index 310e926..19da486 100644 --- a/interface/deploy.json +++ b/interface/deploy.json @@ -68,6 +68,9 @@ }, "bootstrap": { "type": "string" + }, + "profilePath": { + "type": "string" } }, "required": [ -- cgit v1.2.3 From 867438bfc011e63b633b9d6fa2b0edb3367ea253 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Sat, 10 Oct 2020 10:42:14 -0700 Subject: Document `profilePath` option --- interface/README.md | 1 + 1 file changed, 1 insertion(+) (limited to 'interface') diff --git a/interface/README.md b/interface/README.md index bfca01e..99afeb2 100644 --- a/interface/README.md +++ b/interface/README.md @@ -12,6 +12,7 @@ deploy │   ├── │   │   ├── │   │   ├── bootstrap + │   │   ├── profilePath │   │   └── path │   └── ... └── ... -- cgit v1.2.3 From b2326d8694465718024e63c691fe9920c416489e Mon Sep 17 00:00:00 2001 From: notgne2 Date: Sun, 11 Oct 2020 15:23:58 -0700 Subject: Add missing license information --- interface/README.md | 6 ++++++ interface/deploy.json.license | 3 +++ 2 files changed, 9 insertions(+) create mode 100644 interface/deploy.json.license (limited to 'interface') diff --git a/interface/README.md b/interface/README.md index 99afeb2..f61a69f 100644 --- a/interface/README.md +++ b/interface/README.md @@ -1,3 +1,9 @@ + + A flake must have a `deploy` output with the following structure: ``` diff --git a/interface/deploy.json.license b/interface/deploy.json.license new file mode 100644 index 0000000..9e9897d --- /dev/null +++ b/interface/deploy.json.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2020 Serokell + +SPDX-License-Identifier: MPL-2.0 \ No newline at end of file -- cgit v1.2.3 From ea717911bac5ff29d730d80d4b774fe17ed1e851 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Tue, 13 Oct 2020 19:06:40 -0700 Subject: Clean up some CLI arguments, make magic rollback optional --- interface/deploy.json | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'interface') diff --git a/interface/deploy.json b/interface/deploy.json index 19da486..93bacb8 100644 --- a/interface/deploy.json +++ b/interface/deploy.json @@ -23,6 +23,15 @@ }, "autoRollback": { "type": "boolean" + }, + "magicRollback": { + "type": "boolean" + }, + "confirmTimeout": { + "type": "int" + }, + "tempPath": { + "type": "integer" } } }, -- cgit v1.2.3 From c7b1e9d9617ef02f974f56a47f4a0ee3fbf4020e Mon Sep 17 00:00:00 2001 From: notgne2 Date: Tue, 13 Oct 2020 19:10:07 -0700 Subject: Fix json schema --- interface/deploy.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'interface') diff --git a/interface/deploy.json b/interface/deploy.json index 93bacb8..fa45e50 100644 --- a/interface/deploy.json +++ b/interface/deploy.json @@ -28,10 +28,10 @@ "type": "boolean" }, "confirmTimeout": { - "type": "int" + "type": "integer" }, "tempPath": { - "type": "integer" + "type": "string" } } }, -- cgit v1.2.3