From 58eef02f80fb7dc3bcbacb2f25e99e5d437fd8ce Mon Sep 17 00:00:00 2001 From: Stuart Leeks Date: Thu, 29 Sep 2016 10:54:37 +0100 Subject: [PATCH] Initial changes to support #1 --- lambda3docker/dockerTask.js | 15 +++++++++++++++ lambda3docker/dockerTask.sh | 23 +++++++++++++++++------ lambda3docker/task.json | 17 +++++++++++++++++ 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/lambda3docker/dockerTask.js b/lambda3docker/dockerTask.js index bc94825..6a35bed 100644 --- a/lambda3docker/dockerTask.js +++ b/lambda3docker/dockerTask.js @@ -22,6 +22,11 @@ function run() { bash.arg("--env"); bash.arg(env); } + var defaultenv = tl.getInput('defaultenv', false); + if (env) { + bash.arg("--defaultenv"); + bash.arg(defaultenv); + } break; case "build": bash.arg("--build"); @@ -32,6 +37,11 @@ function run() { bash.arg("--env"); bash.arg(env); } + var defaultenv = tl.getInput('defaultenv', false); + if (env) { + bash.arg("--defaultenv"); + bash.arg(defaultenv); + } var context = tl.getInput('context', false); if (context) { bash.arg("--context"); @@ -47,6 +57,11 @@ function run() { bash.arg("--env"); bash.arg(env); } + var defaultenv = tl.getInput('defaultenv', false); + if (env) { + bash.arg("--defaultenv"); + bash.arg(defaultenv); + } var sshServer = tl.getInput('sshServer', false); if (sshServer) { bash.arg("--server"); diff --git a/lambda3docker/dockerTask.sh b/lambda3docker/dockerTask.sh index 0909525..c9ec7df 100644 --- a/lambda3docker/dockerTask.sh +++ b/lambda3docker/dockerTask.sh @@ -95,6 +95,17 @@ else env='Debug' fi +defaultenvIndex=$(arrayContains args "--defaultenv") +if [ $defaultenvIndex -gt -1 ]; then + defaultenv=${args[$(($defaultenvIndex + 1))]} + if [[ $defaultenv == --* ]]; then + >&2 echo "You must supply a valid value to --defaultenv." + exit 5 + fi +else + defaultenv='Debug' +fi + imageIndex=$(arrayContains args "--image") if [ $imageIndex -gt -1 ]; then imageName=${args[$(($imageIndex + 1))]} @@ -163,7 +174,7 @@ if [ $buildIndex -gt -1 ]; then context='.' fi imageNameExists - if [ $env == "Debug" ]; then + if [ $env == $defaultenv ]; then dockerFileName="Dockerfile" else dockerFileName="Dockerfile.$env" @@ -185,7 +196,7 @@ fi composeIndex=$(arrayContains args "--compose") if [ $composeIndex -gt -1 ]; then - if [ $env == "Debug" ]; then + if [ $env == $defaultenv ]; then composeFileName="docker-compose.yml" else composeFileName="docker-compose.$env.yml" @@ -260,7 +271,7 @@ fi cleanIndex=$(arrayContains args "--clean") if [ $cleanIndex -gt -1 ]; then imageNameExists - if [ $env == "Debug" ]; then + if [ $env == $defaultenv ]; then composeFileName="docker-compose.yml" else composeFileName="docker-compose.$env.yml" @@ -303,9 +314,9 @@ helpIndex=$(arrayContains args "--help") if [ $helpIndex -gt -1 ]; then echo " Usage: - ./dockerTask.sh --clean --image [--env (Debug|Release)] - ./dockerTask.sh --build --image [--env (Debug|Release)] [--context ] - ./dockerTask.sh --compose [--server --port --user --key ] [--env (Debug|Release)] [ --project ] + ./dockerTask.sh --clean --image [--env (Debug|Release)] [--defaultenv (Debug|Release)] + ./dockerTask.sh --build --image [--env (Debug|Release)] [--defaultenv (Debug|Release)] [--context ] + ./dockerTask.sh --compose [--server --port --user --key ] [--env (Debug|Release)] [--defaultenv (Debug|Release)] [ --project ] ./dockerTask.sh --push --image ./dockerTask.sh --help" exit 0 diff --git a/lambda3docker/task.json b/lambda3docker/task.json index c57d96e..0762a81 100644 --- a/lambda3docker/task.json +++ b/lambda3docker/task.json @@ -157,6 +157,23 @@ }, "groupName": "advanced" } + , + { + "name": "defaultenv", + "type": "pickList", + "label": "Default Environment", + "defaultValue": "Debug", + "required": false, + "helpMarkDown": "Default environment: Debug, Release, or type another. When the Environment property matches Default environment the taskk will use `Dockerfile`, otherwise it will use `Dockerfile.<environment>`", + "properties": { + "EditableOptions": "True" + }, + "options": { + "Debug": "Debug", + "Release": "Release" + }, + "groupName": "advanced" + } ], "execution": { "Node": {