kontena / chpharos

Pharos version switcher
https://get.pharos.sh/
Apache License 2.0
3 stars 4 forks source link

Allow chpharos-exec to install missing versions #37

Closed kke closed 5 years ago

kke commented 5 years ago

chpharos-exec can now automatically install the requested pharos version if not yet installed:

$ chpharos-exec 1.3.2 pharos --help
chpharos-exec: version 1.3.2 is not installed. use chpharos-exec -i PHAROS_VERSION -- COMMAND [ARGS...] to automatically install before running COMMAND

==>

$ chpharos-exec -i 1.3.2 pharos --help
Downloading 'pharos-cluster' (16000792 bytes) from https://get.pharos.sh/versions/download/pharos-cluster-darwin-amd64-1.3.2 ..
######################################################################## 100.0%
Verifying download SHA256 checksum.. OK
Downloading 'kubectl' (54938928 bytes) from https://storage.googleapis.com/kubernetes-release/release/v1.11.3/bin/darwin/amd64/kubectl ..
######################################################################## 100.0%
Verifying download SHA256 checksum.. OK
Installed version 1.3.2. To set as current, use: chpharos use 1.3.2
Usage:
    pharos-cluster [OPTIONS] SUBCOMMAND [ARG] ...

  pharos-cluster - Kontena Pharos cluster manager

Parameters:
...

This is useful in CI/CD pipelines.

The chpharos itself is a shell function and cumbersome to use in CI scripts, you have to do something like bash -c "source /xyz/chpharos.sh; chpharos install 1.3.2 && chpharos use 1.3.2 && pharos up".

Directly downloading the binaries is also cumbersome.

The chpharos-exec is an executable, so you can just do: curl -s https://get.pharos.sh | bash && chpharos-exec -i 1.3.2 pharos up (you need to have CHPHAROS_TOKEN environment variable set)