mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Update docs re: godep
This commit is contained in:
parent
b4f5108d39
commit
0114eef83d
@ -166,9 +166,9 @@ See [Faster Reviews](faster_reviews.md) for more details.
|
|||||||
|
|
||||||
Kubernetes uses [godep](https://github.com/tools/godep) to manage dependencies.
|
Kubernetes uses [godep](https://github.com/tools/godep) to manage dependencies.
|
||||||
It is not strictly required for building Kubernetes but it is required when
|
It is not strictly required for building Kubernetes but it is required when
|
||||||
managing dependencies under the Godeps/ tree, and is required by a number of the
|
managing dependencies under the vendor/ tree, and is required by a number of the
|
||||||
build and test scripts. Please make sure that ``godep`` is installed and in your
|
build and test scripts. Please make sure that `godep` is installed and in your
|
||||||
``$PATH``.
|
`$PATH`, and that `godep version` says it is at least v63.
|
||||||
|
|
||||||
### Installing godep
|
### Installing godep
|
||||||
|
|
||||||
@ -186,16 +186,29 @@ from mercurial.
|
|||||||
```sh
|
```sh
|
||||||
export GOPATH=$HOME/go-tools
|
export GOPATH=$HOME/go-tools
|
||||||
mkdir -p $GOPATH
|
mkdir -p $GOPATH
|
||||||
go get github.com/tools/godep
|
go get -u github.com/tools/godep
|
||||||
```
|
```
|
||||||
|
|
||||||
3) Add $GOPATH/bin to your path. Typically you'd add this to your ~/.profile:
|
3) Add this $GOPATH/bin to your path. Typically you'd add this to your ~/.profile:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
export GOPATH=$HOME/go-tools
|
export GOPATH=$HOME/go-tools
|
||||||
export PATH=$PATH:$GOPATH/bin
|
export PATH=$PATH:$GOPATH/bin
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note:
|
||||||
|
At this time, godep version >= v63 is known to work in the Kubernetes project
|
||||||
|
|
||||||
|
To check your version of godep:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ godep version
|
||||||
|
godep v66 (linux/amd64/go1.6.2)
|
||||||
|
```
|
||||||
|
|
||||||
|
If it is not a valid version try, make sure you have updated the godep repo
|
||||||
|
with `go get -u github.com/tools/godep`.
|
||||||
|
|
||||||
### Using godep
|
### Using godep
|
||||||
|
|
||||||
Here's a quick walkthrough of one way to use godeps to add or update a
|
Here's a quick walkthrough of one way to use godeps to add or update a
|
||||||
@ -204,8 +217,8 @@ instructions in [godep's documentation](https://github.com/tools/godep).
|
|||||||
|
|
||||||
1) Devote a directory to this endeavor:
|
1) Devote a directory to this endeavor:
|
||||||
|
|
||||||
_Devoting a separate directory is not required, but it is helpful to separate
|
_Devoting a separate directory is not strictly required, but it is helpful to
|
||||||
dependency updates from other changes._
|
separate dependency updates from other changes._
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
export KPATH=$HOME/code/kubernetes
|
export KPATH=$HOME/code/kubernetes
|
||||||
@ -218,11 +231,8 @@ git clone https://path/to/your/fork .
|
|||||||
2) Set up your GOPATH.
|
2) Set up your GOPATH.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# Option A: this will let your builds see packages that exist elsewhere on your system.
|
# This will *not* let your local builds see packages that exist elsewhere on your system.
|
||||||
export GOPATH=$KPATH:$GOPATH
|
|
||||||
# Option B: This will *not* let your local builds see packages that exist elsewhere on your system.
|
|
||||||
export GOPATH=$KPATH
|
export GOPATH=$KPATH
|
||||||
# Option B is recommended if you're going to mess with the dependencies.
|
|
||||||
```
|
```
|
||||||
|
|
||||||
3) Populate your new GOPATH.
|
3) Populate your new GOPATH.
|
||||||
@ -237,32 +247,34 @@ godep restore
|
|||||||
```sh
|
```sh
|
||||||
# To add a new dependency, do:
|
# To add a new dependency, do:
|
||||||
cd $KPATH/src/k8s.io/kubernetes
|
cd $KPATH/src/k8s.io/kubernetes
|
||||||
go get path/to/dependency
|
godep get path/to/dependency
|
||||||
# Change code in Kubernetes to use the dependency.
|
# Now change code in Kubernetes to use the dependency.
|
||||||
godep save ./...
|
hack/godep-save.sh
|
||||||
|
|
||||||
|
|
||||||
# To update an existing dependency, do:
|
# To update an existing dependency, do:
|
||||||
cd $KPATH/src/k8s.io/kubernetes
|
cd $KPATH/src/k8s.io/kubernetes
|
||||||
go get -u path/to/dependency
|
go get -u path/to/dependency
|
||||||
# Change code in Kubernetes accordingly if necessary.
|
# Change code in Kubernetes accordingly if necessary.
|
||||||
godep update path/to/dependency/...
|
godep update path/to/dependency
|
||||||
```
|
```
|
||||||
|
|
||||||
_If `go get -u path/to/dependency` fails with compilation errors, instead try
|
_If `go get -u path/to/dependency` fails with compilation errors, instead try
|
||||||
`go get -d -u path/to/dependency` to fetch the dependencies without compiling
|
`go get -d -u path/to/dependency` to fetch the dependencies without compiling
|
||||||
them. This can happen when updating the cadvisor dependency._
|
them. This is unusual, but has been observed._
|
||||||
|
|
||||||
|
|
||||||
5) Before sending your PR, it's a good idea to sanity check that your
|
5) Before sending your PR, it's a good idea to sanity check that your
|
||||||
Godeps.json file is ok by running `hack/verify-godeps.sh`
|
Godeps.json file and the contents of `vendor/ `are ok by running `hack/verify-godeps.sh`
|
||||||
|
|
||||||
_If hack/verify-godeps.sh fails after a `godep update`, it is possible that a
|
_If `hack/verify-godeps.sh` fails after a `godep update`, it is possible that a
|
||||||
transitive dependency was added or removed but not updated by godeps. It then
|
transitive dependency was added or removed but not updated by godeps. It then
|
||||||
may be necessary to perform a `godep save ./...` to pick up the transitive
|
may be necessary to perform a `hack/godep-save.sh` to pick up the transitive
|
||||||
dependency changes._
|
dependency changes._
|
||||||
|
|
||||||
It is sometimes expedient to manually fix the /Godeps/godeps.json file to
|
It is sometimes expedient to manually fix the /Godeps/Godeps.json file to
|
||||||
minimize the changes.
|
minimize the changes. However without great care this can lead to failures
|
||||||
|
with `hack/verify-godeps.sh`. This must pass for every PR.
|
||||||
|
|
||||||
Please send dependency updates in separate commits within your PR, for easier
|
Please send dependency updates in separate commits within your PR, for easier
|
||||||
reviewing.
|
reviewing.
|
||||||
|
Loading…
Reference in New Issue
Block a user