{
    "kind": "Template",
    "apiVersion": "v1",
    "metadata": {
        "annotations": {
            "iconClass": "icon-rh-integration",
            "tags": "wildfly,camel,javaee,java",
            "version": "9.0.0",
            "openshift.io/display-name": "WildFly Camel",
            "description": "An example WildFly Camel application. For more information about using this template, see http://wildfly-extras.github.io/wildfly-camel/#_cloud_integration.",
            "template.openshift.io/long-description": "This template defines resources needed to develop a WildFly Camel application, including a build configuration, application deployment configuration and insecure communication using http.",
            "template.openshift.io/documentation-url": "http://wildfly-extras.github.io/wildfly-camel"
        },
        "name": "wildfly-camel-s2i"
    },
    "labels": {
        "template": "wildfly-camel-s2i",
        "xpaas": "9.0.0"
    },
    "message": "A new WildFly Camel application has been created in your project.",
    "parameters": [
        {
            "displayName": "Application Name",
            "description": "The name for the application.",
            "name": "APPLICATION_NAME",
            "value": "my-wildfly-camel-application",
            "required": true
        },
        {
            "displayName": "Base Image",
            "description": "The name of the Docker image to use as base s2i image for the application. You should have imported the WildFly Camel image stream before using this template through \"oc apply -n openshift -f http://wildfly-extras.github.io/wildfly-camel/sources/wildfly-camel-imagestream.json\" If you are not permitted to add to openshift namespace use another one, e.g. -n myproject",
            "name": "BASE_IMAGE",
            "value": "wildfly-camel:9.0.0",
            "required": true
        },
        {
            "displayName": "Base Image ImageStream Namespace",
            "description": "Namespace (i.e. name of the OpenShift project) in which the ImageStream of the base image was imported. See the Base image option",
            "name": "IMAGE_STREAM_NAMESPACE",
            "value": "openshift",
            "required": true
        },
        {
            "displayName": "Custom HTTP Route Hostname",
            "description": "Custom hostname for http service route.  Leave blank for default hostname, e.g.: <application-name>-<project>.<default-domain-suffix>",
            "name": "HOSTNAME_HTTP",
            "value": "",
            "required": false
        },
        {
            "displayName": "Git Repository URL",
            "description": "Git source URI for application",
            "name": "SOURCE_REPOSITORY_URL",
            "value": "https://github.com/wildfly-extras/wildfly-camel-examples.git",
            "required": true
        },
        {
            "displayName": "Git Reference",
            "description": "A git branch name or tag tame. Typically \"master\"",
            "name": "SOURCE_REPOSITORY_REF",
            "value": "9.0.0",
            "required": false
        },
        {
            "displayName": "Context Directory",
            "description": "Path within Git project to build; empty for root project directory.",
            "name": "CONTEXT_DIR",
            "value": "camel-cdi",
            "required": false
        },
        {
            "displayName": "Github Webhook Secret",
            "description": "GitHub trigger secret",
            "name": "GITHUB_WEBHOOK_SECRET",
            "from": "[a-zA-Z0-9]{8}",
            "generate": "expression",
            "required": true
        },
        {
            "displayName": "Generic Webhook Secret",
            "description": "Generic build trigger secret",
            "name": "GENERIC_WEBHOOK_SECRET",
            "from": "[a-zA-Z0-9]{8}",
            "generate": "expression",
            "required": true
        },
        {
            "displayName": "Maven Mirror URL",
            "description": "The URL of a Maven repository to use for S2I builds. Put a URL of a cluster-internal or your company-internal Maven repo here.",
            "name": "MAVEN_MIRROR_URL",
            "value": "",
            "required": false
        },
        {
            "description": "List of directories from which archives will be copied into the deployment folder. If unspecified, all archives in /target will be copied.",
            "name": "ARTIFACT_DIR",
            "value": "",
            "required": false
        },
        {
            "description": "Container memory limit",
            "name": "MEMORY_LIMIT",
            "value": "1Gi",
            "required": false
        }
    ],
    "objects": [
        {
            "kind": "Service",
            "apiVersion": "v1",
            "spec": {
                "ports": [
                    {
                        "port": 8080,
                        "targetPort": 8080
                    }
                ],
                "selector": {
                    "deploymentConfig": "${APPLICATION_NAME}"
                }
            },
            "metadata": {
                "name": "${APPLICATION_NAME}",
                "labels": {
                    "application": "${APPLICATION_NAME}"
                },
                "annotations": {
                    "description": "The web server's http port."
                }
            }
        },
        {
            "kind": "Route",
            "apiVersion": "v1",
            "id": "${APPLICATION_NAME}-http",
            "metadata": {
                "name": "${APPLICATION_NAME}",
                "labels": {
                    "application": "${APPLICATION_NAME}"
                },
                "annotations": {
                    "description": "Route for application's http service."
                }
            },
            "spec": {
                "host": "${HOSTNAME_HTTP}",
                "to": {
                    "name": "${APPLICATION_NAME}"
                }
            }
        },
        {
            "kind": "ImageStream",
            "apiVersion": "v1",
            "metadata": {
                "name": "${APPLICATION_NAME}",
                "labels": {
                    "application": "${APPLICATION_NAME}"
                }
            }
        },
        {
            "kind": "BuildConfig",
            "apiVersion": "v1",
            "metadata": {
                "name": "${APPLICATION_NAME}",
                "labels": {
                    "application": "${APPLICATION_NAME}"
                }
            },
            "spec": {
                "source": {
                    "type": "Git",
                    "git": {
                        "uri": "${SOURCE_REPOSITORY_URL}",
                        "ref": "${SOURCE_REPOSITORY_REF}"
                    },
                    "contextDir": "${CONTEXT_DIR}"
                },
                "strategy": {
                    "type": "Source",
                    "sourceStrategy": {
                        "env": [
                            {
                                "name": "MAVEN_MIRROR_URL",
                                "value": "${MAVEN_MIRROR_URL}"
                            },
                            {
                                "name": "ARTIFACT_DIR",
                                "value": "${ARTIFACT_DIR}"
                            }
                        ],
                        "forcePull": true,
                        "from": {
                            "kind": "ImageStreamTag",
                            "namespace": "${IMAGE_STREAM_NAMESPACE}",
                            "name": "${BASE_IMAGE}"
                        }
                    }
                },
                "output": {
                    "to": {
                        "kind": "ImageStreamTag",
                        "name": "${APPLICATION_NAME}:latest"
                    }
                },
                "triggers": [
                    {
                        "type": "GitHub",
                        "github": {
                            "secret": "${GITHUB_WEBHOOK_SECRET}"
                        }
                    },
                    {
                        "type": "Generic",
                        "generic": {
                            "secret": "${GENERIC_WEBHOOK_SECRET}"
                        }
                    },
                    {
                        "type": "ImageChange",
                        "imageChange": {}
                    },
                    {
                        "type": "ConfigChange"
                    }
                ]
            }
        },
        {
            "kind": "DeploymentConfig",
            "apiVersion": "v1",
            "metadata": {
                "name": "${APPLICATION_NAME}",
                "labels": {
                    "application": "${APPLICATION_NAME}"
                }
            },
            "spec": {
                "strategy": {
                    "type": "Recreate"
                },
                "triggers": [
                    {
                        "type": "ImageChange",
                        "imageChangeParams": {
                            "automatic": true,
                            "containerNames": [
                                "${APPLICATION_NAME}"
                            ],
                            "from": {
                                "kind": "ImageStreamTag",
                                "name": "${APPLICATION_NAME}:latest"
                            }
                        }
                    },
                    {
                        "type": "ConfigChange"
                    }
                ],
                "replicas": 1,
                "selector": {
                    "deploymentConfig": "${APPLICATION_NAME}"
                },
                "template": {
                    "metadata": {
                        "name": "${APPLICATION_NAME}",
                        "labels": {
                            "deploymentConfig": "${APPLICATION_NAME}",
                            "application": "${APPLICATION_NAME}"
                        }
                    },
                    "spec": {
                        "terminationGracePeriodSeconds": 75,
                        "containers": [
                            {
                                "name": "${APPLICATION_NAME}",
                                "image": "${APPLICATION_NAME}",
                                "imagePullPolicy": "Always",
                                "resources": {
                                    "limits": {
                                        "memory": "${MEMORY_LIMIT}"
                                    }
                                },
                                "livenessProbe": {
                                    "exec": {
                                        "command": [
                                            "/bin/bash",
                                            "-c",
                                            "/wildfly/bin/jboss-cli.sh --connect --commands=ls | grep 'server-state=running'"
                                        ]
                                    },
                                    "initialDelaySeconds": 20
                                },
                                "readinessProbe": {
                                    "exec": {
                                        "command": [
                                            "/bin/bash",
                                            "-c",
                                            "/wildfly/bin/jboss-cli.sh --connect --commands=ls | grep 'server-state=running'"
                                        ]
                                    },
                                    "initialDelaySeconds": 10
                                },
                                "ports": [
                                    {
                                        "name": "http",
                                        "containerPort": 8080,
                                        "protocol": "TCP"
                                    }
                                ],
                                "env": []
                            }
                        ]
                    }
                }
            }
        }
    ]
}
