From 7a2bbcede061b26cd478a78096512a4bd759ec3e Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Mon, 15 Oct 2012 18:43:59 +0200 Subject: o Renaming './app app' to './app instance'. --- .app/lib/app-app | 456 -------------------------------------------- .app/lib/app-instance | 456 ++++++++++++++++++++++++++++++++++++++++++++ app | 10 +- app_completion | 6 +- docs/README.md | 2 +- test/app-help.bats | 22 +-- test/app-install.bats | 8 +- test/app-list-versions.bats | 16 +- test/app-list.bats | 70 +++---- 9 files changed, 523 insertions(+), 523 deletions(-) delete mode 100644 .app/lib/app-app create mode 100644 .app/lib/app-instance diff --git a/.app/lib/app-app b/.app/lib/app-app deleted file mode 100644 index cb87847..0000000 --- a/.app/lib/app-app +++ /dev/null @@ -1,456 +0,0 @@ -#!/bin/bash - -if [ -n "$APPSH_REPO" ] -then - repo="$APPSH_REPO" -else - repo="http://repo1.maven.org" -fi - -# TODO: support file:// repositories -# TODO: look in the local repository first -# TODO: assert that we got a 200 OK -get() { - local exit - - curl -o $2 $1 -D curl.tmp - - exit=`grep "^HTTP/[0-9]\.[0-9] 200 .*" curl.tmp >/dev/null; echo $?` - head=`head -n 1 curl.tmp` - rm curl.tmp - if [ "$exit" != 0 ] - then - echo "Unable to download $1: $head" - exit 1 - fi -} - -resolved_version="" -resolve_snapshot() { - local base_url - local metadata - local zip_file=$1 - - echo "Resolving version $version..." - metadata=$BASEDIR/.app/var/download/$groupId-$artifactId-$version-metadata.xml - base_url=$repo/$(echo $groupId | sed "s,\.,/,g")/$artifactId/$version - get $base_url/maven-metadata.xml $metadata - resolved_version=`xmlstarlet sel -t -m '//snapshotVersion[extension[text()="zip"]]' -v value $metadata` - - if [ -z "$resolved_version" ] - then - echo "Unable to resolve version." - exit 1 - fi - echo "Resolved version $version to $resolved_version" - - if [ -r $zip_file ] - then - echo "Artifact already downloaded." - return 0 - fi - echo "Downloading artifact" - base_url=$repo/$(echo $groupId | sed "s,\.,/,g")/$artifactId/$version - get $base_url/$artifactId-$resolved_version.zip $zip_file - - # TODO: download checksum. bash is too shady to trust -} - -method_install_usage() { - if [ -n "$1" ] - then - echo "Error:" "$@" >&2 - fi - - echo "usage: install <-r resolver> -u " >&2 - echo "" >&2 - echo "Install package from a Maven repository:" >&2 - echo " $0 [-n name] [-i instance] app install -r maven -u groupId:artifactId:version" >&2 - echo "" >&2 - echo "Install package from a file:" >&2 - echo " $0 [-n name] [-i instance] app install -r file -u file [-v version]" >&2 - echo "The version defaults to the current timestamp" >&2 - exit 1 -} - -method_install() { - local name="$1"; shift - local instance="$1"; shift - local version - local resolver - local url - local groupId - local artifactId - local zip_file - - - if [ $# -eq 0 ] - then - method_install_usage - fi - - while getopts "n:i:v:r:u:" opt - do - case $opt in - n) - name=$OPTARG - ;; - i) - instance=$OPTARG - ;; - v) - version=$OPTARG - ;; - r) - resolver=$OPTARG - ;; - u) - url=$OPTARG - ;; - \?) - method_install_usage "Invalid option: -$OPTARG" - ;; - esac - done - - if [ -z "$name" ] - then - method_install_usage "Missing required argument: -i name." - fi - - if [ -z "$instance" ] - then - method_install_usage "Missing required argument: -i instance." - fi - - if [ -z "$resolver" ] - then - method_install_usage "Missing required option: -r resolver" - fi - - if [ -z "$url" ] - then - method_install_usage "Missing required option: -u url" - fi - - case "$resolver" in - maven) - url=`echo $url | tr ":" " "`; set -- $url - groupId=$1 - artifactId=$2 - version=$3 - - if [ -z "$groupId" -o -z "$artifactId" -o -z "$version" ] - then - method_install_usage "Invalid Maven url." - fi - - resolve_snapshot - - zip_file=$BASEDIR/.app/var/download/$groupId-$artifactId-$resolved_version.zip - - download_artifact $zip_file - ;; - file) - if [ ! -r "$url" ] - then - echo "Could not read file: $url" >&2 - exit 1 - fi - - # TODO: should the zip file be copied into download/ so that - # there's always a local copy? - zip_file=$url - - if [ -z "$version" ] - then - version=`TZ=UTC date +"%Y%m%d-%H%M%S"` - fi - - resolved_version=$version - ;; - *) - method_install_usage "Invalid resolver type: $resolver" - ;; - esac - - if [ -d $name/$instance/versions/$resolved_version ] - then - echo "Version $resolved_version is already installed" - exit 1 - fi - - if [ ! -d $name/$instance ] - then - echo "Creating instance '$instance' for '$name'" - mkdir -p $name/$instance - fi - - mkdir -p $name/$instance/versions/$resolved_version - - echo "Unpacking..." - unzip -q -d $name/$instance/versions/$resolved_version $zip_file - - if [ ! -d $BASEDIR/$name/$instance/versions/$resolved_version/root ] - then - echo "Invalid zip file, did not contain a ./root directory." >&2 - exit 1 - fi - - ( - cd $name/$instance/versions/$resolved_version - if [ -d scripts ] - then - find scripts | xargs chmod +x - fi - - if [ -x scripts/postinstall ] - then - echo "Running postinstall..." - set +e - env -i \ - PATH=/bin:/usr/bin \ - scripts/postinstall - set -e - ret=`echo $?` - if [ "$ret" != 0 ] - then - echo "Postinstall failed!" - exit 1 - fi - echo "Postinstall completed successfully" - fi - ) - - echo "Changing current symlink" - rm -f $BASEDIR/$name/$instance/current - ln -s versions/$resolved_version/root $BASEDIR/$name/$instance/current - - if [ -d $name/$instance/current/bin ] - then - ( - cd $name/$instance/current - find bin -type f | xargs chmod +x - ) - fi - - if [ -r $BASEDIR/.app/var/list ] - then - sed "/^$name:$instance/d" $BASEDIR/.app/var/list > $BASEDIR/.app/var/list.new - fi - echo "$name:$instance:$version:$url" >> $BASEDIR/.app/var/list.new - mv $BASEDIR/.app/var/list.new $BASEDIR/.app/var/list -} - -method_set_current_usage() { - if [ -n "$1" ] - then - echo "Error:" "$@" >&2 - fi - - echo "usage: set-current -v version" >&2 - exit 1 -} - -method_set_current() { - local name="$1"; shift - local instance="$1"; shift - local version - - if [ $# -eq 0 ] - then - method_set_current_usage - fi - - while getopts "n:i:v:" opt - do - case $opt in - n) - name=$OPTARG - ;; - i) - instance=$OPTARG - ;; - v) - version=$OPTARG - ;; - \?) - method_set_current_usage "Invalid option: -$OPTARG" - ;; - esac - done - - if [ -z "$version" ] - then - echo "Missing required option -v version." >&2 - exit 1 - fi - - assert_is_instance method_set_current_usage "$name" "$instance" "no" - - if [ ! -d $BASEDIR/$name/$instance/versions/$version ] - then - echo "Invalid version: $version." - exit 1 - fi - - rm -f $BASEDIR/$name/$instance/current - ln -s versions/$version/root $BASEDIR/$name/$instance/current - - return 0 -} - -method_list_usage() { - if [ -n "$1" ] - then - echo "Error:" "$@" >&2 - fi - - echo "usage: list [-n name] [-P field]" >&2 - echo "" - echo "List all installed applications:" >&2 - echo " list" >&2 - echo "" - echo "List all applications with the selected fields with parseable output:" >&2 - echo " list -P instance -P version -n foo" >&2 - exit 1 -} - -method_list() { - local filter_name="$1"; shift - local filter_instance="$1"; shift - local mode="pretty" - local vars - local filter_name - - while getopts "P:n:i:" opt - do - case $opt in - P) - mode="parseable" - vars="$vars $OPTARG" - ;; - n) - filter_name=$OPTARG - ;; - i) - filter_instance=$OPTARG - ;; - \?) - method_list_usage "Invalid option: -$OPTARG" - ;; - esac - done - - if [ ! -r $BASEDIR/.app/var/list ] - then - return - fi - - if [ $mode = "pretty" ] - then - printf "%-20s %-20s %-20s\n" "Name" "Instance" "Version" - list_apps "$filter_name" "$filter_instance" name instance version | (IFS=:; while read name instance version - do - printf "%-20s %-20s %-20s\n" "$name" "$instance" "$version" - done) - else - list_apps "$filter_name" "$filter_instance" $vars - fi -} - -method_list_versions_usage() { - if [ -n "$1" ] - then - echo "Error:" "$@" >&2 - fi - - echo "usage: list-versions -n name -i instance [-P]" >&2 - exit 1 -} - -method_list_versions() { - local filter_name="$1"; shift - local instance="$1"; shift - local version - local mode="pretty" - - if [ $# -eq 0 ] - then - method_list_versions_usage - fi - - while getopts "n:i:P" opt - do - case $opt in - n) - name=$OPTARG - ;; - i) - instance=$OPTARG - ;; - v) - version=$OPTARG - ;; - P) - mode="parseable" - ;; - \?) - method_list_versions_usage "Invalid option: -$OPTARG" - ;; - esac - done - - assert_is_instance method_list_versions_usage "$name" "$instance" "no" - - if [ $mode = "pretty" ] - then - echo "Available versions for $name/$instance:" - fi - - find_versions $name $instance - - return 0 -} - -method_app_usage() { - if [ -n "$1" ] - then - echo "Error:" $@ >&2 - fi - - echo "usage: $0 app " >&2 - echo "" >&2 - echo "Available methods:" >&2 - echo " install - Installs an application" >&2 - echo " list - List all installed applications" >&2 - echo " list-versions - List all available versions for a single application" >&2 - echo " set-current - Set the current version" >&2 -} - -method_app() { - local name="$1"; shift - local instance="$1"; shift - local method="$1" - - if [ $# -gt 0 ] - then - shift - fi - - case "$method" in - install) method_install "$name" "$instance" "$@" ;; - list) method_list "$name" "$instance" "$@" ;; - list-versions) method_list_versions "$name" "$instance" "$@" ;; - set-current) method_set_current "$name" "$instance" "$@" ;; - *) - if [ -z "$method" ] - then - method_app_usage - else - method_app_usage "Unknown method $method" - fi - ;; - esac - exit $? -} diff --git a/.app/lib/app-instance b/.app/lib/app-instance new file mode 100644 index 0000000..2012a74 --- /dev/null +++ b/.app/lib/app-instance @@ -0,0 +1,456 @@ +#!/bin/bash + +if [ -n "$APPSH_REPO" ] +then + repo="$APPSH_REPO" +else + repo="http://repo1.maven.org" +fi + +# TODO: support file:// repositories +# TODO: look in the local repository first +# TODO: assert that we got a 200 OK +get() { + local exit + + curl -o $2 $1 -D curl.tmp + + exit=`grep "^HTTP/[0-9]\.[0-9] 200 .*" curl.tmp >/dev/null; echo $?` + head=`head -n 1 curl.tmp` + rm curl.tmp + if [ "$exit" != 0 ] + then + echo "Unable to download $1: $head" + exit 1 + fi +} + +resolved_version="" +resolve_snapshot() { + local base_url + local metadata + local zip_file=$1 + + echo "Resolving version $version..." + metadata=$BASEDIR/.app/var/download/$groupId-$artifactId-$version-metadata.xml + base_url=$repo/$(echo $groupId | sed "s,\.,/,g")/$artifactId/$version + get $base_url/maven-metadata.xml $metadata + resolved_version=`xmlstarlet sel -t -m '//snapshotVersion[extension[text()="zip"]]' -v value $metadata` + + if [ -z "$resolved_version" ] + then + echo "Unable to resolve version." + exit 1 + fi + echo "Resolved version $version to $resolved_version" + + if [ -r $zip_file ] + then + echo "Artifact already downloaded." + return 0 + fi + echo "Downloading artifact" + base_url=$repo/$(echo $groupId | sed "s,\.,/,g")/$artifactId/$version + get $base_url/$artifactId-$resolved_version.zip $zip_file + + # TODO: download checksum. bash is too shady to trust +} + +method_install_usage() { + if [ -n "$1" ] + then + echo "Error:" "$@" >&2 + fi + + echo "usage: install <-r resolver> -u " >&2 + echo "" >&2 + echo "Install package from a Maven repository:" >&2 + echo " $0 [-n name] [-i instance] instance install -r maven -u groupId:artifactId:version" >&2 + echo "" >&2 + echo "Install package from a file:" >&2 + echo " $0 [-n name] [-i instance] instance install -r file -u file [-v version]" >&2 + echo "The version defaults to the current timestamp" >&2 + exit 1 +} + +method_install() { + local name="$1"; shift + local instance="$1"; shift + local version + local resolver + local url + local groupId + local artifactId + local zip_file + + + if [ $# -eq 0 ] + then + method_install_usage + fi + + while getopts "n:i:v:r:u:" opt + do + case $opt in + n) + name=$OPTARG + ;; + i) + instance=$OPTARG + ;; + v) + version=$OPTARG + ;; + r) + resolver=$OPTARG + ;; + u) + url=$OPTARG + ;; + \?) + method_install_usage "Invalid option: -$OPTARG" + ;; + esac + done + + if [ -z "$name" ] + then + method_install_usage "Missing required argument: -i name." + fi + + if [ -z "$instance" ] + then + method_install_usage "Missing required argument: -i instance." + fi + + if [ -z "$resolver" ] + then + method_install_usage "Missing required option: -r resolver" + fi + + if [ -z "$url" ] + then + method_install_usage "Missing required option: -u url" + fi + + case "$resolver" in + maven) + url=`echo $url | tr ":" " "`; set -- $url + groupId=$1 + artifactId=$2 + version=$3 + + if [ -z "$groupId" -o -z "$artifactId" -o -z "$version" ] + then + method_install_usage "Invalid Maven url." + fi + + resolve_snapshot + + zip_file=$BASEDIR/.app/var/download/$groupId-$artifactId-$resolved_version.zip + + download_artifact $zip_file + ;; + file) + if [ ! -r "$url" ] + then + echo "Could not read file: $url" >&2 + exit 1 + fi + + # TODO: should the zip file be copied into download/ so that + # there's always a local copy? + zip_file=$url + + if [ -z "$version" ] + then + version=`TZ=UTC date +"%Y%m%d-%H%M%S"` + fi + + resolved_version=$version + ;; + *) + method_install_usage "Invalid resolver type: $resolver" + ;; + esac + + if [ -d $name/$instance/versions/$resolved_version ] + then + echo "Version $resolved_version is already installed" + exit 1 + fi + + if [ ! -d $name/$instance ] + then + echo "Creating instance '$instance' for '$name'" + mkdir -p $name/$instance + fi + + mkdir -p $name/$instance/versions/$resolved_version + + echo "Unpacking..." + unzip -q -d $name/$instance/versions/$resolved_version $zip_file + + if [ ! -d $BASEDIR/$name/$instance/versions/$resolved_version/root ] + then + echo "Invalid zip file, did not contain a ./root directory." >&2 + exit 1 + fi + + ( + cd $name/$instance/versions/$resolved_version + if [ -d scripts ] + then + find scripts | xargs chmod +x + fi + + if [ -x scripts/postinstall ] + then + echo "Running postinstall..." + set +e + env -i \ + PATH=/bin:/usr/bin \ + scripts/postinstall + set -e + ret=`echo $?` + if [ "$ret" != 0 ] + then + echo "Postinstall failed!" + exit 1 + fi + echo "Postinstall completed successfully" + fi + ) + + echo "Changing current symlink" + rm -f $BASEDIR/$name/$instance/current + ln -s versions/$resolved_version/root $BASEDIR/$name/$instance/current + + if [ -d $name/$instance/current/bin ] + then + ( + cd $name/$instance/current + find bin -type f | xargs chmod +x + ) + fi + + if [ -r $BASEDIR/.app/var/list ] + then + sed "/^$name:$instance/d" $BASEDIR/.app/var/list > $BASEDIR/.app/var/list.new + fi + echo "$name:$instance:$version:$url" >> $BASEDIR/.app/var/list.new + mv $BASEDIR/.app/var/list.new $BASEDIR/.app/var/list +} + +method_set_current_usage() { + if [ -n "$1" ] + then + echo "Error:" "$@" >&2 + fi + + echo "usage: set-current -v version" >&2 + exit 1 +} + +method_set_current() { + local name="$1"; shift + local instance="$1"; shift + local version + + if [ $# -eq 0 ] + then + method_set_current_usage + fi + + while getopts "n:i:v:" opt + do + case $opt in + n) + name=$OPTARG + ;; + i) + instance=$OPTARG + ;; + v) + version=$OPTARG + ;; + \?) + method_set_current_usage "Invalid option: -$OPTARG" + ;; + esac + done + + if [ -z "$version" ] + then + echo "Missing required option -v version." >&2 + exit 1 + fi + + assert_is_instance method_set_current_usage "$name" "$instance" "no" + + if [ ! -d $BASEDIR/$name/$instance/versions/$version ] + then + echo "Invalid version: $version." + exit 1 + fi + + rm -f $BASEDIR/$name/$instance/current + ln -s versions/$version/root $BASEDIR/$name/$instance/current + + return 0 +} + +method_list_usage() { + if [ -n "$1" ] + then + echo "Error:" "$@" >&2 + fi + + echo "usage: list [-n name] [-P field]" >&2 + echo "" + echo "List all installed applications:" >&2 + echo " list" >&2 + echo "" + echo "List all applications with the selected fields with parseable output:" >&2 + echo " list -P instance -P version -n foo" >&2 + exit 1 +} + +method_list() { + local filter_name="$1"; shift + local filter_instance="$1"; shift + local mode="pretty" + local vars + local filter_name + + while getopts "P:n:i:" opt + do + case $opt in + P) + mode="parseable" + vars="$vars $OPTARG" + ;; + n) + filter_name=$OPTARG + ;; + i) + filter_instance=$OPTARG + ;; + \?) + method_list_usage "Invalid option: -$OPTARG" + ;; + esac + done + + if [ ! -r $BASEDIR/.app/var/list ] + then + return + fi + + if [ $mode = "pretty" ] + then + printf "%-20s %-20s %-20s\n" "Name" "Instance" "Version" + list_apps "$filter_name" "$filter_instance" name instance version | (IFS=:; while read name instance version + do + printf "%-20s %-20s %-20s\n" "$name" "$instance" "$version" + done) + else + list_apps "$filter_name" "$filter_instance" $vars + fi +} + +method_list_versions_usage() { + if [ -n "$1" ] + then + echo "Error:" "$@" >&2 + fi + + echo "usage: list-versions -n name -i instance [-P]" >&2 + exit 1 +} + +method_list_versions() { + local filter_name="$1"; shift + local instance="$1"; shift + local version + local mode="pretty" + + if [ $# -eq 0 ] + then + method_list_versions_usage + fi + + while getopts "n:i:P" opt + do + case $opt in + n) + name=$OPTARG + ;; + i) + instance=$OPTARG + ;; + v) + version=$OPTARG + ;; + P) + mode="parseable" + ;; + \?) + method_list_versions_usage "Invalid option: -$OPTARG" + ;; + esac + done + + assert_is_instance method_list_versions_usage "$name" "$instance" "no" + + if [ $mode = "pretty" ] + then + echo "Available versions for $name/$instance:" + fi + + find_versions $name $instance + + return 0 +} + +method_instance_usage() { + if [ -n "$1" ] + then + echo "Error:" $@ >&2 + fi + + echo "usage: $0 instance " >&2 + echo "" >&2 + echo "Available methods:" >&2 + echo " install - Installs an application" >&2 + echo " list - List all installed applications" >&2 + echo " list-versions - List all available versions for a single application" >&2 + echo " set-current - Set the current version" >&2 +} + +method_instance() { + local name="$1"; shift + local instance="$1"; shift + local method="$1" + + if [ $# -gt 0 ] + then + shift + fi + + case "$method" in + install) method_install "$name" "$instance" "$@" ;; + list) method_list "$name" "$instance" "$@" ;; + list-versions) method_list_versions "$name" "$instance" "$@" ;; + set-current) method_set_current "$name" "$instance" "$@" ;; + *) + if [ -z "$method" ] + then + method_instance_usage + else + method_instance_usage "Unknown method $method" + fi + ;; + esac + exit $? +} diff --git a/app b/app index 0c4cbd1..f02f11d 100755 --- a/app +++ b/app @@ -35,7 +35,7 @@ method_usage() { echo "usage: $0 [-n name] [-i instance] " >&2 echo "" >&2 echo "Available method groups:" >&2 - echo " app" >&2 + echo " instance" >&2 echo " conf" >&2 echo " operate" >&2 echo "" >&2 @@ -43,7 +43,7 @@ method_usage() { } . $APPSH_HOME/.app/lib/app-common -. $APPSH_HOME/.app/lib/app-app +. $APPSH_HOME/.app/lib/app-instance . $APPSH_HOME/.app/lib/app-conf . $APPSH_HOME/.app/lib/app-operate @@ -75,8 +75,8 @@ main() { method_usage else case "$h" in - app) - method_app_usage + instance) + method_instance_usage ;; conf) method_conf_usage @@ -104,7 +104,7 @@ main() { fi case "$method" in - app) method_app "$name" "$instance" "$@" ;; + instance) method_instance "$name" "$instance" "$@" ;; conf) method_conf "$name" "$instance" "$@" ;; operate) method_operate "$name" "$instance" "$@" ;; *) diff --git a/app_completion b/app_completion index 68a3b7b..c4bfe02 100644 --- a/app_completion +++ b/app_completion @@ -6,7 +6,7 @@ _appsh_contains() { } _appsh_methods=( - "app" + "instance" "conf" "operate" ) @@ -58,14 +58,14 @@ _complete_appsh() { case $prev in -n) - values=$(./app app list -P name) + values=$(./app instance list -P name) COMPREPLY=($(compgen -W "$values" -- ${cur})) return 0 ;; -i) if [ -n "$has_n" ] then - values=$(./app app list -n $has_n -P instance) + values=$(./app instance list -n $has_n -P instance) COMPREPLY=($(compgen -W "$values" -- ${cur})) return 0 fi diff --git a/docs/README.md b/docs/README.md index f818faf..a757254 100644 --- a/docs/README.md +++ b/docs/README.md @@ -40,7 +40,7 @@ TODOs Commands -------- -### `app` +### `instance` #### `install` diff --git a/test/app-help.bats b/test/app-help.bats index 68f88e3..4b94f23 100755 --- a/test/app-help.bats +++ b/test/app-help.bats @@ -3,35 +3,35 @@ load utils -@test "./app app" { - app app; echo_lines +@test "./app instance" { + app instance; echo_lines [ $status -eq $exit_usage_wrong ] - [ $(expr "${lines[0]}" : "usage: ./app app .*") -ne 0 ] + [ $(expr "${lines[0]}" : "usage: ./app instance .*") -ne 0 ] [ ${#lines[*]} == 6 ] } -@test "./app app install" { - app app install; echo_lines +@test "./app instance install" { + app instance install; echo_lines [ $status -eq $exit_usage ] [ $(expr "${lines[0]}" : "usage: install .*") -ne 0 ] [ ${#lines[*]} == 6 ] } -@test "./app app list" { - app app list; echo_lines +@test "./app instance list" { + app instance list; echo_lines [ $status -eq 0 ] [ ${#lines[*]} == 0 ] } -@test "./app app list-versions" { - app app list-versions; echo_lines +@test "./app instance list-versions" { + app instance list-versions; echo_lines [ $status -eq $exit_usage ] [ $(expr "${lines[0]}" : "usage: list-versions .*") -ne 0 ] [ ${#lines[*]} == 1 ] } -@test "./app app set-current" { - app app "set-current"; echo_lines +@test "./app instance set-current" { + app instance "set-current"; echo_lines [ $status -eq $exit_usage ] [ $(expr "${lines[0]}" : "usage: set-current .*") -ne 0 ] [ ${#lines[*]} == 1 ] diff --git a/test/app-install.bats b/test/app-install.bats index 9961c84..59880bd 100755 --- a/test/app-install.bats +++ b/test/app-install.bats @@ -5,9 +5,9 @@ load utils # TODO: Add test for installing duplicate version -@test "./app app install app-a" { +@test "./app instance install app-a" { mkzip "app-a" - app app install \ + app instance install \ -r file \ -u $BATS_TEST_DIRNAME/data/app-a.zip \ -n app-a -i prod @@ -23,9 +23,9 @@ Changing current symlink" ] [ ${#lines[*]} == 6 ] } -@test "./app app install install-test-env" { +@test "./app instance install install-test-env" { mkzip "install-test-env" - app app install \ + app instance install \ -r file \ -u $BATS_TEST_DIRNAME/data/install-test-env.zip \ -n install-test-env -i prod -v 1.0 diff --git a/test/app-list-versions.bats b/test/app-list-versions.bats index 207a282..17fb2d2 100755 --- a/test/app-list-versions.bats +++ b/test/app-list-versions.bats @@ -3,22 +3,22 @@ load utils -@test "./app app list-versions" { +@test "./app instance list-versions" { mkzip "app-a" - app app install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-a -v 1.0 && - app app install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-a -v 1.1 && - app app install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-b -v 1.0 && - app app install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-b -i env-a -v 1.0 && - app app install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-b -i env-b -v 1.0 + app instance install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-a -v 1.0 && + app instance install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-a -v 1.1 && + app instance install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-b -v 1.0 && + app instance install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-b -i env-a -v 1.0 && + app instance install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-b -i env-b -v 1.0 [ $status -eq 0 ] - app app list-versions -n app-a -i env-a; echo_lines + app instance list-versions -n app-a -i env-a; echo_lines [ $status -eq 0 ] [ "$output" = "Available versions for app-a/env-a: 1.0 1.1" ] - app app list-versions -n app-a -i env-a -P; echo_lines + app instance list-versions -n app-a -i env-a -P; echo_lines [ $status -eq 0 ] [ "$output" = "1.0 1.1" ] diff --git a/test/app-list.bats b/test/app-list.bats index e7e06e9..3092837 100755 --- a/test/app-list.bats +++ b/test/app-list.bats @@ -3,16 +3,16 @@ load utils -@test "./app app list - all apps" { +@test "./app instance list - all apps" { mkzip "app-a" - app app install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-a -v 1.0 && - app app install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-a -v 1.1 && - app app install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-b -v 1.0 && - app app install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-b -i env-a -v 1.0 && - app app install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-b -i env-b -v 1.0 + app instance install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-a -v 1.0 && + app instance install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-a -v 1.1 && + app instance install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-b -v 1.0 && + app instance install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-b -i env-a -v 1.0 && + app instance install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-b -i env-b -v 1.0 [ $status -eq 0 ] - app app list; echo_lines + app instance list; echo_lines [ $status -eq 0 ] [ "$output" = "Name Instance Version app-a env-a 1.1 @@ -20,7 +20,7 @@ app-a env-b 1.0 app-b env-a 1.0 app-b env-b 1.0 " ] - app app list -P name -P instance -P version; echo_lines + app instance list -P name -P instance -P version; echo_lines [ $status -eq 0 ] [ "$output" = "app-a:env-a:1.1 app-a:env-b:1.0 @@ -28,75 +28,75 @@ app-b:env-a:1.0 app-b:env-b:1.0" ] } -@test "./app app list - -n filter" { +@test "./app instance list - -n filter" { mkzip "app-a" - app app install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-a -v 1.0 && - app app install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-a -v 1.1 && - app app install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-b -v 1.0 && - app app install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-b -i env-a -v 1.0 && - app app install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-b -i env-b -v 1.0 + app instance install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-a -v 1.0 && + app instance install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-a -v 1.1 && + app instance install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-b -v 1.0 && + app instance install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-b -i env-a -v 1.0 && + app instance install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-b -i env-b -v 1.0 [ $status -eq 0 ] - app app list -n foo; echo_lines + app instance list -n foo; echo_lines [ $status -eq 0 ] [ "$output" = "Name Instance Version " ] - app app list -n app-a; echo_lines + app instance list -n app-a; echo_lines [ $status -eq 0 ] [ "$output" = "Name Instance Version app-a env-a 1.1 app-a env-b 1.0 " ] - app app list -n app-a -P name -P instance -P version; echo_lines + app instance list -n app-a -P name -P instance -P version; echo_lines [ $status -eq 0 ] [ "$output" = "app-a:env-a:1.1 app-a:env-b:1.0" ] } -@test "./app app list - -i filter" { +@test "./app instance list - -i filter" { mkzip "app-a" - app app install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-a -v 1.0 && - app app install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-a -v 1.1 && - app app install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-b -v 1.0 && - app app install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-b -i env-a -v 1.0 && - app app install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-b -i env-b -v 1.0 + app instance install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-a -v 1.0 && + app instance install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-a -v 1.1 && + app instance install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-b -v 1.0 && + app instance install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-b -i env-a -v 1.0 && + app instance install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-b -i env-b -v 1.0 [ $status -eq 0 ] - app app list -i foo; echo_lines + app instance list -i foo; echo_lines [ $status -eq 0 ] [ "$output" = "Name Instance Version " ] - app app list -i env-a; echo_lines + app instance list -i env-a; echo_lines [ $status -eq 0 ] [ "$output" = "Name Instance Version app-a env-a 1.1 app-b env-a 1.0 " ] - app app list -i env-a -P name -P instance -P version; echo_lines + app instance list -i env-a -P name -P instance -P version; echo_lines [ $status -eq 0 ] [ "$output" = "app-a:env-a:1.1 app-b:env-a:1.0" ] } -@test "./app app list - -n + -i filter" { +@test "./app instance list - -n + -i filter" { mkzip "app-a" - app app install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-a -v 1.0 && - app app install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-a -v 1.1 && - app app install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-b -v 1.0 && - app app install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-b -i env-a -v 1.0 && - app app install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-b -i env-b -v 1.0 + app instance install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-a -v 1.0 && + app instance install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-a -v 1.1 && + app instance install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-a -i env-b -v 1.0 && + app instance install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-b -i env-a -v 1.0 && + app instance install -r file -u $BATS_TEST_DIRNAME/data/app-a.zip -n app-b -i env-b -v 1.0 [ $status -eq 0 ] - app app list -n foo -i bar; echo_lines + app instance list -n foo -i bar; echo_lines [ $status -eq 0 ] [ "$output" = "Name Instance Version " ] - app app list -n app-a -i env-a; echo_lines + app instance list -n app-a -i env-a; echo_lines [ $status -eq 0 ] [ "$output" = "Name Instance Version app-a env-a 1.1 " ] - app app list -n app-a -i env-a -P name -P instance -P version; echo_lines + app instance list -n app-a -i env-a -P name -P instance -P version; echo_lines [ $status -eq 0 ] [ "$output" = "app-a:env-a:1.1" ] } -- cgit v1.2.3