mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
commit
6e656e4da7
38
README.md
38
README.md
@ -62,20 +62,29 @@ The commands above will not work if there are more than one directory in ``$GOPA
|
|||||||
|
|
||||||
### godep and dependency management
|
### godep and dependency management
|
||||||
|
|
||||||
Kubernetes uses [godep](https://github.com/tools/godep) to manage dependencies. Please make sure that *godep* is installed and in your PATH. If you have already set up Go development environment correctly, the following command will install *godep* into your ``GOBIN`` directory, which is ``$GOPATH/bin`` if ``GOBIN`` is not set:
|
Kubernetes uses [godep](https://github.com/tools/godep) to manage dependencies. Please make sure that ``godep`` is installed and in your ``$PATH``. If you have already set up Go development environment correctly, the following command will install ``godep`` into your ``$GOBIN`` directory, which is ``$GOPATH/bin`` by default if ``$GOBIN`` is not set:
|
||||||
|
|
||||||
```
|
```
|
||||||
go get github.com/tools/godep
|
go get github.com/tools/godep
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Here is a quick summary of `godep`. `godep` helps manage third party dependencies by copying known versions into Godep/_workspace. You can use `godep` in three ways:
|
||||||
|
|
||||||
|
1. Use `godep` to call your `go` commands. For example: `godep go test ./...`
|
||||||
|
2. Use `godep` to modify your `$GOPATH` so that other tools know where to find the dependencies. Specifically: `export GOPATH=$GOPATH:$(godep path)`
|
||||||
|
3. Use `godep` to copy the saved versions of packages into your `$GOPATH`. This is done with `godep restore`.
|
||||||
|
|
||||||
|
We recommend using options #1 or #2.
|
||||||
|
|
||||||
### Hooks
|
### Hooks
|
||||||
|
|
||||||
|
Before committing any changes, please link/copy these hooks into your .git
|
||||||
|
directory. This will keep you from accidentally committing non-gofmt'd go code.
|
||||||
|
|
||||||
|
**NOTE:** The `../..` part seems odd but is correct, since the newly created
|
||||||
|
links will be 2 levels down the tree.
|
||||||
|
|
||||||
```
|
```
|
||||||
# Before committing any changes, please link/copy these hooks into your .git
|
|
||||||
# directory. This will keep you from accidentally committing non-gofmt'd
|
|
||||||
# go code.
|
|
||||||
#
|
|
||||||
# NOTE: The "../.." part seems odd but is correct, since the newly created
|
|
||||||
# links will be 2 levels down the tree.
|
|
||||||
cd kubernetes
|
cd kubernetes
|
||||||
ln -s ../../hooks/prepare-commit-msg .git/hooks/prepare-commit-msg
|
ln -s ../../hooks/prepare-commit-msg .git/hooks/prepare-commit-msg
|
||||||
ln -s ../../hooks/commit-msg .git/hooks/commit-msg
|
ln -s ../../hooks/commit-msg .git/hooks/commit-msg
|
||||||
@ -109,13 +118,14 @@ ok github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet 0.317s
|
|||||||
### Coverage
|
### Coverage
|
||||||
```
|
```
|
||||||
cd kubernetes
|
cd kubernetes
|
||||||
go tool cover -html=target/c.out
|
godep go tool cover -html=target/c.out
|
||||||
```
|
```
|
||||||
|
|
||||||
### Integration tests
|
### Integration tests
|
||||||
|
|
||||||
|
You need an etcd somewhere in your path. To get from head:
|
||||||
|
|
||||||
```
|
```
|
||||||
# You need an etcd somewhere in your path.
|
|
||||||
# To get from head:
|
|
||||||
go get github.com/coreos/etcd
|
go get github.com/coreos/etcd
|
||||||
go install github.com/coreos/etcd
|
go install github.com/coreos/etcd
|
||||||
sudo ln -s "$GOPATH/bin/etcd" /usr/bin/etcd
|
sudo ln -s "$GOPATH/bin/etcd" /usr/bin/etcd
|
||||||
@ -129,7 +139,9 @@ hack/integration-test.sh
|
|||||||
```
|
```
|
||||||
|
|
||||||
### End-to-End tests
|
### End-to-End tests
|
||||||
|
|
||||||
With a GCE account set up for running `cluster/kube-up.sh` (see Setup above):
|
With a GCE account set up for running `cluster/kube-up.sh` (see Setup above):
|
||||||
|
|
||||||
```
|
```
|
||||||
cd kubernetes
|
cd kubernetes
|
||||||
hack/e2e-test.sh
|
hack/e2e-test.sh
|
||||||
@ -140,28 +152,34 @@ hack/e2e-test.sh
|
|||||||
Kubernetes uses [godep](https://github.com/tools/godep) to manage dependencies. To add or update a package, please follow the instructions on [godep's document](https://github.com/tools/godep).
|
Kubernetes uses [godep](https://github.com/tools/godep) to manage dependencies. To add or update a package, please follow the instructions on [godep's document](https://github.com/tools/godep).
|
||||||
|
|
||||||
To add a new package ``foo/bar``:
|
To add a new package ``foo/bar``:
|
||||||
|
|
||||||
- Download foo/bar into the first directory in GOPATH: ``go get foo/bar``.
|
- Download foo/bar into the first directory in GOPATH: ``go get foo/bar``.
|
||||||
- Change code in kubernetes to use ``foo/bar``.
|
- Change code in kubernetes to use ``foo/bar``.
|
||||||
- Run ``godep save ./...`` under kubernetes' root directory.
|
- Run ``godep save ./...`` under kubernetes' root directory.
|
||||||
|
|
||||||
To update a package ``foo/bar``:
|
To update a package ``foo/bar``:
|
||||||
|
|
||||||
- Update the package with ``go get -u foo/bar``.
|
- Update the package with ``go get -u foo/bar``.
|
||||||
- Change code in kubernetes accordingly if necessary.
|
- Change code in kubernetes accordingly if necessary.
|
||||||
- Run ``godep update foo/bar``.
|
- Run ``godep update foo/bar``.
|
||||||
|
|
||||||
### Keeping your development fork in sync
|
### Keeping your development fork in sync
|
||||||
|
|
||||||
One time after cloning your forked repo:
|
One time after cloning your forked repo:
|
||||||
|
|
||||||
```
|
```
|
||||||
git remote add upstream https://github.com/GoogleCloudPlatform/kubernetes.git
|
git remote add upstream https://github.com/GoogleCloudPlatform/kubernetes.git
|
||||||
```
|
```
|
||||||
|
|
||||||
Then each time you want to sync to upstream:
|
Then each time you want to sync to upstream:
|
||||||
|
|
||||||
```
|
```
|
||||||
git fetch upstream
|
git fetch upstream
|
||||||
git rebase upstream/master
|
git rebase upstream/master
|
||||||
```
|
```
|
||||||
|
|
||||||
### Regenerating the documentation
|
### Regenerating the documentation
|
||||||
|
|
||||||
```
|
```
|
||||||
cd kubernetes/api
|
cd kubernetes/api
|
||||||
sudo docker build -t kubernetes/raml2html .
|
sudo docker build -t kubernetes/raml2html .
|
||||||
|
@ -45,17 +45,17 @@ RUN cd /usr/local/go/src && \
|
|||||||
|
|
||||||
# Set up Go Environment
|
# Set up Go Environment
|
||||||
ENV PATH /go/bin:$PATH
|
ENV PATH /go/bin:$PATH
|
||||||
ENV GOPATH /go:/go/src/github.com/GoogleCloudPlatform/kubernetes/third_party
|
ENV GOPATH /go
|
||||||
ENV GOOS linux
|
ENV GOOS linux
|
||||||
ENV GOARCH amd64
|
ENV GOARCH amd64
|
||||||
|
|
||||||
# Get the code coverage tool and etcd for integration tests
|
# Get the code coverage tool and etcd for integration tests
|
||||||
RUN go get code.google.com/p/go.tools/cmd/cover github.com/coreos/etcd
|
RUN go get code.google.com/p/go.tools/cmd/cover github.com/coreos/etcd github.com/tools/godep
|
||||||
|
|
||||||
# Mark this as a kube-build container
|
# Mark this as a kube-build container
|
||||||
RUN touch /kube-build-image
|
RUN touch /kube-build-image
|
||||||
|
|
||||||
WORKDIR /go/src/github.com/GoogleCloudPlatform/kubernetes
|
WORKDIR /go/src/github.com/GoogleCloudPlatform/kubernetes
|
||||||
|
|
||||||
# Upload Kubernetes
|
# Upload Kubernetes source
|
||||||
ADD kube-source.tar.gz /go/src/github.com/GoogleCloudPlatform/kubernetes
|
ADD kube-source.tar.gz /go/src/github.com/GoogleCloudPlatform/kubernetes
|
||||||
|
@ -42,7 +42,7 @@ function make-binaries() {
|
|||||||
|
|
||||||
function make-binary() {
|
function make-binary() {
|
||||||
echo "+++ Building $1 for ${GOOS}/${GOARCH}"
|
echo "+++ Building $1 for ${GOOS}/${GOARCH}"
|
||||||
go build \
|
godep go build \
|
||||||
-o "${ARCH_TARGET}/$1" \
|
-o "${ARCH_TARGET}/$1" \
|
||||||
github.com/GoogleCloudPlatform/kubernetes/cmd/$1
|
github.com/GoogleCloudPlatform/kubernetes/cmd/$1
|
||||||
}
|
}
|
||||||
|
@ -19,27 +19,11 @@ set -e
|
|||||||
|
|
||||||
source $(dirname $0)/common.sh
|
source $(dirname $0)/common.sh
|
||||||
|
|
||||||
find_test_dirs() {
|
|
||||||
(
|
|
||||||
cd ${KUBE_REPO_ROOT}
|
|
||||||
find . -not \( \
|
|
||||||
\( \
|
|
||||||
-wholename './third_party' \
|
|
||||||
-o -wholename './output' \
|
|
||||||
\) -prune \
|
|
||||||
\) -name '*_test.go' -print0 | xargs -0n1 dirname | sort -u
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
cd "${KUBE_TARGET}"
|
|
||||||
|
|
||||||
echo "+++ Running unit tests"
|
echo "+++ Running unit tests"
|
||||||
|
|
||||||
if [[ -n "$1" ]]; then
|
if [[ -n "$1" ]]; then
|
||||||
go test -cover -coverprofile=tmp.out "$KUBE_GO_PACKAGE/$1"
|
godep go test -cover -coverprofile=tmp.out "$KUBE_GO_PACKAGE/$1"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for package in $(find_test_dirs); do
|
godep go test ./...
|
||||||
go test -cover -coverprofile=tmp.out "${KUBE_GO_PACKAGE}/${package}"
|
|
||||||
done
|
|
||||||
|
@ -121,10 +121,13 @@ function build-image() {
|
|||||||
api
|
api
|
||||||
build
|
build
|
||||||
cmd
|
cmd
|
||||||
|
examples
|
||||||
|
Godeps
|
||||||
hack
|
hack
|
||||||
|
LICENSE
|
||||||
|
README.md
|
||||||
pkg
|
pkg
|
||||||
third_party
|
third_party
|
||||||
LICENSE
|
|
||||||
"
|
"
|
||||||
mkdir -p ${BUILD_CONTEXT_DIR}
|
mkdir -p ${BUILD_CONTEXT_DIR}
|
||||||
tar czf ${BUILD_CONTEXT_DIR}/kube-source.tar.gz ${SOURCE}
|
tar czf ${BUILD_CONTEXT_DIR}/kube-source.tar.gz ${SOURCE}
|
||||||
@ -194,9 +197,9 @@ function run-build-command() {
|
|||||||
# If the Docker server is remote, copy the results back out.
|
# If the Docker server is remote, copy the results back out.
|
||||||
function copy-output() {
|
function copy-output() {
|
||||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
# When we are on the Mac with boot2docker Now we need to copy the results
|
# When we are on the Mac with boot2docker we need to copy the results back
|
||||||
# back out. Ideally we would leave the container around and use 'docker cp'
|
# out. Ideally we would leave the container around and use 'docker cp' to
|
||||||
# to copy the results out. However, that doesn't work for mounted volumes
|
# copy the results out. However, that doesn't work for mounted volumes
|
||||||
# currently (https://github.com/dotcloud/docker/issues/1992). And it is
|
# currently (https://github.com/dotcloud/docker/issues/1992). And it is
|
||||||
# just plain broken (https://github.com/dotcloud/docker/issues/6483).
|
# just plain broken (https://github.com/dotcloud/docker/issues/6483).
|
||||||
#
|
#
|
||||||
|
@ -25,7 +25,7 @@ fi
|
|||||||
|
|
||||||
if [[ -z "$(which godep)" ]]; then
|
if [[ -z "$(which godep)" ]]; then
|
||||||
echo "Can't find 'godep' in PATH, please fix and retry." >&2
|
echo "Can't find 'godep' in PATH, please fix and retry." >&2
|
||||||
echo "See https://github.com/tools/godep#install for installation instructions." >&2
|
echo "See https://github.com/GoogleCloudPlatform/kubernetes#godep-and-dependency-management" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ mkdir -p "${KUBE_GO_PACKAGE_BASEDIR}"
|
|||||||
# Create symlink under output/go/src.
|
# Create symlink under output/go/src.
|
||||||
ln -snf "${KUBE_REPO_ROOT}" "${KUBE_GO_PACKAGE_DIR}"
|
ln -snf "${KUBE_REPO_ROOT}" "${KUBE_GO_PACKAGE_DIR}"
|
||||||
|
|
||||||
GOPATH="${KUBE_TARGET}:`godep path`"
|
GOPATH="${KUBE_TARGET}:$(godep path)"
|
||||||
export GOPATH
|
export GOPATH
|
||||||
|
|
||||||
# Unset GOBIN in case it already exsits in the current session.
|
# Unset GOBIN in case it already exsits in the current session.
|
||||||
|
Loading…
Reference in New Issue
Block a user