Skip to content

Commit

Permalink
Initial changes to support Lambda3#1
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartleeks committed Sep 29, 2016
1 parent 0b670e6 commit 58eef02
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 6 deletions.
15 changes: 15 additions & 0 deletions lambda3docker/dockerTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand All @@ -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");
Expand Down
23 changes: 17 additions & 6 deletions lambda3docker/dockerTask.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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))]}
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -303,9 +314,9 @@ helpIndex=$(arrayContains args "--help")
if [ $helpIndex -gt -1 ]; then
echo "
Usage:
./dockerTask.sh --clean --image <IMAGE_NAME> [--env (Debug|Release)]
./dockerTask.sh --build --image <IMAGE_NAME> [--env (Debug|Release)] [--context <BUILD_CONTEXT>]
./dockerTask.sh --compose [--server <SSH_SERVER> --port <SSH_PORT> --user <SSH_USER> --key <SSH_KEY>] [--env (Debug|Release)] [ --project <DOCKER_COMPOSE_PROJECT_NAME> ]
./dockerTask.sh --clean --image <IMAGE_NAME> [--env (Debug|Release)] [--defaultenv (Debug|Release)]
./dockerTask.sh --build --image <IMAGE_NAME> [--env (Debug|Release)] [--defaultenv (Debug|Release)] [--context <BUILD_CONTEXT>]
./dockerTask.sh --compose [--server <SSH_SERVER> --port <SSH_PORT> --user <SSH_USER> --key <SSH_KEY>] [--env (Debug|Release)] [--defaultenv (Debug|Release)] [ --project <DOCKER_COMPOSE_PROJECT_NAME> ]
./dockerTask.sh --push --image <IMAGE_NAME>
./dockerTask.sh --help"
exit 0
Expand Down
17 changes: 17 additions & 0 deletions lambda3docker/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.&lt;environment&gt;`",
"properties": {
"EditableOptions": "True"
},
"options": {
"Debug": "Debug",
"Release": "Release"
},
"groupName": "advanced"
}
],
"execution": {
"Node": {
Expand Down

0 comments on commit 58eef02

Please sign in to comment.