Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(jsonschema): better jobs #441

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "schema for .kontinuous/values.yaml",
"type": "object",
"patternProperties": {
"pg-.*": {
"^pg-.*": {
"allOf": [
{
"$ref": "https://raw.githubusercontent.com/socialgouv/kontinuous/v1/plugins/fabrique/charts/pg/kontinuous.values.schema.json"
Expand All @@ -19,7 +19,7 @@
}
]
},
"app-.*": {
"^app-.*": {
"allOf": [
{
"$ref": "https://raw.githubusercontent.com/socialgouv/kontinuous/v1/plugins/contrib/charts/app/kontinuous.values.schema.json"
Expand Down
110 changes: 67 additions & 43 deletions plugins/contrib/charts/jobs/kontinuous.values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,10 @@
]
},
"image": {
"type": "string"
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.24.0/_definitions.json#/definitions/io.k8s.api.core.v1.Container/properties/image"
},
"entrypoint": {
"description": "Docker image entrypoint arguments",
"examples": ["['sh', '-c', 'echo 42']"],
"type": "array",
"items": {
"type": "string"
}
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.24.0/_definitions.json#/definitions/io.k8s.api.core.v1.Container/properties/command"
},
"checkout": {
"description": "Should the repo be checked-out to build. defaults to true",
Expand Down Expand Up @@ -69,42 +64,51 @@
"description": "Kubernetes cpu reservation for the Job",
"type": "string"
},
"with": { "type": "object", "additionalProperties": true }
"args": {
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.24.0/_definitions.json#/definitions/io.k8s.api.core.v1.Container/properties/args"
},
"envFrom": {
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.24.0/_definitions.json#/definitions/io.k8s.api.core.v1.Container/properties/envFrom"
},
"env": {
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.24.0/_definitions.json#/definitions/io.k8s.api.core.v1.Container/properties/env"
},
"volumeMounts": {
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.24.0/_definitions.json#/definitions/io.k8s.api.core.v1.Container/properties/volumeMounts"
},
"volumes": {
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.24.0/_definitions.json#/definitions/io.k8s.api.core.v1.PodSpec/properties/volumes"
},
"seccompProfile": {
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.24.0/_definitions.json#/definitions/io.k8s.api.core.v1.SeccompProfile"
}
},
"required": ["use"],
"if": {
"properties": {
"use": {
"const": "build"
"type": "null"
}
}
},
"then": {
"properties": {
"use": {
"markdownDescription": "Build and register docker image with buildkit.\n\nSee [build source](https://github.com/SocialGouv/kontinuous/tree/master/plugins/contrib/jobs/build)"
},
"with": {
"$ref": "https://raw.githubusercontent.com/socialgouv/kontinuous/v1/plugins/contrib/jobs/build/use.schema.json#"
}
},
"required": ["with"]
"properties": {},
"required": []
},
"else": {
"if": {
"properties": {
"use": {
"const": "build-kaniko"
"const": "build"
}
}
},
"then": {
"properties": {
"use": {
"markdownDescription": "Build and register docker image with kaniko.\n\nSee [build-kaniko source](https://github.com/SocialGouv/kontinuous/tree/master/plugins/contrib/jobs/build-kaniko)"
"markdownDescription": "Build and register docker image with buildkit.\n\nSee [build source](https://github.com/SocialGouv/kontinuous/tree/master/plugins/contrib/jobs/build)"
},
"with": {
"$ref": "https://raw.githubusercontent.com/socialgouv/kontinuous/v1/plugins/contrib/jobs/build-kaniko/use.schema.json#"
"$ref": "https://raw.githubusercontent.com/socialgouv/kontinuous/v1/plugins/contrib/jobs/build/use.schema.json#"
}
},
"required": ["with"]
Expand All @@ -113,55 +117,55 @@
"if": {
"properties": {
"use": {
"const": "create-db"
"const": "build-kaniko"
}
}
},
"then": {
"properties": {
"use": {
"markdownDescription": "Create a Postgres Database\n\nSee [create-db source](https://github.com/SocialGouv/kontinuous/tree/master/plugins/contrib/jobs/create-db)"
"markdownDescription": "Build and register docker image with kaniko.\n\nSee [build-kaniko source](https://github.com/SocialGouv/kontinuous/tree/master/plugins/contrib/jobs/build-kaniko)"
},
"with": {
"$ref": "https://raw.githubusercontent.com/socialgouv/kontinuous/v1/plugins/contrib/jobs/create-db/use.schema.json#"
"$ref": "https://raw.githubusercontent.com/socialgouv/kontinuous/v1/plugins/contrib/jobs/build-kaniko/use.schema.json#"
}
},
"required": []
"required": ["with"]
},
"else": {
"if": {
"properties": {
"use": {
"const": "deactivate"
"const": "create-db"
}
}
},
"then": {
"properties": {
"use": {
"markdownDescription": "Destroy namespace and databases\n\nSee [deactivate source](https://github.com/SocialGouv/kontinuous/tree/master/plugins/contrib/jobs/deactivate)"
"markdownDescription": "Create a Postgres Database\n\nSee [create-db source](https://github.com/SocialGouv/kontinuous/tree/master/plugins/contrib/jobs/create-db)"
},
"with": {
"$ref": "https://raw.githubusercontent.com/socialgouv/kontinuous/v1/plugins/contrib/jobs/deactivate/use.schema.json#"
"$ref": "https://raw.githubusercontent.com/socialgouv/kontinuous/v1/plugins/contrib/jobs/create-db/use.schema.json#"
}
},
"required": ["with"]
"required": []
},
"else": {
"if": {
"properties": {
"use": {
"const": "drop-db"
"const": "deactivate"
}
}
},
"then": {
"properties": {
"use": {
"markdownDescription": "Destroy the database\n\nSee [drop-db source](https://github.com/SocialGouv/kontinuous/tree/master/plugins/contrib/jobs/drop-db)"
"markdownDescription": "Destroy namespace and databases\n\nSee [deactivate source](https://github.com/SocialGouv/kontinuous/tree/master/plugins/contrib/jobs/deactivate)"
},
"with": {
"$ref": "https://raw.githubusercontent.com/socialgouv/kontinuous/v1/plugins/contrib/jobs/drop-db/use.schema.json#"
"$ref": "https://raw.githubusercontent.com/socialgouv/kontinuous/v1/plugins/contrib/jobs/deactivate/use.schema.json#"
}
},
"required": ["with"]
Expand All @@ -170,17 +174,17 @@
"if": {
"properties": {
"use": {
"const": "pg-restore"
"const": "drop-db"
}
}
},
"then": {
"properties": {
"use": {
"markdownDescription": "Restore the database from a backup storage\n\nSee [pg-restore source](https://github.com/SocialGouv/kontinuous/tree/master/plugins/contrib/jobs/pg-restore)"
"markdownDescription": "Destroy the database\n\nSee [drop-db source](https://github.com/SocialGouv/kontinuous/tree/master/plugins/contrib/jobs/drop-db)"
},
"with": {
"$ref": "https://raw.githubusercontent.com/socialgouv/kontinuous/v1/plugins/contrib/jobs/pg-restore/use.schema.json#"
"$ref": "https://raw.githubusercontent.com/socialgouv/kontinuous/v1/plugins/contrib/jobs/drop-db/use.schema.json#"
}
},
"required": ["with"]
Expand All @@ -189,17 +193,17 @@
"if": {
"properties": {
"use": {
"const": "psql"
"const": "pg-restore"
}
}
},
"then": {
"properties": {
"use": {
"markdownDescription": "Execute psql commands on the database\n\nSee [psql source](https://github.com/SocialGouv/kontinuous/tree/master/plugins/contrib/jobs/psql)"
"markdownDescription": "Restore the database from a backup storage\n\nSee [pg-restore source](https://github.com/SocialGouv/kontinuous/tree/master/plugins/contrib/jobs/pg-restore)"
},
"with": {
"$ref": "https://raw.githubusercontent.com/socialgouv/kontinuous/v1/plugins/contrib/jobs/psql/use.schema.json#"
"$ref": "https://raw.githubusercontent.com/socialgouv/kontinuous/v1/plugins/contrib/jobs/pg-restore/use.schema.json#"
}
},
"required": ["with"]
Expand All @@ -208,22 +212,42 @@
"if": {
"properties": {
"use": {
"const": "seed-db"
"const": "psql"
}
}
},
"then": {
"properties": {
"use": {
"markdownDescription": "Execute a repository .sql on the database\n\nSee [seed-db source](https://github.com/SocialGouv/kontinuous/tree/master/plugins/contrib/jobs/seed-db)"
"markdownDescription": "Execute psql commands on the database\n\nSee [psql source](https://github.com/SocialGouv/kontinuous/tree/master/plugins/contrib/jobs/psql)"
},
"with": {
"$ref": "https://raw.githubusercontent.com/socialgouv/kontinuous/v1/plugins/contrib/jobs/seed-db/use.schema.json#"
"$ref": "https://raw.githubusercontent.com/socialgouv/kontinuous/v1/plugins/contrib/jobs/psql/use.schema.json#"
}
},
"required": ["with"]
},
"else": {}
"else": {
"if": {
"properties": {
"use": {
"const": "seed-db"
}
}
},
"then": {
"properties": {
"use": {
"markdownDescription": "Execute a repository .sql on the database\n\nSee [seed-db source](https://github.com/SocialGouv/kontinuous/tree/master/plugins/contrib/jobs/seed-db)"
},
"with": {
"$ref": "https://raw.githubusercontent.com/socialgouv/kontinuous/v1/plugins/contrib/jobs/seed-db/use.schema.json#"
}
},
"required": ["with"]
},
"else": {}
}
}
}
}
Expand Down