diff options
author | notgne2 | 2020-10-05 19:46:28 -0700 |
---|---|---|
committer | notgne2 | 2020-10-05 19:46:28 -0700 |
commit | 7c00fd2761e6efffe763ece5d08d9a6d3fb95092 (patch) | |
tree | 9d4030bd4788bec3eb4783adc38130536d8fa696 /interface | |
parent | 5674670a59168fb05f26e5b4fb41dd2662810e94 (diff) |
Add interface with json schema, fix flake-less issues, put setActivate and jsonSchema check in flake lib
Diffstat (limited to 'interface')
-rw-r--r-- | interface/README.md | 32 | ||||
-rw-r--r-- | interface/deploy.json | 103 |
2 files changed, 135 insertions, 0 deletions
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 +├── <generic args> +└── nodes + ├── <NODE> + │ ├── <generic args> + │ ├── hostname + │ └── profiles + │ ├── <PROFILE> + │ │ ├── <generic args> + │ │ ├── bootstrap + │ │ └── path + │ └── <PROFILE>... + └── <NODE>... + +``` + +Where `<generic args>` 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 `<PROFILE>` taking precedence over `<NODE>` and `<NODE>` 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@<NODE>.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 |