mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 10:20:51 +00:00
Get rid of most references to GOPATH
This commit is contained in:
parent
3c2940f2ae
commit
10c32b3e2f
@ -43,8 +43,6 @@ If you want to build Kubernetes right away there are two options:
|
||||
##### You have a working [Go environment].
|
||||
|
||||
```
|
||||
mkdir -p $GOPATH/src/k8s.io
|
||||
cd $GOPATH/src/k8s.io
|
||||
git clone https://github.com/kubernetes/kubernetes
|
||||
cd kubernetes
|
||||
make
|
||||
|
@ -147,7 +147,6 @@ def file_extension(filename):
|
||||
|
||||
skipped_names = [
|
||||
"third_party",
|
||||
"_gopath",
|
||||
"_output",
|
||||
".git",
|
||||
"cluster/env.sh",
|
||||
|
@ -39,7 +39,6 @@ kube::test::find_dirs() {
|
||||
\( \
|
||||
-path './_artifacts/*' \
|
||||
-o -path './_output/*' \
|
||||
-o -path './_gopath/*' \
|
||||
-o -path './cmd/kubeadm/test/*' \
|
||||
-o -path './contrib/podex/*' \
|
||||
-o -path './release/*' \
|
||||
|
@ -31,7 +31,6 @@ find_files() {
|
||||
-wholename './output' \
|
||||
-o -wholename './.git' \
|
||||
-o -wholename './_output' \
|
||||
-o -wholename './_gopath' \
|
||||
-o -wholename './release' \
|
||||
-o -wholename './target' \
|
||||
-o -wholename '*/vendor/*' \
|
||||
|
@ -40,7 +40,6 @@ find_files() {
|
||||
\( \
|
||||
-wholename './output' \
|
||||
-o -wholename './_output' \
|
||||
-o -wholename './_gopath' \
|
||||
-o -wholename './release' \
|
||||
-o -wholename './target' \
|
||||
-o -wholename '*/third_party/*' \
|
||||
|
@ -40,7 +40,6 @@ find_files() {
|
||||
\( \
|
||||
-wholename './output' \
|
||||
-o -wholename './_output' \
|
||||
-o -wholename './_gopath' \
|
||||
-o -wholename './release' \
|
||||
-o -wholename './target' \
|
||||
-o -wholename '*/third_party/*' \
|
||||
|
@ -54,8 +54,6 @@ def get_all_files(rootdir):
|
||||
dirs.remove('staging')
|
||||
if '_output' in dirs:
|
||||
dirs.remove('_output')
|
||||
if '_gopath' in dirs:
|
||||
dirs.remove('_gopath')
|
||||
if 'third_party' in dirs:
|
||||
dirs.remove('third_party')
|
||||
if '.git' in dirs:
|
||||
|
@ -38,7 +38,6 @@ find_files() {
|
||||
-wholename './output' \
|
||||
-o -wholename './.git' \
|
||||
-o -wholename './_output' \
|
||||
-o -wholename './_gopath' \
|
||||
-o -wholename './release' \
|
||||
-o -wholename './target' \
|
||||
-o -wholename '*/third_party/*' \
|
||||
|
@ -37,7 +37,6 @@ find_files() {
|
||||
-wholename './output' \
|
||||
-o -wholename './.git' \
|
||||
-o -wholename './_output' \
|
||||
-o -wholename './_gopath' \
|
||||
-o -wholename './release' \
|
||||
-o -wholename './target' \
|
||||
-o -wholename '*/third_party/*' \
|
||||
|
@ -33,7 +33,6 @@ find_files() {
|
||||
\( \
|
||||
-wholename './output' \
|
||||
-o -wholename './_output' \
|
||||
-o -wholename './_gopath' \
|
||||
-o -wholename './release' \
|
||||
-o -wholename './target' \
|
||||
-o -wholename '*/third_party/*' \
|
||||
|
@ -79,14 +79,8 @@ go get k8s.io/client-go@v0.20.4
|
||||
### Go modules disabled
|
||||
|
||||
If you get a message like `cannot use path@version syntax in GOPATH mode`,
|
||||
you likely do not have go modules enabled.
|
||||
|
||||
Dependency management tools are built into go 1.11+ in the form of
|
||||
[go modules](https://github.com/golang/go/wiki/Modules).
|
||||
These are used by the main Kubernetes repo (>= `v1.15.0`) and
|
||||
`client-go` (>= `kubernetes-1.15.0`) to manage dependencies.
|
||||
If you are using go 1.11 or 1.12 and are working with a project located within `$GOPATH`,
|
||||
you must opt into using go modules:
|
||||
you likely do not have go modules enabled. This should be on by default in all
|
||||
supported versions of Go.
|
||||
|
||||
```sh
|
||||
export GO111MODULE=on
|
||||
|
@ -18,7 +18,6 @@ package fake
|
||||
|
||||
import (
|
||||
"io"
|
||||
gopath "path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
@ -153,7 +152,7 @@ func (g *genFakeForType) GenerateType(c *generator.Context, t *types.Type, w io.
|
||||
if generateApply {
|
||||
// Generated apply builder type references required for generated Apply function
|
||||
_, gvString := util.ParsePathGroupVersion(g.inputPackage)
|
||||
m["inputApplyConfig"] = types.Ref(gopath.Join(g.applyConfigurationPackage, gvString), t.Name.Name+"ApplyConfiguration")
|
||||
m["inputApplyConfig"] = types.Ref(filepath.Join(g.applyConfigurationPackage, gvString), t.Name.Name+"ApplyConfiguration")
|
||||
}
|
||||
|
||||
if tags.NonNamespaced {
|
||||
@ -237,7 +236,7 @@ func (g *genFakeForType) GenerateType(c *generator.Context, t *types.Type, w io.
|
||||
m["resultType"] = &resultType
|
||||
m["subresourcePath"] = e.SubResourcePath
|
||||
if e.HasVerb("apply") {
|
||||
m["inputApplyConfig"] = types.Ref(gopath.Join(g.applyConfigurationPackage, inputGVString), inputType.Name.Name+"ApplyConfiguration")
|
||||
m["inputApplyConfig"] = types.Ref(filepath.Join(g.applyConfigurationPackage, inputGVString), inputType.Name.Name+"ApplyConfiguration")
|
||||
}
|
||||
|
||||
if e.HasVerb("get") {
|
||||
|
@ -26,28 +26,11 @@ Code changes are made in that location, merged into `k8s.io/kubernetes` and late
|
||||
|
||||
## Fetch sample-apiserver and its dependencies
|
||||
|
||||
Like the rest of Kubernetes, sample-apiserver has used
|
||||
[godep](https://github.com/tools/godep) and `$GOPATH` for years and is
|
||||
now adopting go 1.11 modules. There are thus two alternative ways to
|
||||
go about fetching this demo and its dependencies.
|
||||
|
||||
### Fetch with godep
|
||||
|
||||
When NOT using go 1.11 modules, you can use the following commands.
|
||||
Issue the following commands --- starting in whatever working directory you
|
||||
like.
|
||||
|
||||
```sh
|
||||
go get -d k8s.io/sample-apiserver
|
||||
cd $GOPATH/src/k8s.io/sample-apiserver # assuming your GOPATH has just one entry
|
||||
godep restore
|
||||
```
|
||||
|
||||
### When using go 1.11 modules
|
||||
|
||||
When using go 1.11 modules (`GO111MODULE=on`), issue the following
|
||||
commands --- starting in whatever working directory you like.
|
||||
|
||||
```sh
|
||||
git clone https://github.com/kubernetes/sample-apiserver.git
|
||||
git clone https://github.com/kubernetes/sample-apiserver
|
||||
cd sample-apiserver
|
||||
```
|
||||
|
||||
|
@ -33,28 +33,11 @@ explained [here](docs/controller-client-go.md).
|
||||
|
||||
## Fetch sample-controller and its dependencies
|
||||
|
||||
Like the rest of Kubernetes, sample-controller has used
|
||||
[godep](https://github.com/tools/godep) and `$GOPATH` for years and is
|
||||
now adopting go 1.11 modules. There are thus two alternative ways to
|
||||
go about fetching this demo and its dependencies.
|
||||
|
||||
### Fetch with godep
|
||||
|
||||
When NOT using go 1.11 modules, you can use the following commands.
|
||||
Issue the following commands --- starting in whatever working directory you
|
||||
like.
|
||||
|
||||
```sh
|
||||
go get -d k8s.io/sample-controller
|
||||
cd $GOPATH/src/k8s.io/sample-controller
|
||||
godep restore
|
||||
```
|
||||
|
||||
### When using go 1.11 modules
|
||||
|
||||
When using go 1.11 modules (`GO111MODULE=on`), issue the following
|
||||
commands --- starting in whatever working directory you like.
|
||||
|
||||
```sh
|
||||
git clone https://github.com/kubernetes/sample-controller.git
|
||||
git clone https://github.com/kubernetes/sample-controller
|
||||
cd sample-controller
|
||||
```
|
||||
|
||||
|
@ -583,20 +583,22 @@ func TestRBAC(t *testing.T) {
|
||||
previousResourceVersion := make(map[string]float64)
|
||||
|
||||
for j, r := range tc.requests {
|
||||
path := "/"
|
||||
// This is a URL-path, not a local path, so we use the "path"
|
||||
// package (aliased as "gopath") instead of "path/filepath".
|
||||
urlPath := "/"
|
||||
if r.apiGroup == "" {
|
||||
path = gopath.Join(path, "api/v1")
|
||||
urlPath = gopath.Join(urlPath, "api/v1")
|
||||
} else {
|
||||
path = gopath.Join(path, "apis", r.apiGroup, "v1")
|
||||
urlPath = gopath.Join(urlPath, "apis", r.apiGroup, "v1")
|
||||
}
|
||||
if r.namespace != "" {
|
||||
path = gopath.Join(path, "namespaces", r.namespace)
|
||||
urlPath = gopath.Join(urlPath, "namespaces", r.namespace)
|
||||
}
|
||||
if r.resource != "" {
|
||||
path = gopath.Join(path, r.resource)
|
||||
urlPath = gopath.Join(urlPath, r.resource)
|
||||
}
|
||||
if r.name != "" {
|
||||
path = gopath.Join(path, r.name)
|
||||
urlPath = gopath.Join(urlPath, r.name)
|
||||
}
|
||||
|
||||
var body io.Reader
|
||||
@ -604,14 +606,14 @@ func TestRBAC(t *testing.T) {
|
||||
sub := ""
|
||||
if r.verb == "PUT" {
|
||||
// For update operations, insert previous resource version
|
||||
if resVersion := previousResourceVersion[getPreviousResourceVersionKey(path, "")]; resVersion != 0 {
|
||||
if resVersion := previousResourceVersion[getPreviousResourceVersionKey(urlPath, "")]; resVersion != 0 {
|
||||
sub += fmt.Sprintf(",\"resourceVersion\": \"%v\"", resVersion)
|
||||
}
|
||||
}
|
||||
body = strings.NewReader(fmt.Sprintf(r.body, sub))
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(r.verb, kubeConfig.Host+path, body)
|
||||
req, err := http.NewRequest(r.verb, kubeConfig.Host+urlPath, body)
|
||||
if r.verb == "PATCH" {
|
||||
// For patch operations, use the apply content type
|
||||
req.Header.Add("Content-Type", string(types.ApplyPatchType))
|
||||
@ -662,7 +664,7 @@ func TestRBAC(t *testing.T) {
|
||||
// For successful create operations, extract resourceVersion
|
||||
id, currentResourceVersion, err := parseResourceVersion(b)
|
||||
if err == nil {
|
||||
key := getPreviousResourceVersionKey(path, id)
|
||||
key := getPreviousResourceVersionKey(urlPath, id)
|
||||
previousResourceVersion[key] = currentResourceVersion
|
||||
} else {
|
||||
t.Logf("error in trying to extract resource version: %s", err)
|
||||
|
Loading…
Reference in New Issue
Block a user