From 10c32b3e2f4345dab582270b1a202dcd92dabd34 Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Wed, 3 Jan 2024 17:14:38 -0800 Subject: [PATCH] Get rid of most references to GOPATH --- README.md | 2 -- hack/boilerplate/boilerplate.py | 1 - hack/make-rules/test.sh | 1 - hack/update-yamlfmt.sh | 1 - hack/verify-description.sh | 1 - hack/verify-fieldname-docs.sh | 1 - hack/verify-flags-underscore.py | 2 -- hack/verify-gofmt.sh | 1 - hack/verify-netparse-cve.sh | 1 - hack/verify-readonly-packages.sh | 1 - staging/src/k8s.io/client-go/INSTALL.md | 10 ++------ .../fake/generator_fake_for_type.go | 5 ++-- staging/src/k8s.io/sample-apiserver/README.md | 23 +++---------------- .../src/k8s.io/sample-controller/README.md | 23 +++---------------- test/integration/auth/rbac_test.go | 20 ++++++++-------- 15 files changed, 21 insertions(+), 72 deletions(-) diff --git a/README.md b/README.md index a171572b5a60d..5cc460c15bf1e 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/hack/boilerplate/boilerplate.py b/hack/boilerplate/boilerplate.py index 04009e979eb08..65eb08b00ecbc 100755 --- a/hack/boilerplate/boilerplate.py +++ b/hack/boilerplate/boilerplate.py @@ -147,7 +147,6 @@ def file_extension(filename): skipped_names = [ "third_party", - "_gopath", "_output", ".git", "cluster/env.sh", diff --git a/hack/make-rules/test.sh b/hack/make-rules/test.sh index a5c626a013153..bd16994db253b 100755 --- a/hack/make-rules/test.sh +++ b/hack/make-rules/test.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/*' \ diff --git a/hack/update-yamlfmt.sh b/hack/update-yamlfmt.sh index ca784eb3997dd..1f6622a5bd1f0 100755 --- a/hack/update-yamlfmt.sh +++ b/hack/update-yamlfmt.sh @@ -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/*' \ diff --git a/hack/verify-description.sh b/hack/verify-description.sh index 95db1a3d49ac5..832806a5cb4d0 100755 --- a/hack/verify-description.sh +++ b/hack/verify-description.sh @@ -40,7 +40,6 @@ find_files() { \( \ -wholename './output' \ -o -wholename './_output' \ - -o -wholename './_gopath' \ -o -wholename './release' \ -o -wholename './target' \ -o -wholename '*/third_party/*' \ diff --git a/hack/verify-fieldname-docs.sh b/hack/verify-fieldname-docs.sh index 2997234cf65d4..3978b40377327 100755 --- a/hack/verify-fieldname-docs.sh +++ b/hack/verify-fieldname-docs.sh @@ -40,7 +40,6 @@ find_files() { \( \ -wholename './output' \ -o -wholename './_output' \ - -o -wholename './_gopath' \ -o -wholename './release' \ -o -wholename './target' \ -o -wholename '*/third_party/*' \ diff --git a/hack/verify-flags-underscore.py b/hack/verify-flags-underscore.py index 7d620a09424d7..fd8181d723fe2 100755 --- a/hack/verify-flags-underscore.py +++ b/hack/verify-flags-underscore.py @@ -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: diff --git a/hack/verify-gofmt.sh b/hack/verify-gofmt.sh index 4e2fc06a38997..9219d0a221b8f 100755 --- a/hack/verify-gofmt.sh +++ b/hack/verify-gofmt.sh @@ -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/*' \ diff --git a/hack/verify-netparse-cve.sh b/hack/verify-netparse-cve.sh index f052a3d6fc7ce..323eb9e46d89b 100755 --- a/hack/verify-netparse-cve.sh +++ b/hack/verify-netparse-cve.sh @@ -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/*' \ diff --git a/hack/verify-readonly-packages.sh b/hack/verify-readonly-packages.sh index 86fe04094c7e3..e0bf6ce3c08b7 100755 --- a/hack/verify-readonly-packages.sh +++ b/hack/verify-readonly-packages.sh @@ -33,7 +33,6 @@ find_files() { \( \ -wholename './output' \ -o -wholename './_output' \ - -o -wholename './_gopath' \ -o -wholename './release' \ -o -wholename './target' \ -o -wholename '*/third_party/*' \ diff --git a/staging/src/k8s.io/client-go/INSTALL.md b/staging/src/k8s.io/client-go/INSTALL.md index 21e15357e6048..cc4afa4195456 100644 --- a/staging/src/k8s.io/client-go/INSTALL.md +++ b/staging/src/k8s.io/client-go/INSTALL.md @@ -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 diff --git a/staging/src/k8s.io/code-generator/cmd/client-gen/generators/fake/generator_fake_for_type.go b/staging/src/k8s.io/code-generator/cmd/client-gen/generators/fake/generator_fake_for_type.go index a9b6af1c4e37b..18ea159546037 100644 --- a/staging/src/k8s.io/code-generator/cmd/client-gen/generators/fake/generator_fake_for_type.go +++ b/staging/src/k8s.io/code-generator/cmd/client-gen/generators/fake/generator_fake_for_type.go @@ -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") { diff --git a/staging/src/k8s.io/sample-apiserver/README.md b/staging/src/k8s.io/sample-apiserver/README.md index bbf66b4fa2628..db8f6c682a418 100644 --- a/staging/src/k8s.io/sample-apiserver/README.md +++ b/staging/src/k8s.io/sample-apiserver/README.md @@ -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. - -```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. +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 ``` diff --git a/staging/src/k8s.io/sample-controller/README.md b/staging/src/k8s.io/sample-controller/README.md index 3b73b33a8b3ea..7b743c511e09f 100644 --- a/staging/src/k8s.io/sample-controller/README.md +++ b/staging/src/k8s.io/sample-controller/README.md @@ -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. - -```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. +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 ``` diff --git a/test/integration/auth/rbac_test.go b/test/integration/auth/rbac_test.go index bbe0d0d5a6d57..1d857c442e608 100644 --- a/test/integration/auth/rbac_test.go +++ b/test/integration/auth/rbac_test.go @@ -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)