Skip to content

Commit

Permalink
Add support for ansible-builder v3 schema
Browse files Browse the repository at this point in the history
Signed-off-by: Ajinkya Udgirkar <ajinkyaudgirkar@gmail.com>
  • Loading branch information
audgirka committed May 22, 2023
1 parent bc9ae85 commit ea2e139
Show file tree
Hide file tree
Showing 3 changed files with 292 additions and 53 deletions.
2 changes: 1 addition & 1 deletion src/ansiblelint/rules/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def matchyaml(self, file: Lintable) -> list[MatchError]:
pytest.param(
"examples/ee_broken/execution-environment.yml",
"execution-environment",
["Additional properties are not allowed ('foo' was unexpected)"],
["{'foo': 'bar'} is not valid under any of the given schemas"],
id="execution-environment-broken",
),
("examples/meta/runtime.yml", "meta-runtime", []),
Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/schemas/__store__.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/inventory.json"
},
"meta": {
"etag": "7b5ac2250a4ae70ef657cd9906e6c13f4941daba71724e3342b7fa7e7239a334",
"etag": "230d2476c1e1f60cd05cba2ac7c42ef658588b1f502e68e85404fd524ef3b3b2",
"url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/meta.json"
},
"meta-runtime": {
Expand Down
341 changes: 290 additions & 51 deletions src/ansiblelint/schemas/execution-environment.json
Original file line number Diff line number Diff line change
@@ -1,70 +1,309 @@
{
"$id": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/execution-environment.json",
"$schema": "http://json-schema.org/draft-07/schema",
"additionalProperties": false,
"description": "See https://docs.ansible.com/automation-controller/latest/html/userguide/ee_reference.html",
"examples": ["execution-environment.yml"],
"properties": {
"additional_build_steps": {
"properties": {
"append": {
"examples": ["RUN cat /etc/os-release"],
"type": ["string", "array"]
},
"prepend": {
"examples": ["RUN cat /etc/os-release"],
"type": ["string", "array"]
"$defs": {
"TYPE_DictOrStringOrListOfStrings": {
"anyOf": [
{ "type": "object" },
{ "type": "string" },
{
"items": {
"type": "string"
},
"type": "array"
}
},
"title": "Commands to append or prepend to container build process.",
"type": "object"
]
},
"ansible_config": {
"examples": ["ansible.cfg"],
"title": "Ansible configuration file",
"type": "string"
"TYPE_StringOrListOfStrings": {
"anyOf": [
{ "type": "string" },
{
"items": {
"type": "string"
},
"type": "array"
}
]
},
"build_arg_defaults": {
"additionalProperties": true,
"v1": {
"additionalProperties": false,
"properties": {
"EE_BASE_IMAGE": {
"additional_build_steps": {
"properties": {
"append": {
"$ref": "#/$defs/TYPE_StringOrListOfStrings",
"examples": ["RUN cat /etc/os-release"]
},
"prepend": {
"$ref": "#/$defs/TYPE_StringOrListOfStrings",
"examples": ["RUN cat /etc/os-release"]
}
},
"title": "Commands to append or prepend to container build process.",
"type": "object"
},
"ansible_config": {
"examples": ["ansible.cfg"],
"title": "Ansible configuration file",
"type": "string"
},
"build_arg_defaults": {
"additionalProperties": true,
"properties": {
"EE_BASE_IMAGE": {
"type": "string"
}
},
"type": "object"
},
"dependencies": {
"description": "Allows adding system, python or galaxy dependencies.",
"properties": {
"galaxy": {
"examples": ["requirements.yml"],
"markdownDescription": "Example `requirements.yml`",
"title": "Optional galaxy file",
"type": "string"
},
"python": {
"examples": ["requirements.txt"],
"markdownDescription": "Example `requirements.txt`",
"title": "Optional python package dependencies",
"type": "string"
},
"system": {
"examples": ["bindep.txt"],
"markdownDescription": "Example `bindep.txt`",
"title": "Optional system dependencies using bindep format",
"type": "string"
}
},
"title": "Dependencies",
"type": "object"
},
"version": {
"enum": [1],
"title": "Version",
"type": "integer"
}
},
"required": ["version", "dependencies"],
"title": "Ansible Execution Environment Schema v1",
"type": "object"
},
"dependencies": {
"description": "Allows adding system, python or galaxy dependencies.",
"v3": {
"additionalProperties": false,
"properties": {
"galaxy": {
"examples": ["requirements.yml"],
"markdownDescription": "Example `requirements.yml`",
"title": "Optional galaxy file",
"type": "string"
"additional_build_files": {
"description": "Describes files to add to the build context",
"items": {
"additionalProperties": false,
"properties": {
"dest": {
"description": "Relative subdirectory under build context to place file",
"type": "string"
},
"src": {
"description": "File to add to build context",
"type": "string"
}
},
"required": ["src", "dest"],
"type": "object"
},
"type": "array"
},
"python": {
"examples": ["requirements.txt"],
"markdownDescription": "Example `requirements.txt`",
"title": "Optional python package dependencies",
"type": "string"
"additional_build_steps": {
"properties": {
"append_base": {
"$ref": "#/$defs/TYPE_StringOrListOfStrings",
"examples": ["RUN cat /etc/os-release"]
},
"append_builder": {
"$ref": "#/$defs/TYPE_StringOrListOfStrings",
"examples": ["RUN cat /etc/os-release"]
},
"append_final": {
"$ref": "#/$defs/TYPE_StringOrListOfStrings",
"examples": ["RUN cat /etc/os-release"]
},
"append_galaxy": {
"$ref": "#/$defs/TYPE_StringOrListOfStrings",
"examples": ["RUN cat /etc/os-release"]
},
"prepend_base": {
"$ref": "#/$defs/TYPE_StringOrListOfStrings",
"examples": ["RUN cat /etc/os-release"]
},
"prepend_builder": {
"$ref": "#/$defs/TYPE_StringOrListOfStrings",
"examples": ["RUN cat /etc/os-release"]
},
"prepend_final": {
"$ref": "#/$defs/TYPE_StringOrListOfStrings",
"examples": ["RUN cat /etc/os-release"]
},
"prepend_galaxy": {
"$ref": "#/$defs/TYPE_StringOrListOfStrings",
"examples": ["RUN cat /etc/os-release"]
}
},
"title": "Commands to append or prepend to container build process.",
"type": "object"
},
"system": {
"examples": ["bindep.txt"],
"markdownDescription": "Example `bindep.txt`",
"title": "Optional system dependencies using bindep format",
"type": "string"
"build_arg_defaults": {
"additionalProperties": false,
"properties": {
"ANSIBLE_GALAXY_CLI_COLLECTION_OPTS": {
"type": "string"
},
"ANSIBLE_GALAXY_CLI_ROLE_OPTS": {
"type": "string"
},
"PKGMGR_PRESERVE_CACHE": {
"type": "string"
}
},
"type": "object"
},
"dependencies": {
"description": "Allows adding system, python or galaxy dependencies.",
"properties": {
"ansible_core": {
"additionalProperties": false,
"description": "Ansible package installation",
"oneOf": [{ "required": ["package_pip"] }],
"properties": {
"package_pip": {
"description": "Ansible package to install via pip",
"type": "string"
}
},
"type": "object"
},
"ansible_runner": {
"additionalProperties": false,
"description": "Ansible Runner package installation",
"oneOf": [{ "required": ["package_pip"] }],
"properties": {
"package_pip": {
"description": "Ansible Runner package to install via pip",
"type": "string"
}
},
"type": "object"
},
"galaxy": {
"$ref": "#/$defs/TYPE_DictOrStringOrListOfStrings",
"examples": ["requirements.yml"],
"markdownDescription": "Example `requirements.yml`",
"title": "Optional galaxy file"
},
"python": {
"$ref": "#/$defs/TYPE_StringOrListOfStrings",
"examples": ["requirements.txt"],
"markdownDescription": "Example `requirements.txt`",
"title": "Optional python package dependencies"
},
"python_interpreter": {
"additionalProperties": false,
"description": "Python package name and path",
"properties": {
"package_system": {
"description": "The python package to install via system package manager",
"type": "string"
},
"python_path": {
"description": "Path to the python interpreter",
"type": "string"
}
},
"type": "object"
},
"system": {
"$ref": "#/$defs/TYPE_StringOrListOfStrings",
"examples": ["bindep.txt"],
"markdownDescription": "Example `bindep.txt`",
"title": "Optional system dependencies using bindep format"
}
},
"title": "Dependencies",
"type": "object"
},
"images": {
"additionalProperties": false,
"properties": {
"base_image": {
"name": {
"examples": [
"registry.redhat.io/ansible-automation-platform-21/ee-minimal-rhel8:latest"
],
"type": "string"
},
"type": "object"
}
},
"type": "object"
},
"options": {
"additionalProperties": false,
"description": "Options that effect runtime behavior",
"properties": {
"container_init": {
"additionalProperties": false,
"description": "Customize container startup behavior",
"properties": {
"cmd": {
"description": "literal value for CMD Containerfile directive",
"type": "string"
},
"entrypoint": {
"description": "literal value for ENTRYPOINT Containerfile directive",
"type": "string"
},
"package_pip": {
"description": "package to install via pip for entrypoint support",
"type": "string"
}
},
"type": "object"
},
"package_manager_path": {
"description": "Path to the system package manager to use",
"type": "string"
},
"relax_passwd_permissions": {
"description": "allows GID0 write access to /etc/passwd; currently necessary for many uses",
"type": "boolean"
},
"skip_ansible_check": {
"description": "Disables the check for Ansible/Runner in final image",
"type": "boolean"
},
"user": {
"description": "Sets the username or UID",
"type": "string"
},
"workdir": {
"description": "Default working directory, also often the homedir for ephemeral UIDs",
"type": ["string", "null"]
}
},
"type": "object"
},
"version": {
"enum": [3],
"title": "Version",
"type": "integer"
}
},
"title": "Dependencies",
"required": ["version", "dependencies"],
"title": "Ansible Execution Environment Schema v3",
"type": "object"
},
"version": {
"enum": [1],
"title": "Version",
"type": "integer"
}
},
"required": ["version", "dependencies"],
"title": "Ansible Execution Environment Schema",
"type": "object"
"$id": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/execution-environment.json",
"$schema": "http://json-schema.org/draft-07/schema",
"description": "See https://docs.ansible.com/automation-controller/latest/html/userguide/ee_reference.html",
"examples": ["execution-environment.yml"],
"oneOf": [{ "$ref": "#/$defs/v3" }, { "$ref": "#/$defs/v1" }],
"title": "Ansible Execution Environment Schema v1/v3"
}

0 comments on commit ea2e139

Please sign in to comment.