{
	"$schema": "http://json-schema.org/draft-04/schema#",
	"$ref": "#/definitions/Function",
	"definitions": {
		"BuildSpec": {
			"required": [
				"buildpacks",
				"builder",
				"buildEnvs"
			],
			"properties": {
				"git": {
					"$schema": "http://json-schema.org/draft-04/schema#",
					"$ref": "#/definitions/Git"
				},
				"builderImages": {
					"patternProperties": {
						".*": {
							"type": "string"
						}
					},
					"type": "object"
				},
				"buildpacks": {
					"items": {
						"type": "string"
					},
					"type": "array"
				},
				"builder": {
					"enum": [
						"pack",
						"s2i"
					],
					"type": "string"
				},
				"buildEnvs": {
					"items": {
						"$schema": "http://json-schema.org/draft-04/schema#",
						"$ref": "#/definitions/Env"
					},
					"type": "array"
				}
			},
			"additionalProperties": false,
			"type": "object"
		},
		"DeploySpec": {
			"required": [
				"namespace",
				"annotations",
				"options",
				"labels",
				"healthEndpoints"
			],
			"properties": {
				"namespace": {
					"type": "string"
				},
				"annotations": {
					"patternProperties": {
						".*": {
							"type": "string"
						}
					},
					"type": "object"
				},
				"options": {
					"$schema": "http://json-schema.org/draft-04/schema#",
					"$ref": "#/definitions/Options"
				},
				"labels": {
					"items": {
						"$schema": "http://json-schema.org/draft-04/schema#",
						"$ref": "#/definitions/Label"
					},
					"type": "array"
				},
				"healthEndpoints": {
					"$schema": "http://json-schema.org/draft-04/schema#",
					"$ref": "#/definitions/HealthEndpoints"
				}
			},
			"additionalProperties": false,
			"type": "object"
		},
		"Env": {
			"required": [
				"value"
			],
			"properties": {
				"name": {
					"pattern": "^[-._a-zA-Z][-._a-zA-Z0-9]*$",
					"type": "string"
				},
				"value": {
					"type": "string"
				}
			},
			"additionalProperties": false,
			"type": "object"
		},
		"Function": {
			"required": [
				"specVersion",
				"name",
				"runtime",
				"registry",
				"image",
				"imageDigest",
				"created",
				"build",
				"run",
				"deploy"
			],
			"properties": {
				"specVersion": {
					"type": "string"
				},
				"name": {
					"pattern": "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$",
					"type": "string"
				},
				"runtime": {
					"type": "string"
				},
				"registry": {
					"type": "string"
				},
				"image": {
					"type": "string"
				},
				"imageDigest": {
					"type": "string"
				},
				"created": {
					"type": "string",
					"format": "date-time"
				},
				"invocation": {
					"$schema": "http://json-schema.org/draft-04/schema#",
					"$ref": "#/definitions/Invocation"
				},
				"build": {
					"$schema": "http://json-schema.org/draft-04/schema#",
					"$ref": "#/definitions/BuildSpec"
				},
				"run": {
					"$schema": "http://json-schema.org/draft-04/schema#",
					"$ref": "#/definitions/RunSpec"
				},
				"deploy": {
					"$schema": "http://json-schema.org/draft-04/schema#",
					"$ref": "#/definitions/DeploySpec"
				}
			},
			"additionalProperties": false,
			"type": "object"
		},
		"Git": {
			"properties": {
				"url": {
					"type": "string"
				},
				"revision": {
					"type": "string"
				},
				"contextDir": {
					"type": "string"
				}
			},
			"additionalProperties": false,
			"type": "object"
		},
		"HealthEndpoints": {
			"properties": {
				"liveness": {
					"type": "string"
				},
				"readiness": {
					"type": "string"
				}
			},
			"additionalProperties": false,
			"type": "object"
		},
		"Invocation": {
			"properties": {
				"format": {
					"type": "string"
				}
			},
			"additionalProperties": false,
			"type": "object"
		},
		"Label": {
			"required": [
				"key"
			],
			"properties": {
				"key": {
					"pattern": "^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*\\/)?([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]$",
					"type": "string"
				},
				"value": {
					"pattern": "^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$",
					"type": "string"
				}
			},
			"additionalProperties": false,
			"type": "object"
		},
		"Options": {
			"properties": {
				"scale": {
					"$schema": "http://json-schema.org/draft-04/schema#",
					"$ref": "#/definitions/ScaleOptions"
				},
				"resources": {
					"$schema": "http://json-schema.org/draft-04/schema#",
					"$ref": "#/definitions/ResourcesOptions"
				}
			},
			"additionalProperties": false,
			"type": "object"
		},
		"ResourcesLimitsOptions": {
			"properties": {
				"cpu": {
					"pattern": "^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$",
					"type": "string"
				},
				"memory": {
					"pattern": "^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$",
					"type": "string"
				},
				"concurrency": {
					"type": "integer",
					"minimum": 0
				}
			},
			"additionalProperties": false,
			"type": "object"
		},
		"ResourcesOptions": {
			"properties": {
				"requests": {
					"$schema": "http://json-schema.org/draft-04/schema#",
					"$ref": "#/definitions/ResourcesRequestsOptions"
				},
				"limits": {
					"$schema": "http://json-schema.org/draft-04/schema#",
					"$ref": "#/definitions/ResourcesLimitsOptions"
				}
			},
			"additionalProperties": false,
			"type": "object"
		},
		"ResourcesRequestsOptions": {
			"properties": {
				"cpu": {
					"pattern": "^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$",
					"type": "string"
				},
				"memory": {
					"pattern": "^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$",
					"type": "string"
				}
			},
			"additionalProperties": false,
			"type": "object"
		},
		"RunSpec": {
			"required": [
				"volumes",
				"envs"
			],
			"properties": {
				"volumes": {
					"items": {
						"$schema": "http://json-schema.org/draft-04/schema#",
						"$ref": "#/definitions/Volume"
					},
					"type": "array"
				},
				"envs": {
					"items": {
						"$ref": "#/definitions/Env"
					},
					"type": "array"
				}
			},
			"additionalProperties": false,
			"type": "object"
		},
		"ScaleOptions": {
			"properties": {
				"min": {
					"type": "integer",
					"minimum": 0
				},
				"max": {
					"type": "integer",
					"minimum": 0
				},
				"metric": {
					"enum": [
						"concurrency",
						"rps"
					],
					"type": "string"
				},
				"target": {
					"type": "number",
					"minimum": 0
				},
				"utilization": {
					"maximum": 100,
					"minimum": 1,
					"type": "number"
				}
			},
			"additionalProperties": false,
			"type": "object"
		},
		"Volume": {
			"required": [
				"path"
			],
			"properties": {
				"secret": {
					"type": "string"
				},
				"configMap": {
					"type": "string"
				},
				"path": {
					"type": "string"
				}
			},
			"additionalProperties": false,
			"type": "object",
			"oneOf": [
				{
					"required": [
						"secret"
					],
					"title": "secret"
				},
				{
					"required": [
						"configMap"
					],
					"title": "configmap"
				}
			]
		}
	}
}