From db8b4af10b531fedf1d13ef7fe2c71dc4b31ab0b Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Wed, 24 Mar 2021 10:01:18 +0000 Subject: [PATCH] Improve zuul schema --- examples/zuul.d/jobs.yaml | 3 +++ f/zuul.json | 39 ++++++++++++++++++++++++++++++++++++++ src/ansibleschemas/zuul.py | 10 ++++++++++ 3 files changed, 52 insertions(+) diff --git a/examples/zuul.d/jobs.yaml b/examples/zuul.d/jobs.yaml index fd29e875..c073f6a6 100644 --- a/examples/zuul.d/jobs.yaml +++ b/examples/zuul.d/jobs.yaml @@ -36,6 +36,7 @@ files: 'pattern' # or list of patterns override-checkout: master success-url: docs/ + failure-url: docs/ secrets: # https://zuul-ci.org/docs/zuul/reference/job_def.html#attr-job.secrets - foo - name: bar @@ -45,6 +46,8 @@ required-projects: - foo - bar + roles: + - zuul: some_role_name - project-template: name: sample-template diff --git a/f/zuul.json b/f/zuul.json index 90f339f7..4e06e3fb 100644 --- a/f/zuul.json +++ b/f/zuul.json @@ -45,6 +45,10 @@ "title": "Description", "type": "string" }, + "failure-url": { + "title": "Failure-Url", + "type": "string" + }, "files": { "anyOf": [ { @@ -66,6 +70,20 @@ "title": "Host-Vars", "type": "object" }, + "irrelevant-files": { + "anyOf": [ + { + "type": "string" + }, + { + "items": { + "type": "string" + }, + "type": "array" + } + ], + "title": "Irrelevant-Files" + }, "name": { "title": "Name", "type": "string" @@ -116,6 +134,13 @@ "title": "Required-Projects", "type": "array" }, + "roles": { + "items": { + "$ref": "#/definitions/ZuulRoleModel" + }, + "title": "Roles", + "type": "array" + }, "run": { "title": "Run", "type": "string" @@ -374,6 +399,20 @@ ], "title": "SecretModel", "type": "object" + }, + "ZuulRoleModel": { + "additionalProperties": false, + "properties": { + "zuul": { + "title": "Zuul", + "type": "string" + } + }, + "required": [ + "zuul" + ], + "title": "ZuulRoleModel", + "type": "object" } }, "items": { diff --git a/src/ansibleschemas/zuul.py b/src/ansibleschemas/zuul.py index bbb5d1e3..2a587568 100644 --- a/src/ansibleschemas/zuul.py +++ b/src/ansibleschemas/zuul.py @@ -68,6 +68,13 @@ class Config: extra = Extra.forbid +class ZuulRoleModel(BaseModel): + zuul: str + + class Config: + extra = Extra.forbid + + class JobModel(BaseModel): # based on https://docs.ansible.com/ansible/latest/reference_appendices/playbooks_keywords.html#play name: str @@ -79,8 +86,10 @@ class JobModel(BaseModel): parent: Optional[str] vars: Optional[Mapping[str, Any]] files: Optional[Union[str, List[str]]] + irrelevant_files: Optional[Union[str, List[str]]] = Field(alias="irrelevant-files") override_checkout: Optional[str] = Field(alias="override-checkout") success_url: Optional[str] = Field(alias="success-url") + failure_url: Optional[str] = Field(alias="failure-url") abstract: Optional[bool] = False voting: Optional[bool] = True timeout: Optional[int] @@ -91,6 +100,7 @@ class JobModel(BaseModel): tags: Optional[Union[str, List[str]]] required_projects: Optional[List[str]] = Field(alias="required-projects") secrets: Optional[Union[JobSecretModel, List[Union[JobSecretModel, str]]]] + roles: Optional[List[ZuulRoleModel]] class Config: extra = Extra.forbid