# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

version: "3"

dotenv:
  - .env
  
tasks:
  default: task --list-all  

  deploy:
    vars:
      F: http://localhost
      N: 1
      P: 1
      R: OK
    cmds:
      - echo "Deploying with host {{.F}}"
      - F={{.F}} nuv -envsubst -i script-cm.yaml -o _script-cm.yaml
      - kubectl create -f locust-manifest.yaml -f nodeport.yaml
      
  # stress:  

  undeploy:
      - kubectl delete -f locust-manifest.yaml -f nodeport.yaml

  deploy:action:
    cmds:
      - nuv action update echo0 echo.js --web=true --memory 256         
      - nuv action update echo1 echo.js --web=true --memory 256               
      - nuv action update echo2 echo.js --web=true --memory 256         
      - nuv action update echo3 echo.js --web=true --memory 256         
      - nuv action update echo4 echo.js --web=true --memory 256
      - nuv action update redis0 redis.js --web=true --memory 256  -p redis_url "$REDIS_URL" -p redis_prefix "$REDIS_PREFIX"
      - nuv action update redis1 redis.js --web=true --memory 256  -p redis_url "$REDIS_URL" -p redis_prefix "$REDIS_PREFIX"               
      - nuv action update redis2 redis.js --web=true --memory 256  -p redis_url "$REDIS_URL" -p redis_prefix "$REDIS_PREFIX"         
      - nuv action update redis3 redis.js --web=true --memory 256  -p redis_url "$REDIS_URL" -p redis_prefix "$REDIS_PREFIX"         
      - nuv action update redis4 redis.js --web=true --memory 256  -p redis_url "$REDIS_URL" -p redis_prefix "$REDIS_PREFIX"              
      - nuv action update postgres0 postgres.js --web=true --memory 256 -p postgres_url "$POSTGRES_URL"
      - nuv action update postgres1 postgres.js --web=true --memory 256 -p postgres_url "$POSTGRES_URL"
      - nuv action update postgres2 postgres.js --web=true --memory 256 -p postgres_url "$POSTGRES_URL"
      - nuv action update postgres3 postgres.js --web=true --memory 256 -p postgres_url "$POSTGRES_URL"
      - nuv action update postgres4 postgres.js --web=true --memory 256 -p postgres_url "$POSTGRES_URL"
