There doesn't seem to be any benefit to tidying after
getting every dependency pkg. And trying to tidy after
every get seems bugged:
* Some of the k8s.io dependencies depend on each other.
For example k8s.io/client-go depends on k8s.io/api.
* We bump k8s.io/api to a new version, and that version removes
some pkg (e.g. replaces v1alpha1 with v1alpha2), that
some other dependency (e.g. k8s.io/client-go) requires.
* If we try to tidy immediately after getting k8s.io/api, this can
fail because the required new k8s.io/api version doesn't have the
removed pkg that k8s.io/client-go (still at a lower version
since we haven't processed it yet) requires.
Getting all of the dependencies at the new versions first, and then
tidying once afterwards solves this issue.
Previously we would run `go mod vendor` before `go mod tidy`, meaning
that we were snapshotting dependencies before we were really finished
updating them.
Since Cluster Autoscaler versioning should be in sync with Kubernetes,
update-vendor.sh can simply set the version after a successful
dependency update.
Use shell syntax instead of pipe so error messages are printed out. Before
this change, if it could not download a module, it would just exit without
printing an error message due to the pipe. With this change it now prints
out the error message(unable to download) from the underlying process.
The update-vendor.sh script needed some fixes to work with zsh on OSX.
Various binaries are expected to be GNU utils, which are not installed
by default on OSX. I've added suggestions to install ported binaries
using homebrew if they are not found in PATH.
Skip `shopt -s lastpipe` when `$BASH` is not defined.
The `git restore` command was introduced in Git version 2.23.0, which
was released in August 2019. Even late Linux distributions do not
include this modern of a Git binary. For example, Ubuntu 19.10 as of Nov
26, 2019 only includes Git 2.20.1.
In order to run hack/update-vendor.sh on machines with Git <2.23.0, I've
modified the script to use `git reset .` instead of `git restore
--staged`.
Issue #2560
Running this script as-is fails as `git ci` is not a recognised
command. Fixed by referencing `git commit` explicitly; I guess it
works as it may be aliased.