{
    "title": "application manifest",
    "description": "In the application manifest a developer defines the application, its dependencies on other applications, services and environment variables that should be set. The application manifest is a JSON file. While the two required values are located in the root object, all deployment information is located under the ```deployment``` key. This way, applications written in NodeJS can reuse their existing package.json file as their application manifest by simply adding the ```deployment``` section.",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "id": "http://github.com/push2cloud/push2cloud/schemas/application-manifest.json",
    "type": "object",
    "example": {
        "name": "push2cloud-example-api",
        "version": "1.0.0",
        "deployment": {
            "memory": 512,
            "disk": 512,
            "instances": 1,
            "startTimeout": 100,
            "stageTimeout": 200,
            "gracePeriod": 20,
            "buildpack": "https://github.com/cloudfoundry/nodejs-buildpack.git",
            "env": {
                "FOO": "BAR"
            },
            "appConnections": {
                "push2cloud-example-host": {
                    "injectCredentials": false,
                    "urls": {
                        "START_URL": "/start"
                    }
                }
            },
            "serviceBinding": [
                "todo-db"
            ],
            "path": "build/libs/java-1.0.jar",
            "scripts": {
                "package": [
                    "gradle jar"
                ]
            }
        }
    },
    "properties": {
        "name": {
            "id": "name",
            "type": "string",
            "description": "Identifier for the application. Must be unique in a release. This value is used to identify an application throughout push2cloud, such as in `appConnections`, the [release manifest](release_manifest.md) and the [deployment manifest](deployment_manifest.md)."
        },
        "version": {
            "id": "version",
            "type": "string",
            "description": "The version of your application. Use [semver](http://semver.org/). The version is used in certain [workflows](workflows.md) to determine if an update is required."
        },
        "deployment": {
            "id": "deployment",
            "description": "the entrypoint for all deployment information",
            "type": "object",
            "properties": {
                "memory": {
                    "id": "memory",
                    "description": "the amount of memory the app requires, e.g.: 128M, 1G",
                    "type": "string",
                    "pattern": "^[0-9]*[MG]$",
                    "default": "256M"
                },
                "disk": {
                    "id": "disk",
                    "type": "string",
                    "description": "the amount of disk the app requires, e.g.: 128M, 1G",
                    "pattern": "^[0-9]*[MG]$",
                    "default": "256M"
                },
                "instances": {
                    "id": "instances",
                    "description": "the base amount of instances",
                    "type": "integer",
                    "minimum": 1,
                    "default": 1
                },
                "startTimeout": {
                    "id": "startTimeout",
                    "description": "how long the app can take to start before it is considered an error",
                    "type": "integer",
                    "minimum": 0
                },
                "stageTimeout": {
                    "id": "stageTimeout",
                    "description": "how long the app can take to stage before it is considered an error",
                    "type": "integer",
                    "minimum": 0,
                    "default": 300
                },
                "gracePeriod": {
                    "id": "gracePeriod",
                    "description": "how long the app has to run without crashing to be considered successfully started",
                    "type": "integer",
                    "minimum": 0,
                    "default": 40
                },
                "buildpack": {
                    "id": "buildpack",
                    "description": "buildbpack to build the application",
                    "type": "string"
                },
                "path": {
                    "id": "path",
                    "description": "which folder/file should be used for deployment. Useful for java applications. Similar to [path in CloudFoundry manifests](http://docs.cloudfoundry.org/devguide/deploy-apps/manifest.html#path).",
                    "type": "string"
                },
                "appBits": {
                    "id": "appBits",
                    "description": "Alias for path. Will be overwritten by path.",
                    "type": "string"
                },
                "env": {
                    "id": "env",
                    "description": "environment variables to set/substitue for this app",
                    "type": "object",
                    "additionalProperties": {
                        "type": "string"
                    }
                },
                "serviceBinding": {
                    "id": "serviceBinding",
                    "description": "names of services this app needs connections to",
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                },
                "scripts": {
                    "id": "scripts",
                    "description": "scripts that are used in workflows during the apps deployment",
                    "type": "object",
                    "additionalProperties": {
                        "type": "object",
                        "properties": {
                            "prepare": {
                                "description": "scripts that run during the [packageApp helper](https://github.com/push2cloud/workflow-utils/blob/master/packageApp.js).",
                                "type": "array",
                                "items": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                },
                "appConnections": {
                    "id": "appConnections",
                    "description": "names of other apps this app needs connections to",
                    "type": "object",
                    "additionalProperties": {
                        "type": "object",
                        "properties": {
                            "urls": {
                                "description": "inject the connection information additonally with the following key and with value as a suffix to the URL",
                                "type": "object",
                                "additionalProperties": {
                                    "type": "string"
                                }
                            },
                            "injectCredentials": {
                                "description": "controls the injection of _USERNAME and _PASSWORD credentials for this connection",
                                "type": "boolean"
                            }
                        }
                    }
                }
            }
        }
    },
    "required": [
        "name",
        "version",
        "deployment"
    ]
}