Skip to content

Commit

Permalink
feat: Check if the .sugar.yaml file is valid according to the schema …
Browse files Browse the repository at this point in the history
…file
  • Loading branch information
xmnlab committed Oct 17, 2024
1 parent da19b71 commit 6772f88
Show file tree
Hide file tree
Showing 2 changed files with 177 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
default_stages:
- commit
- pre-commit

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
176 changes: 176 additions & 0 deletions src/sugar/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Sugar Configuration Schema",
"type": "object",
"properties": {
"backend": {
"type": "string",
"enum": ["compose"]
},
"env-file": {
"type": "string"
},
"defaults": {
"type": "object",
"properties": {
"group": {
"type": "string"
},
"project-name": {
"type": "string"
}
},
"required": ["group", "project-name"],
"additionalProperties": false
},
"hooks": {
"type": "object",
"properties": {
"pre-run": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"targets": {
"type": "object",
"patternProperties": {
"^[a-zA-Z0-9_-]+$": {
"type": "array",
"items": {
"type": "string"
}
}
},
"additionalProperties": false
},
"run": {
"type": "string"
}
},
"required": ["name", "targets", "run"],
"additionalProperties": false
}
},
"post-run": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"targets": {
"type": "object",
"patternProperties": {
"^[a-zA-Z0-9_-]+$": {
"type": "array",
"items": {
"type": "string"
}
}
},
"additionalProperties": false
},
"run": {
"type": "string"
}
},
"required": ["name", "targets", "run"],
"additionalProperties": false
}
}
},
"required": ["pre-run", "post-run"],
"additionalProperties": false
},
"groups": {
"type": "object",
"patternProperties": {
"^[a-zA-Z0-9_-]+$": {
"type": "object",
"properties": {
"project-name": {
"type": "string"
},
"config-path": {
"anyOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
},
"env-file": {
"type": "string"
},
"services": {
"type": "object",
"properties": {
"default": {
"type": "string"
},
"available": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
}
},
"required": ["name"],
"additionalProperties": false
}
}
},
"required": ["available"],
"additionalProperties": false
}
},
"required": ["config-path", "env-file", "services"],
"additionalProperties": false
}
},
"additionalProperties": false
},
"services": {
"type": "object",
"properties": {
"project-name": {
"type": "string"
},
"config-path": {
"type": "string"
},
"default": {
"type": "string"
},
"available": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
}
},
"required": ["name"],
"additionalProperties": false
}
}
},
"required": ["project-name", "config-path", "default", "available"],
"additionalProperties": false
}
},
"required": ["backend"],
"additionalProperties": false
}

0 comments on commit 6772f88

Please sign in to comment.