{
  "$defs": {
    "roleRule": {
      "properties": {
        "namespace": {
          "type": "string"
        },
        "rules": {
          "items": {
            "$ref": "#/$defs/rules"
          },
          "type": "array"
        }
      },
      "required": [
        "namespace",
        "rules"
      ],
      "type": "object"
    },
    "rules": {
      "properties": {
        "apiGroups": {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "resourceNames": {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "resources": {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "verbs": {
          "items": {
            "type": "string"
          },
          "type": "array"
        }
      },
      "required": [
        "verbs",
        "apiGroups",
        "resources"
      ],
      "type": "object"
    }
  },
  "$id": "https://github.com/openshift/managed-scripts/metadata.schema.json",
  "$schema": "https://json-schema.org/draft-06/schema#",
  "additionalProperties": false,
  "description": "Metadata for managed scripts",
  "properties": {
    "allowedGroups": {
      "description": "Groups who are allowed to run the script",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "author": {
      "description": "Github username of the author",
      "type": "string"
    },
    "clusterVersions": {
      "additionalProperties": false,
      "description": "List of required cluster versions, supporting 'major.minor.patch' format and wildcards",
      "items": {
        "pattern": "^\\d+\\.\\d+\\.\\d+$|^\\d+\\.\\d+\\.\\*$",
        "type": "string"
      },
      "type": "array"
    },
    "description": {
      "description": "A brief description of the script",
      "type": "string"
    },
    "envs": {
      "additionalProperties": false,
      "description": "The environment variables declared on the script",
      "items": {
        "properties": {
          "description": {
            "description": "A brief description of the environment variable",
            "type": "string"
          },
          "key": {
            "description": "Key of the environment variable",
            "type": "string"
          },
          "optional": {
            "description": "Whether or not this environment variable is optional",
            "type": "boolean"
          }
        },
        "type": "object"
      },
      "type": "array"
    },
    "file": {
      "description": "File name of the script",
      "type": "string"
    },
    "labels": {
      "description": "Labels that apply to this script",
      "items": {
        "properties": {
          "description": {
            "description": "A brief description of the label",
            "type": "string"
          },
          "key": {
            "description": "Key of the label",
            "type": "string"
          },
          "values": {
            "description": "Values for the label",
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "type": "object"
      },
      "type": "array"
    },
    "language": {
      "description": "The script language",
      "enum": [
        "python",
        "bash"
      ],
      "type": "string"
    },
    "name": {
      "description": "Parent directory name of the script",
      "type": "string"
    },
    "rbac": {
      "additionalProperties": false,
      "properties": {
        "clusterRoleRules": {
          "items": {
            "$ref": "#/$defs/rules"
          },
          "type": "array"
        },
        "roles": {
          "items": {
            "$ref": "#/$defs/roleRule"
          },
          "type": "array"
        }
      },
      "type": "object"
    },
    "shortDescription": {
      "description": "A shorter description for tables and lists",
      "type": "string"
    }
  },
  "required": [
    "file",
    "name",
    "description",
    "author",
    "language",
    "allowedGroups"
  ],
  "title": "Metadata",
  "type": "object"
}