We can install|use|uninstall version that is prefixed with v
parent
0d96fa467c
commit
cacd45eb62
16
README.md
16
README.md
|
@ -56,7 +56,7 @@ Install a specific version of driftctl.
|
||||||
|
|
||||||
Available options:
|
Available options:
|
||||||
|
|
||||||
- `x.y.z` to install the exact version of driftctl
|
- `(v)x.y.z` to install the exact version of driftctl
|
||||||
- `latest` to install the latest version of driftctl
|
- `latest` to install the latest version of driftctl
|
||||||
|
|
||||||
```console
|
```console
|
||||||
|
@ -102,13 +102,17 @@ Switch a version to use.
|
||||||
|
|
||||||
Available options:
|
Available options:
|
||||||
|
|
||||||
- `x.y.z` to install and use the exact version of driftctl
|
- `(v)x.y.z` to install and use the exact version of driftctl
|
||||||
- `latest` to install and use the latest version of driftctl
|
- `latest` to install and use the latest version of driftctl
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ dctlenv use 0.2.3
|
$ dctlenv use 0.2.3
|
||||||
Switching version to v0.2.3
|
Switching version to v0.2.3
|
||||||
Switching completed
|
Switching completed
|
||||||
|
|
||||||
|
$ dctlenv use v0.6.0
|
||||||
|
Switching version to v0.6.0
|
||||||
|
Switching completed
|
||||||
```
|
```
|
||||||
|
|
||||||
### `dctlenv list`
|
### `dctlenv list`
|
||||||
|
@ -139,10 +143,18 @@ $ dctlenv list-remote
|
||||||
|
|
||||||
Uninstall a specific version of driftctl.
|
Uninstall a specific version of driftctl.
|
||||||
|
|
||||||
|
Available options:
|
||||||
|
|
||||||
|
- `(v)x.y.z` to uninstall the exact version of driftctl
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ dctlenv uninstall 0.2.3
|
$ dctlenv uninstall 0.2.3
|
||||||
Uninstall driftctl v0.2.3
|
Uninstall driftctl v0.2.3
|
||||||
driftctl v0.2.3 is successfully uninstalled
|
driftctl v0.2.3 is successfully uninstalled
|
||||||
|
|
||||||
|
$ dctlenv uninstall v0.6.0
|
||||||
|
Uninstall driftctl v0.6.0
|
||||||
|
driftctl v0.6.0 is successfully uninstalled
|
||||||
```
|
```
|
||||||
|
|
||||||
### `dctlenv root`
|
### `dctlenv root`
|
||||||
|
|
|
@ -6,6 +6,8 @@ set -uo pipefail
|
||||||
version_requested="${1:-""}"
|
version_requested="${1:-""}"
|
||||||
[ -n "$version_requested" ] || log_error 'Version is not specified' 'usage: dctlenv install [<version>]'
|
[ -n "$version_requested" ] || log_error 'Version is not specified' 'usage: dctlenv install [<version>]'
|
||||||
|
|
||||||
|
version_requested=$(echo $version_requested | sed 's/^v//')
|
||||||
|
|
||||||
if [[ $version_requested == "latest" ]]; then
|
if [[ $version_requested == "latest" ]]; then
|
||||||
version="$(dctlenv-list-remote | tail -n 1)"
|
version="$(dctlenv-list-remote | tail -n 1)"
|
||||||
else
|
else
|
||||||
|
|
|
@ -6,6 +6,8 @@ set -uo pipefail
|
||||||
version_requested="${1:-""}"
|
version_requested="${1:-""}"
|
||||||
[ -n "$version_requested" ] || log_error 'Version is not specified' 'usage: dctlenv uninstall [<version>]'
|
[ -n "$version_requested" ] || log_error 'Version is not specified' 'usage: dctlenv uninstall [<version>]'
|
||||||
|
|
||||||
|
version_requested=$(echo $version_requested | sed 's/^v//')
|
||||||
|
|
||||||
version="$(dctlenv-list 2>/dev/null | sed -E 's/^(\*| )? //g; s/ \(set by .+\)$//' | grep -e "$version_requested" | head -n 1)"
|
version="$(dctlenv-list 2>/dev/null | sed -E 's/^(\*| )? //g; s/ \(set by .+\)$//' | grep -e "$version_requested" | head -n 1)"
|
||||||
[ -n "$version" ] || log_error "No versions matching '$version_requested' found in local"
|
[ -n "$version" ] || log_error "No versions matching '$version_requested' found in local"
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,8 @@ set -uo pipefail
|
||||||
version_requested="${1:-""}"
|
version_requested="${1:-""}"
|
||||||
[ -n "$version_requested" ] || log_error 'Version is not specified' 'usage: dctlenv use [<version>]'
|
[ -n "$version_requested" ] || log_error 'Version is not specified' 'usage: dctlenv use [<version>]'
|
||||||
|
|
||||||
|
version_requested=$(echo $version_requested | sed 's/^v//')
|
||||||
|
|
||||||
if [[ $version_requested == "latest" ]]; then
|
if [[ $version_requested == "latest" ]]; then
|
||||||
version_requested="$(dctlenv-list-remote | tail -n 1)"
|
version_requested="$(dctlenv-list-remote | tail -n 1)"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -148,6 +148,27 @@ Installation of driftctl v0.3.1 successful. To make this your default version, r
|
||||||
OUT
|
OUT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "dctlenv install [<version>]: prints a success message if it can install v0.3.1" {
|
||||||
|
uname() { echo "Linux"; }; export -f uname;
|
||||||
|
curlw() {
|
||||||
|
mkdir -p "$DCTLENV_TMPDIR/versions/0.3.1"
|
||||||
|
touch "$DCTLENV_TMPDIR/versions/0.3.1/driftctl_linux_amd64"
|
||||||
|
(cd "$DCTLENV_TMPDIR/versions/0.3.1"; sha256sum * > "$DCTLENV_TMPDIR/versions/0.3.1/driftctl_SHA256SUMS")
|
||||||
|
exit 0
|
||||||
|
}; export -f curlw;
|
||||||
|
|
||||||
|
run dctlenv install v0.3.1
|
||||||
|
|
||||||
|
assert_success
|
||||||
|
assert_output <<OUT
|
||||||
|
Installing driftctl v0.3.1
|
||||||
|
Downloading release tarball from https://github.com/cloudskiff/driftctl/releases/download/v0.3.1/driftctl_linux_amd64
|
||||||
|
Downloading SHA256 hashes file from https://github.com/cloudskiff/driftctl/releases/download/v0.3.1/driftctl_SHA256SUMS
|
||||||
|
SHA256 hash matched!
|
||||||
|
Installation of driftctl v0.3.1 successful. To make this your default version, run 'dctlenv use 0.3.1'
|
||||||
|
OUT
|
||||||
|
}
|
||||||
|
|
||||||
@test "dctlenv install [<version>]: prints a success message if it can install the latest version" {
|
@test "dctlenv install [<version>]: prints a success message if it can install the latest version" {
|
||||||
uname() { echo "Linux"; }; export -f uname;
|
uname() { echo "Linux"; }; export -f uname;
|
||||||
curlw() {
|
curlw() {
|
||||||
|
|
|
@ -55,6 +55,22 @@ driftctl v0.3.1 is successfully uninstalled
|
||||||
OUT
|
OUT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "dctlenv uninstall [<version>]: prints a success message if it can uninstall v0.3.1" {
|
||||||
|
mkdir -p "$DCTLENV_TMPDIR/versions/0.3.1"
|
||||||
|
mkdir -p "$DCTLENV_TMPDIR/versions/0.3.0"
|
||||||
|
mkdir -p "$DCTLENV_TMPDIR/versions/0.2.3"
|
||||||
|
touch "$DCTLENV_TMPDIR/versions/0.3.1/driftctl"
|
||||||
|
|
||||||
|
run dctlenv uninstall v0.3.1
|
||||||
|
|
||||||
|
assert_success
|
||||||
|
assert_output <<OUT
|
||||||
|
Uninstall driftctl v0.3.1
|
||||||
|
driftctl v0.3.1 is successfully uninstalled
|
||||||
|
OUT
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
teardown() {
|
teardown() {
|
||||||
rm -rf "$DCTLENV_TMPDIR"
|
rm -rf "$DCTLENV_TMPDIR"
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,22 @@ Switching completed
|
||||||
OUT
|
OUT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "dctlenv use [<version>]: prints a success message when switching versions v0.3.1" {
|
||||||
|
mkdir -p "$DCTLENV_TMPDIR/versions/0.3.1"
|
||||||
|
touch "$DCTLENV_TMPDIR/versions/0.3.1/driftctl"
|
||||||
|
chmod +x $DCTLENV_TMPDIR/versions/0.3.1/driftctl
|
||||||
|
|
||||||
|
driftctl() { exit 0; }; export -f driftctl;
|
||||||
|
|
||||||
|
run dctlenv use v0.3.1
|
||||||
|
|
||||||
|
assert_success
|
||||||
|
assert_output <<OUT
|
||||||
|
Switching version to v0.3.1
|
||||||
|
Switching completed
|
||||||
|
OUT
|
||||||
|
}
|
||||||
|
|
||||||
@test "dctlenv use [<version>]: prints a success message if we successfuly install and use a non-installed version" {
|
@test "dctlenv use [<version>]: prints a success message if we successfuly install and use a non-installed version" {
|
||||||
mkdir -p "$DCTLENV_TMPDIR/versions/0.3.1"
|
mkdir -p "$DCTLENV_TMPDIR/versions/0.3.1"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue