def namespace = 'ballerina-playground-v2';

task deployWebServer(type: Exec) {
    dependsOn(":docker:nginx:cloudBuild")
    environment("RELEASE_VERSION", project.version)
    commandLine './deploy-web-server.sh'
}

task undeployWebServer(type: Exec) {
    commandLine './undeploy-web-server.sh'
}

task deployNfs(type: Exec) {
    commandLine './deploy-nfs.sh'
}

task undeployNfs(type: Exec) {
    commandLine './undeploy-nfs.sh'
}

task deployCompiler(type: Exec) {
    dependsOn(":docker:compiler:cloudBuild")
    environment("RELEASE_VERSION", project.version)
    commandLine './deploy-compiler.sh'
}

task deployExecutor(type: Exec) {
    dependsOn(":docker:executor:cloudBuild")
    environment("RELEASE_VERSION", project.version)
    commandLine './deploy-executor.sh'
}

task deployRedis(type: Exec) {
    dependsOn(":docker:redis-slave:cloudBuild")
    environment("RELEASE_VERSION", project.version)
    environment("BPG_NAMESPACE", namespace)
    commandLine './deploy-redis.sh'
}

task undeployRedis(type: Exec) {
    environment("BPG_NAMESPACE", namespace)
    commandLine './undeploy-redis.sh'
}

task undeployExecutor(type: Exec) {
    commandLine './undeploy-executor.sh'
}

task deployController(type: Exec) {
    dependsOn(":docker:controller:cloudBuild")
    environment("RELEASE_VERSION", project.version)
    commandLine './deploy-controller.sh'
}

task deployGists(type: Exec) {
    dependsOn(":docker:gists:cloudBuild")
    environment("BPG_NAMESPACE", namespace)
    environment("RELEASE_VERSION", project.version)
    commandLine './deploy-gists.sh'
}

task undeployCompiler(type: Exec) {
    commandLine './undeploy-compiler.sh'
}

task undeployGists(type: Exec) {
    environment("BPG_NAMESPACE", namespace)
    commandLine './undeploy-gists.sh'
}

task undeployController(type: Exec) {
    commandLine './undeploy-controller.sh'
}

task deployIngressResources(type: Exec) {
    commandLine './deploy-ingress-resources.sh'
}

task undeployIngressResources(type: Exec) {
    commandLine './undeploy-ingress-resources.sh'
}

task deploy {
    dependsOn deployGists
    dependsOn deployWebServer
    dependsOn deployCompiler
    dependsOn deployExecutor
    dependsOn deployController
    dependsOn deployIngressResources
}

task undeploy {
    dependsOn undeployGists
    dependsOn undeployWebServer
    dependsOn undeployCompiler
    dependsOn undeployExecutor
    dependsOn undeployController
    dependsOn undeployIngressResources
}