Skip to content

Commit

Permalink
Update docs for Kubernetes go modules upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
feiskyer committed Sep 9, 2019
1 parent f1bc6bf commit 9844afe
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion docs/dependency-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,29 @@ To upgrade to the latest version for all direct and indirect dependencies of the
* run `go get -u=patch <package>` to use the latest patch releases
* run `go get <pacakge>@VERSION` to use the specified version

You can also manually editing `go.mod`.
You can also manually editing `go.mod` and update the versions in `require` and `replace` parts.

Because of staging in Kubernetes, manually `go.mod` updating is required for Kubernetes and
its staging packages. In cloud-provider-azure, their versions are set in `replace` part, e.g.

```go
replace (
...
k8s.io/kubernetes => k8s.io/kubernetes v0.0.0-20190815230911-4e7fd98763aa
k8s.io/legacy-cloud-providers => k8s.io/kubernetes/staging/src/k8s.io/legacy-cloud-providers v0.0.0-20190815230911-4e7fd98763aa
)
```

To update their versions, you need switch to `$GOPATH/src/k8s.io/kubernetes`, checkout to
the version you want upgrade to, and finally run the following commands to get the go modules expected version:

```sh
commit=$(git log --date=format:'%Y%m%d%H%M%S' -1 | head -n 1 | awk '{print $2}' | cut -c1-12)
date=$(git log --date=format:'%Y%m%d%H%M%S' -1 | awk '/Date:/{print $2}')
echo "v0.0.0-$date-$commit"
```

After this, replace all kubernetes and staging versions (e.g. `v0.0.0-20190815230911-4e7fd98763aa` in above example) in `go.mod`.

Always run `hack/update-dependencies.sh` after changing `go.mod` by any of these methods (or adding new imports).

Expand Down

0 comments on commit 9844afe

Please sign in to comment.