{
    "apiVersion": "v1",
    "kind": "Template",
    "labels": {
        "template": "dotnet-pgsql-persistent"
    },
    "message": "The following service(s) have been created in your project: ${NAME}, ${DATABASE_SERVICE_NAME}.\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/redhat-developer/s2i-dotnetcore.",
    "metadata": {
        "annotations": {
            "description": "An example .NET Core application with a PostgreSQL database. For more information about using this template, including OpenShift considerations, see https://github.com/redhat-developer/s2i-dotnetcore.",
            "iconClass": "icon-dotnet",
            "openshift.io/display-name": ".NET Core + PostgreSQL (Persistent)",
            "tags": "quickstart,dotnet",
            "template.openshift.io/documentation-url": "https://github.com/redhat-developer/s2i-dotnetcore",
            "template.openshift.io/provider-display-name": "Red Hat, Inc.",
            "template.openshift.io/support-url": "https://access.redhat.com"
        },
        "name": "dotnet-pgsql-persistent"
    },
    "objects": [
        {
            "apiVersion": "v1",
            "kind": "Secret",
            "metadata": {
                "name": "${NAME}"
            },
            "stringData": {
                "connect-string": "Host=${DATABASE_SERVICE_NAME};Database=${DATABASE_NAME};Username=${DATABASE_USER};Password=${DATABASE_PASSWORD}",
                "database-password": "${DATABASE_PASSWORD}"
            }
        },
        {
            "apiVersion": "v1",
            "kind": "Service",
            "metadata": {
                "annotations": {
                    "description": "Exposes and load balances the application pods",
                    "service.alpha.openshift.io/dependencies": "[{\"name\": \"${DATABASE_SERVICE_NAME}\", \"kind\": \"Service\"}]"
                },
                "name": "${NAME}"
            },
            "spec": {
                "ports": [
                    {
                        "name": "web",
                        "port": 8080,
                        "targetPort": 8080
                    }
                ],
                "selector": {
                    "name": "${NAME}"
                }
            }
        },
        {
            "apiVersion": "v1",
            "kind": "Route",
            "metadata": {
                "name": "${NAME}"
            },
            "spec": {
                "host": "${APPLICATION_DOMAIN}",
                "to": {
                    "kind": "Service",
                    "name": "${NAME}"
                }
            }
        },
        {
            "apiVersion": "v1",
            "kind": "ImageStream",
            "metadata": {
                "annotations": {
                    "description": "Keeps track of changes in the application image"
                },
                "name": "${NAME}"
            }
        },
        {
            "apiVersion": "v1",
            "kind": "BuildConfig",
            "metadata": {
                "annotations": {
                    "description": "Defines how to build the application"
                },
                "name": "${NAME}"
            },
            "spec": {
                "output": {
                    "to": {
                        "kind": "ImageStreamTag",
                        "name": "${NAME}:latest"
                    }
                },
                "postCommit": {},
                "source": {
                    "contextDir": "${CONTEXT_DIR}",
                    "git": {
                        "ref": "${SOURCE_REPOSITORY_REF}",
                        "uri": "${SOURCE_REPOSITORY_URL}"
                    },
                    "type": "Git"
                },
                "strategy": {
                    "sourceStrategy": {
                        "env": [
                            {
                                "name": "DOTNET_STARTUP_PROJECT",
                                "value": "${DOTNET_STARTUP_PROJECT}"
                            },
                            {
                                "name": "DOTNET_ASSEMBLY_NAME",
                                "value": "${DOTNET_ASSEMBLY_NAME}"
                            },
                            {
                                "name": "DOTNET_NPM_TOOLS",
                                "value": "${DOTNET_NPM_TOOLS}"
                            },
                            {
                                "name": "DOTNET_TEST_PROJECTS",
                                "value": "${DOTNET_TEST_PROJECTS}"
                            },
                            {
                                "name": "DOTNET_CONFIGURATION",
                                "value": "${DOTNET_CONFIGURATION}"
                            },
                            {
                                "name": "DOTNET_RESTORE_SOURCES",
                                "value": "${DOTNET_RESTORE_SOURCES}"
                            },
                            {
                                "name": "DOTNET_TOOLS",
                                "value": "${DOTNET_TOOLS}"
                            }
                        ],
                        "from": {
                            "kind": "ImageStreamTag",
                            "name": "${DOTNET_IMAGE_STREAM_TAG}",
                            "namespace": "${NAMESPACE}"
                        }
                    },
                    "type": "Source"
                },
                "triggers": [
                    {
                        "type": "ImageChange"
                    },
                    {
                        "type": "ConfigChange"
                    },
                    {
                        "github": {
                            "secret": "${GITHUB_WEBHOOK_SECRET}"
                        },
                        "type": "GitHub"
                    }
                ]
            }
        },
        {
            "apiVersion": "v1",
            "kind": "DeploymentConfig",
            "metadata": {
                "annotations": {
                    "description": "Defines how to deploy the application server"
                },
                "name": "${NAME}"
            },
            "spec": {
                "replicas": 1,
                "selector": {
                    "name": "${NAME}"
                },
                "strategy": {
                    "resources": {},
                    "rollingParams": {
                        "intervalSeconds": 1,
                        "maxSurge": "25%",
                        "maxUnavailable": "25%",
                        "timeoutSeconds": 600,
                        "updatePeriodSeconds": 1
                    },
                    "type": "Rolling"
                },
                "template": {
                    "metadata": {
                        "labels": {
                            "name": "${NAME}"
                        },
                        "name": "${NAME}"
                    },
                    "spec": {
                        "containers": [
                            {
                                "env": [
                                    {
                                        "name": "ConnectionString",
                                        "valueFrom": {
                                            "secretKeyRef": {
                                                "key": "connect-string",
                                                "name": "${NAME}"
                                            }
                                        }
                                    }
                                ],
                                "image": " ",
                                "livenessProbe": {
                                    "httpGet": {
                                        "path": "/",
                                        "port": 8080,
                                        "scheme": "HTTP"
                                    },
                                    "initialDelaySeconds": 40,
                                    "timeoutSeconds": 10
                                },
                                "name": "dotnet-pgsql-persistent",
                                "ports": [
                                    {
                                        "containerPort": 8080
                                    }
                                ],
                                "readinessProbe": {
                                    "httpGet": {
                                        "path": "/",
                                        "port": 8080,
                                        "scheme": "HTTP"
                                    },
                                    "initialDelaySeconds": 10,
                                    "timeoutSeconds": 30
                                },
                                "resources": {
                                    "limits": {
                                        "memory": "${MEMORY_LIMIT}"
                                    }
                                }
                            }
                        ]
                    }
                },
                "triggers": [
                    {
                        "imageChangeParams": {
                            "automatic": true,
                            "containerNames": [
                                "dotnet-pgsql-persistent"
                            ],
                            "from": {
                                "kind": "ImageStreamTag",
                                "name": "${NAME}:latest"
                            }
                        },
                        "type": "ImageChange"
                    },
                    {
                        "type": "ConfigChange"
                    }
                ]
            }
        },
        {
            "apiVersion": "v1",
            "kind": "PersistentVolumeClaim",
            "metadata": {
                "name": "${DATABASE_SERVICE_NAME}"
            },
            "spec": {
                "accessModes": [
                    "ReadWriteOnce"
                ],
                "resources": {
                    "requests": {
                        "storage": "${VOLUME_CAPACITY}"
                    }
                }
            }
        },
        {
            "apiVersion": "v1",
            "kind": "Service",
            "metadata": {
                "annotations": {
                    "description": "Exposes the database server"
                },
                "name": "${DATABASE_SERVICE_NAME}"
            },
            "spec": {
                "ports": [
                    {
                        "name": "postgresql",
                        "port": 5432,
                        "targetPort": 5432
                    }
                ],
                "selector": {
                    "name": "${DATABASE_SERVICE_NAME}"
                }
            }
        },
        {
            "apiVersion": "v1",
            "kind": "DeploymentConfig",
            "metadata": {
                "annotations": {
                    "description": "Defines how to deploy the database"
                },
                "name": "${DATABASE_SERVICE_NAME}"
            },
            "spec": {
                "replicas": 1,
                "selector": {
                    "name": "${DATABASE_SERVICE_NAME}"
                },
                "strategy": {
                    "type": "Recreate"
                },
                "template": {
                    "metadata": {
                        "labels": {
                            "name": "${DATABASE_SERVICE_NAME}"
                        },
                        "name": "${DATABASE_SERVICE_NAME}"
                    },
                    "spec": {
                        "containers": [
                            {
                                "env": [
                                    {
                                        "name": "POSTGRESQL_USER",
                                        "value": "${DATABASE_USER}"
                                    },
                                    {
                                        "name": "POSTGRESQL_PASSWORD",
                                        "valueFrom": {
                                            "secretKeyRef": {
                                                "key": "database-password",
                                                "name": "${NAME}"
                                            }
                                        }
                                    },
                                    {
                                        "name": "POSTGRESQL_DATABASE",
                                        "value": "${DATABASE_NAME}"
                                    },
                                    {
                                        "name": "POSTGRESQL_MAX_CONNECTIONS",
                                        "value": "${POSTGRESQL_MAX_CONNECTIONS}"
                                    },
                                    {
                                        "name": "POSTGRESQL_SHARED_BUFFERS",
                                        "value": "${POSTGRESQL_SHARED_BUFFERS}"
                                    }
                                ],
                                "image": " ",
                                "livenessProbe": {
                                    "initialDelaySeconds": 30,
                                    "tcpSocket": {
                                        "port": 5432
                                    },
                                    "timeoutSeconds": 1
                                },
                                "name": "postgresql",
                                "ports": [
                                    {
                                        "containerPort": 5432
                                    }
                                ],
                                "resources": {
                                    "limits": {
                                        "memory": "${MEMORY_POSTGRESQL_LIMIT}"
                                    }
                                },
                                "volumeMounts": [
                                    {
                                        "mountPath": "/var/lib/pgsql/data",
                                        "name": "${DATABASE_SERVICE_NAME}-data"
                                    }
                                ]
                            }
                        ],
                        "volumes": [
                            {
                                "name": "${DATABASE_SERVICE_NAME}-data",
                                "persistentVolumeClaim": {
                                    "claimName": "${DATABASE_SERVICE_NAME}"
                                }
                            }
                        ]
                    }
                },
                "triggers": [
                    {
                        "imageChangeParams": {
                            "automatic": true,
                            "containerNames": [
                                "postgresql"
                            ],
                            "from": {
                                "kind": "ImageStreamTag",
                                "name": "postgresql:9.5",
                                "namespace": "openshift"
                            }
                        },
                        "type": "ImageChange"
                    },
                    {
                        "type": "ConfigChange"
                    }
                ]
            }
        }
    ],
    "parameters": [
        {
            "description": "The name assigned to all of the frontend objects defined in this template.",
            "displayName": "Name",
            "name": "NAME",
            "required": true,
            "value": "musicstore"
        },
        {
            "description": "Maximum amount of memory the .NET Core container can use.",
            "displayName": "Memory Limit",
            "name": "MEMORY_LIMIT",
            "required": true,
            "value": "128Mi"
        },
        {
            "description": "Maximum amount of memory the PostgreSQL container can use.",
            "displayName": "Memory Limit (PostgreSQL)",
            "name": "MEMORY_POSTGRESQL_LIMIT",
            "required": true,
            "value": "128Mi"
        },
        {
            "description": "Volume space available for data, e.g. 512Mi, 2Gi",
            "displayName": "Volume Capacity",
            "name": "VOLUME_CAPACITY",
            "required": true,
            "value": "256Mi"
        },
        {
            "description": "The image stream tag which is used to build the code.",
            "displayName": ".NET builder",
            "name": "DOTNET_IMAGE_STREAM_TAG",
            "required": true,
            "value": "dotnet:2.1"
        },
        {
            "description": "The OpenShift Namespace where the .NET builder ImageStream resides.",
            "displayName": "Namespace",
            "name": "NAMESPACE",
            "required": true,
            "value": "openshift"
        },
        {
            "description": "The URL of the repository with your application source code.",
            "displayName": "Git Repository URL",
            "name": "SOURCE_REPOSITORY_URL",
            "required": true,
            "value": "https://github.com/redhat-developer/s2i-aspnet-musicstore-ex.git"
        },
        {
            "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch.",
            "displayName": "Git Reference",
            "name": "SOURCE_REPOSITORY_REF",
            "value": "rel/2.1-example"
        },
        {
            "description": "Set this to the relative path to your project if it is not in the root of your repository.",
            "displayName": "Context Directory",
            "name": "CONTEXT_DIR"
        },
        {
            "description": "Set this to a project file (e.g. csproj) or a folder containing a single project file.",
            "displayName": "Startup Project",
            "name": "DOTNET_STARTUP_PROJECT",
            "value": "samples/MusicStore"
        },
        {
            "description": "Set this when the assembly name is overridden in the project file.",
            "displayName": "Startup Assembly",
            "name": "DOTNET_ASSEMBLY_NAME"
        },
        {
            "description": "Set this to a space separated list of .NET tools needed to publish.",
            "displayName": ".NET Tools",
            "name": "DOTNET_TOOLS"
        },
        {
            "description": "Set this to a space separated list of npm tools needed to publish.",
            "displayName": "Npm Tools",
            "name": "DOTNET_NPM_TOOLS"
        },
        {
            "description": "Set this to a space separated list of test projects to run before publishing.",
            "displayName": "Test projects",
            "name": "DOTNET_TEST_PROJECTS"
        },
        {
            "description": "Set this to configuration (Release/Debug).",
            "displayName": "Configuration",
            "name": "DOTNET_CONFIGURATION",
            "value": "Release"
        },
        {
            "description": "Set this to override the NuGet.config sources.",
            "displayName": "NuGet package sources",
            "name": "DOTNET_RESTORE_SOURCES"
        },
        {
            "description": "The exposed hostname that will route to the .NET Core service, if left blank a value will be defaulted.",
            "displayName": "Application Hostname",
            "name": "APPLICATION_DOMAIN",
            "value": ""
        },
        {
            "description": "A secret string used to configure the GitHub webhook.",
            "displayName": "GitHub Webhook Secret",
            "from": "[a-zA-Z0-9]{40}",
            "generate": "expression",
            "name": "GITHUB_WEBHOOK_SECRET"
        },
        {
            "displayName": "Database Service Name",
            "name": "DATABASE_SERVICE_NAME",
            "required": true,
            "value": "postgresql"
        },
        {
            "displayName": "Database Username",
            "from": "user[A-Z0-9]{3}",
            "generate": "expression",
            "name": "DATABASE_USER"
        },
        {
            "displayName": "Database Password",
            "from": "[a-zA-Z0-9]{8}",
            "generate": "expression",
            "name": "DATABASE_PASSWORD"
        },
        {
            "displayName": "Database Name",
            "name": "DATABASE_NAME",
            "required": true,
            "value": "musicstore"
        },
        {
            "displayName": "Maximum Database Connections",
            "name": "POSTGRESQL_MAX_CONNECTIONS",
            "value": "100"
        },
        {
            "displayName": "Shared Buffer Amount",
            "name": "POSTGRESQL_SHARED_BUFFERS",
            "value": "12MB"
        }
    ]
}