Skip to content

Commit 10c32b3

Browse files
committed
Get rid of most references to GOPATH
1 parent 3c2940f commit 10c32b3

File tree

15 files changed

+21
-72
lines changed

15 files changed

+21
-72
lines changed

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ If you want to build Kubernetes right away there are two options:
4343
##### You have a working [Go environment].
4444

4545
```
46-
mkdir -p $GOPATH/src/k8s.io
47-
cd $GOPATH/src/k8s.io
4846
git clone https://github.com/kubernetes/kubernetes
4947
cd kubernetes
5048
make

hack/boilerplate/boilerplate.py

-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ def file_extension(filename):
147147

148148
skipped_names = [
149149
"third_party",
150-
"_gopath",
151150
"_output",
152151
".git",
153152
"cluster/env.sh",

hack/make-rules/test.sh

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ kube::test::find_dirs() {
3939
\( \
4040
-path './_artifacts/*' \
4141
-o -path './_output/*' \
42-
-o -path './_gopath/*' \
4342
-o -path './cmd/kubeadm/test/*' \
4443
-o -path './contrib/podex/*' \
4544
-o -path './release/*' \

hack/update-yamlfmt.sh

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ find_files() {
3131
-wholename './output' \
3232
-o -wholename './.git' \
3333
-o -wholename './_output' \
34-
-o -wholename './_gopath' \
3534
-o -wholename './release' \
3635
-o -wholename './target' \
3736
-o -wholename '*/vendor/*' \

hack/verify-description.sh

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ find_files() {
4040
\( \
4141
-wholename './output' \
4242
-o -wholename './_output' \
43-
-o -wholename './_gopath' \
4443
-o -wholename './release' \
4544
-o -wholename './target' \
4645
-o -wholename '*/third_party/*' \

hack/verify-fieldname-docs.sh

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ find_files() {
4040
\( \
4141
-wholename './output' \
4242
-o -wholename './_output' \
43-
-o -wholename './_gopath' \
4443
-o -wholename './release' \
4544
-o -wholename './target' \
4645
-o -wholename '*/third_party/*' \

hack/verify-flags-underscore.py

-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ def get_all_files(rootdir):
5454
dirs.remove('staging')
5555
if '_output' in dirs:
5656
dirs.remove('_output')
57-
if '_gopath' in dirs:
58-
dirs.remove('_gopath')
5957
if 'third_party' in dirs:
6058
dirs.remove('third_party')
6159
if '.git' in dirs:

hack/verify-gofmt.sh

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ find_files() {
3838
-wholename './output' \
3939
-o -wholename './.git' \
4040
-o -wholename './_output' \
41-
-o -wholename './_gopath' \
4241
-o -wholename './release' \
4342
-o -wholename './target' \
4443
-o -wholename '*/third_party/*' \

hack/verify-netparse-cve.sh

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ find_files() {
3737
-wholename './output' \
3838
-o -wholename './.git' \
3939
-o -wholename './_output' \
40-
-o -wholename './_gopath' \
4140
-o -wholename './release' \
4241
-o -wholename './target' \
4342
-o -wholename '*/third_party/*' \

hack/verify-readonly-packages.sh

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ find_files() {
3333
\( \
3434
-wholename './output' \
3535
-o -wholename './_output' \
36-
-o -wholename './_gopath' \
3736
-o -wholename './release' \
3837
-o -wholename './target' \
3938
-o -wholename '*/third_party/*' \

staging/src/k8s.io/client-go/INSTALL.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,8 @@ go get k8s.io/[email protected]
7979
### Go modules disabled
8080

8181
If you get a message like `cannot use path@version syntax in GOPATH mode`,
82-
you likely do not have go modules enabled.
83-
84-
Dependency management tools are built into go 1.11+ in the form of
85-
[go modules](https://github.com/golang/go/wiki/Modules).
86-
These are used by the main Kubernetes repo (>= `v1.15.0`) and
87-
`client-go` (>= `kubernetes-1.15.0`) to manage dependencies.
88-
If you are using go 1.11 or 1.12 and are working with a project located within `$GOPATH`,
89-
you must opt into using go modules:
82+
you likely do not have go modules enabled. This should be on by default in all
83+
supported versions of Go.
9084

9185
```sh
9286
export GO111MODULE=on

staging/src/k8s.io/code-generator/cmd/client-gen/generators/fake/generator_fake_for_type.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package fake
1818

1919
import (
2020
"io"
21-
gopath "path"
2221
"path/filepath"
2322
"strings"
2423

@@ -153,7 +152,7 @@ func (g *genFakeForType) GenerateType(c *generator.Context, t *types.Type, w io.
153152
if generateApply {
154153
// Generated apply builder type references required for generated Apply function
155154
_, gvString := util.ParsePathGroupVersion(g.inputPackage)
156-
m["inputApplyConfig"] = types.Ref(gopath.Join(g.applyConfigurationPackage, gvString), t.Name.Name+"ApplyConfiguration")
155+
m["inputApplyConfig"] = types.Ref(filepath.Join(g.applyConfigurationPackage, gvString), t.Name.Name+"ApplyConfiguration")
157156
}
158157

159158
if tags.NonNamespaced {
@@ -237,7 +236,7 @@ func (g *genFakeForType) GenerateType(c *generator.Context, t *types.Type, w io.
237236
m["resultType"] = &resultType
238237
m["subresourcePath"] = e.SubResourcePath
239238
if e.HasVerb("apply") {
240-
m["inputApplyConfig"] = types.Ref(gopath.Join(g.applyConfigurationPackage, inputGVString), inputType.Name.Name+"ApplyConfiguration")
239+
m["inputApplyConfig"] = types.Ref(filepath.Join(g.applyConfigurationPackage, inputGVString), inputType.Name.Name+"ApplyConfiguration")
241240
}
242241

243242
if e.HasVerb("get") {

staging/src/k8s.io/sample-apiserver/README.md

+3-20
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,11 @@ Code changes are made in that location, merged into `k8s.io/kubernetes` and late
2626

2727
## Fetch sample-apiserver and its dependencies
2828

29-
Like the rest of Kubernetes, sample-apiserver has used
30-
[godep](https://github.com/tools/godep) and `$GOPATH` for years and is
31-
now adopting go 1.11 modules. There are thus two alternative ways to
32-
go about fetching this demo and its dependencies.
33-
34-
### Fetch with godep
35-
36-
When NOT using go 1.11 modules, you can use the following commands.
37-
38-
```sh
39-
go get -d k8s.io/sample-apiserver
40-
cd $GOPATH/src/k8s.io/sample-apiserver # assuming your GOPATH has just one entry
41-
godep restore
42-
```
43-
44-
### When using go 1.11 modules
45-
46-
When using go 1.11 modules (`GO111MODULE=on`), issue the following
47-
commands --- starting in whatever working directory you like.
29+
Issue the following commands --- starting in whatever working directory you
30+
like.
4831

4932
```sh
50-
git clone https://github.com/kubernetes/sample-apiserver.git
33+
git clone https://github.com/kubernetes/sample-apiserver
5134
cd sample-apiserver
5235
```
5336

staging/src/k8s.io/sample-controller/README.md

+3-20
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,11 @@ explained [here](docs/controller-client-go.md).
3333

3434
## Fetch sample-controller and its dependencies
3535

36-
Like the rest of Kubernetes, sample-controller has used
37-
[godep](https://github.com/tools/godep) and `$GOPATH` for years and is
38-
now adopting go 1.11 modules. There are thus two alternative ways to
39-
go about fetching this demo and its dependencies.
40-
41-
### Fetch with godep
42-
43-
When NOT using go 1.11 modules, you can use the following commands.
44-
45-
```sh
46-
go get -d k8s.io/sample-controller
47-
cd $GOPATH/src/k8s.io/sample-controller
48-
godep restore
49-
```
50-
51-
### When using go 1.11 modules
52-
53-
When using go 1.11 modules (`GO111MODULE=on`), issue the following
54-
commands --- starting in whatever working directory you like.
36+
Issue the following commands --- starting in whatever working directory you
37+
like.
5538

5639
```sh
57-
git clone https://github.com/kubernetes/sample-controller.git
40+
git clone https://github.com/kubernetes/sample-controller
5841
cd sample-controller
5942
```
6043

test/integration/auth/rbac_test.go

+11-9
Original file line numberDiff line numberDiff line change
@@ -583,35 +583,37 @@ func TestRBAC(t *testing.T) {
583583
previousResourceVersion := make(map[string]float64)
584584

585585
for j, r := range tc.requests {
586-
path := "/"
586+
// This is a URL-path, not a local path, so we use the "path"
587+
// package (aliased as "gopath") instead of "path/filepath".
588+
urlPath := "/"
587589
if r.apiGroup == "" {
588-
path = gopath.Join(path, "api/v1")
590+
urlPath = gopath.Join(urlPath, "api/v1")
589591
} else {
590-
path = gopath.Join(path, "apis", r.apiGroup, "v1")
592+
urlPath = gopath.Join(urlPath, "apis", r.apiGroup, "v1")
591593
}
592594
if r.namespace != "" {
593-
path = gopath.Join(path, "namespaces", r.namespace)
595+
urlPath = gopath.Join(urlPath, "namespaces", r.namespace)
594596
}
595597
if r.resource != "" {
596-
path = gopath.Join(path, r.resource)
598+
urlPath = gopath.Join(urlPath, r.resource)
597599
}
598600
if r.name != "" {
599-
path = gopath.Join(path, r.name)
601+
urlPath = gopath.Join(urlPath, r.name)
600602
}
601603

602604
var body io.Reader
603605
if r.body != "" {
604606
sub := ""
605607
if r.verb == "PUT" {
606608
// For update operations, insert previous resource version
607-
if resVersion := previousResourceVersion[getPreviousResourceVersionKey(path, "")]; resVersion != 0 {
609+
if resVersion := previousResourceVersion[getPreviousResourceVersionKey(urlPath, "")]; resVersion != 0 {
608610
sub += fmt.Sprintf(",\"resourceVersion\": \"%v\"", resVersion)
609611
}
610612
}
611613
body = strings.NewReader(fmt.Sprintf(r.body, sub))
612614
}
613615

614-
req, err := http.NewRequest(r.verb, kubeConfig.Host+path, body)
616+
req, err := http.NewRequest(r.verb, kubeConfig.Host+urlPath, body)
615617
if r.verb == "PATCH" {
616618
// For patch operations, use the apply content type
617619
req.Header.Add("Content-Type", string(types.ApplyPatchType))
@@ -662,7 +664,7 @@ func TestRBAC(t *testing.T) {
662664
// For successful create operations, extract resourceVersion
663665
id, currentResourceVersion, err := parseResourceVersion(b)
664666
if err == nil {
665-
key := getPreviousResourceVersionKey(path, id)
667+
key := getPreviousResourceVersionKey(urlPath, id)
666668
previousResourceVersion[key] = currentResourceVersion
667669
} else {
668670
t.Logf("error in trying to extract resource version: %s", err)

0 commit comments

Comments
 (0)