Remove defunct references to "vendor"
This commit is contained in:
		| @@ -49,7 +49,7 @@ kube::test::find_integration_test_dirs() { | |||||||
|     find test/integration/ -name '*_test.go' -print0 \ |     find test/integration/ -name '*_test.go' -print0 \ | ||||||
|       | xargs -0n1 dirname | sed "s|^|${KUBE_GO_PACKAGE}/|" \ |       | xargs -0n1 dirname | sed "s|^|${KUBE_GO_PACKAGE}/|" \ | ||||||
|       | LC_ALL=C sort -u |       | LC_ALL=C sort -u | ||||||
|     find vendor/k8s.io/apiextensions-apiserver/test/integration/ -name '*_test.go' -print0 \ |     find staging/src/k8s.io/apiextensions-apiserver/test/integration/ -name '*_test.go' -print0 \ | ||||||
|       | xargs -0n1 dirname | sed "s|^|${KUBE_GO_PACKAGE}/|" \ |       | xargs -0n1 dirname | sed "s|^|${KUBE_GO_PACKAGE}/|" \ | ||||||
|       | LC_ALL=C sort -u |       | LC_ALL=C sort -u | ||||||
|   ) |   ) | ||||||
|   | |||||||
| @@ -53,7 +53,7 @@ kube::test::find_dirs() { | |||||||
|         \) -prune \ |         \) -prune \ | ||||||
|       \) -name '*_test.go' -print0 | xargs -0n1 dirname | LC_ALL=C sort -u |       \) -name '*_test.go' -print0 | xargs -0n1 dirname | LC_ALL=C sort -u | ||||||
|  |  | ||||||
|     find ./staging -name '*_test.go' -not -path '*/test/integration/*' -prune -print0 | xargs -0n1 dirname | sed 's|^\./staging/src/|./vendor/|' | LC_ALL=C sort -u |     find ./staging -name '*_test.go' -not -path '*/test/integration/*' -prune -print0 | xargs -0n1 dirname | LC_ALL=C sort -u | ||||||
|   ) |   ) | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -255,18 +255,7 @@ runTests() { | |||||||
|   # we spawn a subshell for each PARALLEL process, redirecting the output to |   # we spawn a subshell for each PARALLEL process, redirecting the output to | ||||||
|   # separate files. |   # separate files. | ||||||
|  |  | ||||||
|   # ignore paths: |  | ||||||
|   # vendor/k8s.io/code-generator/cmd/generator: is fragile when run under coverage, so ignore it for now. |  | ||||||
|   #                            https://github.com/kubernetes/kubernetes/issues/24967 |  | ||||||
|   # vendor/k8s.io/client-go/1.4/rest: causes cover internal errors |  | ||||||
|   #                            https://github.com/golang/go/issues/16540 |  | ||||||
|   cover_ignore_dirs="vendor/k8s.io/code-generator/cmd/generator|vendor/k8s.io/client-go/1.4/rest" |  | ||||||
|   for path in ${cover_ignore_dirs//|/ }; do |  | ||||||
|       echo -e "skipped\tk8s.io/kubernetes/${path}" |  | ||||||
|   done |  | ||||||
|  |  | ||||||
|   printf "%s\n" "${@}" \ |   printf "%s\n" "${@}" \ | ||||||
|     | grep -Ev ${cover_ignore_dirs} \ |  | ||||||
|     | xargs -I{} -n 1 -P "${KUBE_COVERPROCS}" \ |     | xargs -I{} -n 1 -P "${KUBE_COVERPROCS}" \ | ||||||
|     bash -c "set -o pipefail; _pkg=\"\$0\"; _pkg_out=\${_pkg//\//_}; \ |     bash -c "set -o pipefail; _pkg=\"\$0\"; _pkg_out=\${_pkg//\//_}; \ | ||||||
|       go test ${goflags[*]:+${goflags[*]}} \ |       go test ${goflags[*]:+${goflags[*]}} \ | ||||||
|   | |||||||
| @@ -41,7 +41,6 @@ find_files() { | |||||||
|         -o -wholename './target' \ |         -o -wholename './target' \ | ||||||
|         -o -wholename '*/third_party/*' \ |         -o -wholename '*/third_party/*' \ | ||||||
|         -o -wholename '*/vendor/*' \ |         -o -wholename '*/vendor/*' \ | ||||||
|         -o -wholename './staging/src/k8s.io/client-go/*vendor/*' \ |  | ||||||
|       \) -prune \ |       \) -prune \ | ||||||
|     \) -name '*.go' |     \) -name '*.go' | ||||||
| } | } | ||||||
|   | |||||||
| @@ -37,7 +37,6 @@ find_files() { | |||||||
|         -o -wholename './target' \ |         -o -wholename './target' \ | ||||||
|         -o -wholename '*/third_party/*' \ |         -o -wholename '*/third_party/*' \ | ||||||
|         -o -wholename '*/vendor/*' \ |         -o -wholename '*/vendor/*' \ | ||||||
|         -o -wholename './staging/src/k8s.io/client-go/*vendor/*' \ |  | ||||||
|         -o -wholename './staging/src/k8s.io/client-go/pkg/*' \ |         -o -wholename './staging/src/k8s.io/client-go/pkg/*' \ | ||||||
|       \) -prune \ |       \) -prune \ | ||||||
|     \) -name '.readonly' |     \) -name '.readonly' | ||||||
|   | |||||||
| @@ -76,7 +76,7 @@ func output() error { | |||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
| // From vendor/k8s.io/apiserver/pkg/endpoints/openapi/openapi.go | // From k8s.io/apiserver/pkg/endpoints/openapi/openapi.go | ||||||
| func friendlyName(name string) string { | func friendlyName(name string) string { | ||||||
| 	nameParts := strings.Split(name, "/") | 	nameParts := strings.Split(name, "/") | ||||||
| 	// Reverse first part. e.g., io.k8s... instead of k8s.io... | 	// Reverse first part. e.g., io.k8s... instead of k8s.io... | ||||||
|   | |||||||
| @@ -42,11 +42,10 @@ code. You can directly modify such code. | |||||||
|  |  | ||||||
| ## Using staged repositories from Kubernetes code | ## Using staged repositories from Kubernetes code | ||||||
|  |  | ||||||
| Kubernetes code uses the repositories in this directory via symlinks in the | Kubernetes code uses the repositories in this directory via a Go workspace and | ||||||
| `vendor/k8s.io` directory into this staging area.  For example, when | module `replace` statements.  For example, when Kubernetes code imports a | ||||||
| Kubernetes code imports a package from the `k8s.io/client-go` repository, that | package from the `k8s.io/client-go` repository, that import is resolved to | ||||||
| import is resolved to `staging/src/k8s.io/client-go` relative to the project | `staging/src/k8s.io/client-go` relative to the project root: | ||||||
| root: |  | ||||||
|  |  | ||||||
| ```go | ```go | ||||||
| // pkg/example/some_code.go | // pkg/example/some_code.go | ||||||
| @@ -57,38 +56,40 @@ import ( | |||||||
| ) | ) | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| Once the change-over to external repositories is complete, these repositories |  | ||||||
| will actually be vendored from `k8s.io/<package-name>`. |  | ||||||
|  |  | ||||||
| ## Creating a new repository in staging | ## Creating a new repository in staging | ||||||
|  |  | ||||||
| ### Adding the staging repository in `kubernetes/kubernetes`: | ### Adding the staging repository in `kubernetes/kubernetes`: | ||||||
|  |  | ||||||
| 1. Send an email to the SIG Architecture | 1. Send an email to the SIG Architecture [mailing | ||||||
| [mailing list](https://groups.google.com/forum/#!forum/kubernetes-sig-architecture) |    list](https://groups.google.com/forum/#!forum/kubernetes-sig-architecture) | ||||||
| and the mailing list of the SIG which would own the repo requesting approval |    and the mailing list of the SIG which would own the repo requesting approval | ||||||
| for creating the staging repository. |    for creating the staging repository. | ||||||
|  |  | ||||||
| 2. Once approval has been granted, create the new staging repository. | 2. Once approval has been granted, create the new staging repository. | ||||||
|  |  | ||||||
| 3. Add a symlink to the staging repo in `vendor/k8s.io`. | 3. Update | ||||||
|  |    [`import-restrictions.yaml`](/staging/publishing/import-restrictions.yaml) | ||||||
|  |    to add the list of other staging repos that this new repo can import. | ||||||
|  |  | ||||||
| 4. Update [`import-restrictions.yaml`](/staging/publishing/import-restrictions.yaml) | 4. Add all mandatory template files to the staging repo as mentioned in | ||||||
| to add the list of other staging repos that this new repo can import. |    https://github.com/kubernetes/kubernetes-template-project. | ||||||
|  |  | ||||||
| 5. Add all mandatory template files to the staging repo as mentioned in | 5. Make sure that the `.github/PULL_REQUEST_TEMPLATE.md` and `CONTRIBUTING.md` | ||||||
| https://github.com/kubernetes/kubernetes-template-project. |    files mention that PRs are not directly accepted to the repo. | ||||||
|  |  | ||||||
| 6. Make sure that the `.github/PULL_REQUEST_TEMPLATE.md` and | 6. Ensure that `docs.go` file is added. Refer to | ||||||
| `CONTRIBUTING.md` files mention that PRs are not directly accepted to the repo. |    [#kubernetes/kubernetes#91354](https://github.com/kubernetes/kubernetes/blob/release-1.24/staging/src/k8s.io/client-go/doc.go) | ||||||
|  |    for reference. | ||||||
|  |  | ||||||
| 7. Ensure that `docs.go` file is added. Refer to [#kubernetes/kubernetes#91354](https://github.com/kubernetes/kubernetes/blob/release-1.24/staging/src/k8s.io/client-go/doc.go) for reference. | 7. NOTE: Do not edit go.mod or go.sum in the new repo (staging/src/k8s.io/<newrepo>/) manually. Run the following instead: | ||||||
|  |  | ||||||
| 8. NOTE: Do not edit go.mod or go.sum in the new repo (staging/src/k8s.io/<newrepo>/) manually. Run the following instead: |  | ||||||
|  |  | ||||||
| ``` | ``` | ||||||
|   ./hack/update-vendor.sh |   ./hack/update-vendor.sh | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|  | 8. Run [`./hack/update-go-workspace.sh`](/hack/update-go-workspace.sh) to add | ||||||
|  |    the module to the workspace. | ||||||
|  |  | ||||||
| ### Creating the published repository | ### Creating the published repository | ||||||
|  |  | ||||||
| 1. Create an [issue](https://github.com/kubernetes/org/issues/new?template=repo-create.md) | 1. Create an [issue](https://github.com/kubernetes/org/issues/new?template=repo-create.md) | ||||||
|   | |||||||
							
								
								
									
										4
									
								
								staging/src/k8s.io/api/testdata/README.md
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								staging/src/k8s.io/api/testdata/README.md
									
									
									
									
										vendored
									
									
								
							| @@ -83,7 +83,7 @@ to ensure we are not breaking backwards compatibility with serialized data from | |||||||
| To see the diff between the original JSON/YAML data and the `...after_roundtrip...` files: | To see the diff between the original JSON/YAML data and the `...after_roundtrip...` files: | ||||||
|  |  | ||||||
| ```sh | ```sh | ||||||
| cd vendor/k8s.io/api/testdata/v1.14.0/ | cd staging/src/k8s.io/api/testdata/v1.14.0/ | ||||||
| diff -u admission.k8s.io.v1beta1.AdmissionReview.json admission.k8s.io.v1beta1.AdmissionReview.after_roundtrip.json | diff -u admission.k8s.io.v1beta1.AdmissionReview.json admission.k8s.io.v1beta1.AdmissionReview.after_roundtrip.json | ||||||
| diff -u admission.k8s.io.v1beta1.AdmissionReview.yaml admission.k8s.io.v1beta1.AdmissionReview.after_roundtrip.yaml | diff -u admission.k8s.io.v1beta1.AdmissionReview.yaml admission.k8s.io.v1beta1.AdmissionReview.after_roundtrip.yaml | ||||||
| ``` | ``` | ||||||
| @@ -120,7 +120,7 @@ To see the diff between the original proto data and the `...after_roundtrip...` | |||||||
| and strip off the leading four-byte kubernetes protobuf header to get standard protobuf that can be decoded: | and strip off the leading four-byte kubernetes protobuf header to get standard protobuf that can be decoded: | ||||||
|  |  | ||||||
| ```sh | ```sh | ||||||
| cd vendor/k8s.io/api/testdata/v1.14.0/ | cd staging/src/k8s.io/api/testdata/v1.14.0/ | ||||||
| diff -u \ | diff -u \ | ||||||
|   <(tail -c +5 admission.k8s.io.v1beta1.AdmissionReview.pb | protoc --decode_raw) \ |   <(tail -c +5 admission.k8s.io.v1beta1.AdmissionReview.pb | protoc --decode_raw) \ | ||||||
|   <(tail -c +5 admission.k8s.io.v1beta1.AdmissionReview.after_roundtrip.pb | protoc --decode_raw) |   <(tail -c +5 admission.k8s.io.v1beta1.AdmissionReview.after_roundtrip.pb | protoc --decode_raw) | ||||||
|   | |||||||
| @@ -23,11 +23,11 @@ source "${KUBE_ROOT}/hack/lib/util.sh" | |||||||
|  |  | ||||||
| # Register function to be called on EXIT to remove generated binary. | # Register function to be called on EXIT to remove generated binary. | ||||||
| function cleanup { | function cleanup { | ||||||
|   rm "${KUBE_ROOT}/vendor/k8s.io/apiextensions-apiserver/artifacts/simple-image/apiextensions-apiserver" |   rm "${KUBE_ROOT}/staging/src/k8s.io/apiextensions-apiserver/artifacts/simple-image/apiextensions-apiserver" | ||||||
| } | } | ||||||
| trap cleanup EXIT | trap cleanup EXIT | ||||||
|  |  | ||||||
| pushd "${KUBE_ROOT}/vendor/k8s.io/apiextensions-apiserver" | pushd "${KUBE_ROOT}/staging/src/k8s.io/apiextensions-apiserver" | ||||||
| cp -v ../../../../_output/local/bin/linux/amd64/apiextensions-apiserver ./artifacts/simple-image/apiextensions-apiserver | cp -v ../../../../_output/local/bin/linux/amd64/apiextensions-apiserver ./artifacts/simple-image/apiextensions-apiserver | ||||||
| docker build -t apiextensions-apiserver:latest ./artifacts/simple-image | docker build -t apiextensions-apiserver:latest ./artifacts/simple-image | ||||||
| popd | popd | ||||||
|   | |||||||
| @@ -42,7 +42,7 @@ func BenchmarkAdmit(b *testing.B) { | |||||||
| 	if len(testServerURL) == 0 { | 	if len(testServerURL) == 0 { | ||||||
| 		b.Log("warning, WEBHOOK_TEST_SERVER_URL not set, starting in-process server, benchmarks will include webhook cost.") | 		b.Log("warning, WEBHOOK_TEST_SERVER_URL not set, starting in-process server, benchmarks will include webhook cost.") | ||||||
| 		b.Log("to run a standalone server, run:") | 		b.Log("to run a standalone server, run:") | ||||||
| 		b.Log("go run ./vendor/k8s.io/apiserver/pkg/admission/plugin/webhook/testing/main/main.go") | 		b.Log("go run k8s.io/apiserver/pkg/admission/plugin/webhook/testing/main/main.go") | ||||||
| 		testServer := webhooktesting.NewTestServer(b) | 		testServer := webhooktesting.NewTestServer(b) | ||||||
| 		testServer.StartTLS() | 		testServer.StartTLS() | ||||||
| 		defer testServer.Close() | 		defer testServer.Close() | ||||||
|   | |||||||
| @@ -38,7 +38,7 @@ func BenchmarkValidate(b *testing.B) { | |||||||
| 	if len(testServerURL) == 0 { | 	if len(testServerURL) == 0 { | ||||||
| 		b.Log("warning, WEBHOOK_TEST_SERVER_URL not set, starting in-process server, benchmarks will include webhook cost.") | 		b.Log("warning, WEBHOOK_TEST_SERVER_URL not set, starting in-process server, benchmarks will include webhook cost.") | ||||||
| 		b.Log("to run a standalone server, run:") | 		b.Log("to run a standalone server, run:") | ||||||
| 		b.Log("go run ./vendor/k8s.io/apiserver/pkg/admission/plugin/webhook/testing/main/main.go") | 		b.Log("go run k8s.io/apiserver/pkg/admission/plugin/webhook/testing/main/main.go") | ||||||
| 		testServer := webhooktesting.NewTestServer(b) | 		testServer := webhooktesting.NewTestServer(b) | ||||||
| 		testServer.StartTLS() | 		testServer.StartTLS() | ||||||
| 		defer testServer.Close() | 		defer testServer.Close() | ||||||
|   | |||||||
| @@ -50,7 +50,7 @@ func (e shortcutExpander) KindFor(resource schema.GroupVersionResource) (schema. | |||||||
| 	// In case of new CRDs this means we potentially don't have current state of discovery. | 	// In case of new CRDs this means we potentially don't have current state of discovery. | ||||||
| 	// In the current wiring in k8s.io/cli-runtime/pkg/genericclioptions/config_flags.go#toRESTMapper, | 	// In the current wiring in k8s.io/cli-runtime/pkg/genericclioptions/config_flags.go#toRESTMapper, | ||||||
| 	// we are using DeferredDiscoveryRESTMapper which on KindFor failure will clear the | 	// we are using DeferredDiscoveryRESTMapper which on KindFor failure will clear the | ||||||
| 	// cache and fetch all data from a cluster (see vendor/k8s.io/client-go/restmapper/discovery.go#KindFor). | 	// cache and fetch all data from a cluster (see k8s.io/client-go/restmapper/discovery.go#KindFor). | ||||||
| 	// Thus another call to expandResourceShortcut, after a NoMatchError should successfully | 	// Thus another call to expandResourceShortcut, after a NoMatchError should successfully | ||||||
| 	// read Kind to the user or an error. | 	// read Kind to the user or an error. | ||||||
| 	gvk, err := e.RESTMapper.KindFor(e.expandResourceShortcut(resource)) | 	gvk, err := e.RESTMapper.KindFor(e.expandResourceShortcut(resource)) | ||||||
|   | |||||||
| @@ -158,9 +158,6 @@ func friendlyName(name string) string { | |||||||
|  |  | ||||||
| func typeName(t *types.Type) string { | func typeName(t *types.Type) string { | ||||||
| 	typePackage := t.Name.Package | 	typePackage := t.Name.Package | ||||||
| 	if strings.Contains(typePackage, "/vendor/") { |  | ||||||
| 		typePackage = typePackage[strings.Index(typePackage, "/vendor/")+len("/vendor/"):] |  | ||||||
| 	} |  | ||||||
| 	return fmt.Sprintf("%s.%s", typePackage, t.Name.Name) | 	return fmt.Sprintf("%s.%s", typePackage, t.Name.Name) | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -26,10 +26,8 @@ import ( | |||||||
| 	"k8s.io/code-generator/cmd/client-gen/generators/fake" | 	"k8s.io/code-generator/cmd/client-gen/generators/fake" | ||||||
| 	"k8s.io/code-generator/cmd/client-gen/generators/scheme" | 	"k8s.io/code-generator/cmd/client-gen/generators/scheme" | ||||||
| 	"k8s.io/code-generator/cmd/client-gen/generators/util" | 	"k8s.io/code-generator/cmd/client-gen/generators/util" | ||||||
| 	"k8s.io/code-generator/cmd/client-gen/path" |  | ||||||
| 	clientgentypes "k8s.io/code-generator/cmd/client-gen/types" | 	clientgentypes "k8s.io/code-generator/cmd/client-gen/types" | ||||||
| 	codegennamer "k8s.io/code-generator/pkg/namer" | 	codegennamer "k8s.io/code-generator/pkg/namer" | ||||||
| 	genutil "k8s.io/code-generator/pkg/util" |  | ||||||
| 	"k8s.io/gengo/v2/args" | 	"k8s.io/gengo/v2/args" | ||||||
| 	"k8s.io/gengo/v2/generator" | 	"k8s.io/gengo/v2/generator" | ||||||
| 	"k8s.io/gengo/v2/namer" | 	"k8s.io/gengo/v2/namer" | ||||||
| @@ -279,7 +277,7 @@ func applyGroupOverrides(universe types.Universe, customArgs *clientgenargs.Cust | |||||||
| 	// Create a map from "old GV" to "new GV" so we know what changes we need to make. | 	// Create a map from "old GV" to "new GV" so we know what changes we need to make. | ||||||
| 	changes := make(map[clientgentypes.GroupVersion]clientgentypes.GroupVersion) | 	changes := make(map[clientgentypes.GroupVersion]clientgentypes.GroupVersion) | ||||||
| 	for gv, inputDir := range customArgs.GroupVersionPackages() { | 	for gv, inputDir := range customArgs.GroupVersionPackages() { | ||||||
| 		p := universe.Package(genutil.Vendorless(inputDir)) | 		p := universe.Package(inputDir) | ||||||
| 		if override := types.ExtractCommentTags("+", p.Comments)["groupName"]; override != nil { | 		if override := types.ExtractCommentTags("+", p.Comments)["groupName"]; override != nil { | ||||||
| 			newGV := clientgentypes.GroupVersion{ | 			newGV := clientgentypes.GroupVersion{ | ||||||
| 				Group:   clientgentypes.Group(override[0]), | 				Group:   clientgentypes.Group(override[0]), | ||||||
| @@ -324,7 +322,7 @@ func sanitizePackagePaths(context *generator.Context, ca *clientgenargs.CustomAr | |||||||
| 		for j := range pkg.Versions { | 		for j := range pkg.Versions { | ||||||
| 			ver := &pkg.Versions[j] | 			ver := &pkg.Versions[j] | ||||||
| 			input := ver.Package | 			input := ver.Package | ||||||
| 			p := context.Universe[path.Vendorless(input)] | 			p := context.Universe[input] | ||||||
| 			if p == nil || p.Name == "" { | 			if p == nil || p.Name == "" { | ||||||
| 				pkgs, err := context.FindPackages(input) | 				pkgs, err := context.FindPackages(input) | ||||||
| 				if err != nil { | 				if err != nil { | ||||||
| @@ -362,7 +360,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat | |||||||
| 	gvToTypes := map[clientgentypes.GroupVersion][]*types.Type{} | 	gvToTypes := map[clientgentypes.GroupVersion][]*types.Type{} | ||||||
| 	groupGoNames := make(map[clientgentypes.GroupVersion]string) | 	groupGoNames := make(map[clientgentypes.GroupVersion]string) | ||||||
| 	for gv, inputDir := range customArgs.GroupVersionPackages() { | 	for gv, inputDir := range customArgs.GroupVersionPackages() { | ||||||
| 		p := context.Universe.Package(path.Vendorless(inputDir)) | 		p := context.Universe.Package(inputDir) | ||||||
|  |  | ||||||
| 		// If there's a comment of the form "// +groupGoName=SomeUniqueShortName", use that as | 		// If there's a comment of the form "// +groupGoName=SomeUniqueShortName", use that as | ||||||
| 		// the Go group identifier in CamelCase. It defaults | 		// the Go group identifier in CamelCase. It defaults | ||||||
| @@ -371,7 +369,6 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat | |||||||
| 			groupGoNames[gv] = namer.IC(override[0]) | 			groupGoNames[gv] = namer.IC(override[0]) | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		// Package are indexed with the vendor prefix stripped |  | ||||||
| 		for n, t := range p.Types { | 		for n, t := range p.Types { | ||||||
| 			// filter out types which are not included in user specified overrides. | 			// filter out types which are not included in user specified overrides. | ||||||
| 			typesOverride, ok := includedTypesOverrides[gv] | 			typesOverride, ok := includedTypesOverrides[gv] | ||||||
|   | |||||||
| @@ -25,7 +25,6 @@ import ( | |||||||
| 	"k8s.io/gengo/v2/types" | 	"k8s.io/gengo/v2/types" | ||||||
|  |  | ||||||
| 	"k8s.io/code-generator/cmd/client-gen/generators/util" | 	"k8s.io/code-generator/cmd/client-gen/generators/util" | ||||||
| 	"k8s.io/code-generator/cmd/client-gen/path" |  | ||||||
| ) | ) | ||||||
|  |  | ||||||
| // genGroup produces a file for a group client, e.g. ExtensionsClient for the extension group. | // genGroup produces a file for a group client, e.g. ExtensionsClient for the extension group. | ||||||
| @@ -83,7 +82,7 @@ func (g *genGroup) GenerateType(c *generator.Context, t *types.Type, w io.Writer | |||||||
| 		groupName = "" | 		groupName = "" | ||||||
| 	} | 	} | ||||||
| 	// allow user to define a group name that's different from the one parsed from the directory. | 	// allow user to define a group name that's different from the one parsed from the directory. | ||||||
| 	p := c.Universe.Package(path.Vendorless(g.inputPackage)) | 	p := c.Universe.Package(g.inputPackage) | ||||||
| 	if override := types.ExtractCommentTags("+", p.Comments)["groupName"]; override != nil { | 	if override := types.ExtractCommentTags("+", p.Comments)["groupName"]; override != nil { | ||||||
| 		groupName = override[0] | 		groupName = override[0] | ||||||
| 	} | 	} | ||||||
| @@ -104,7 +103,7 @@ func (g *genGroup) GenerateType(c *generator.Context, t *types.Type, w io.Writer | |||||||
| 		"RESTHTTPClientFor":                c.Universe.Function(types.Name{Package: "k8s.io/client-go/rest", Name: "HTTPClientFor"}), | 		"RESTHTTPClientFor":                c.Universe.Function(types.Name{Package: "k8s.io/client-go/rest", Name: "HTTPClientFor"}), | ||||||
| 		"restRESTClientFor":                c.Universe.Function(types.Name{Package: "k8s.io/client-go/rest", Name: "RESTClientFor"}), | 		"restRESTClientFor":                c.Universe.Function(types.Name{Package: "k8s.io/client-go/rest", Name: "RESTClientFor"}), | ||||||
| 		"restRESTClientForConfigAndClient": c.Universe.Function(types.Name{Package: "k8s.io/client-go/rest", Name: "RESTClientForConfigAndClient"}), | 		"restRESTClientForConfigAndClient": c.Universe.Function(types.Name{Package: "k8s.io/client-go/rest", Name: "RESTClientForConfigAndClient"}), | ||||||
| 		"SchemeGroupVersion":               c.Universe.Variable(types.Name{Package: path.Vendorless(g.inputPackage), Name: "SchemeGroupVersion"}), | 		"SchemeGroupVersion":               c.Universe.Variable(types.Name{Package: g.inputPackage, Name: "SchemeGroupVersion"}), | ||||||
| 	} | 	} | ||||||
| 	sw.Do(groupInterfaceTemplate, m) | 	sw.Do(groupInterfaceTemplate, m) | ||||||
| 	sw.Do(groupClientTemplate, m) | 	sw.Do(groupClientTemplate, m) | ||||||
|   | |||||||
| @@ -23,7 +23,6 @@ import ( | |||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"strings" | 	"strings" | ||||||
|  |  | ||||||
| 	"k8s.io/code-generator/cmd/client-gen/path" |  | ||||||
| 	clientgentypes "k8s.io/code-generator/cmd/client-gen/types" | 	clientgentypes "k8s.io/code-generator/cmd/client-gen/types" | ||||||
| 	"k8s.io/gengo/v2/generator" | 	"k8s.io/gengo/v2/generator" | ||||||
| 	"k8s.io/gengo/v2/namer" | 	"k8s.io/gengo/v2/namer" | ||||||
| @@ -70,10 +69,10 @@ func (g *GenScheme) Imports(c *generator.Context) (imports []string) { | |||||||
| 				} | 				} | ||||||
| 				packagePath = filepath.Join(packagePath, "install") | 				packagePath = filepath.Join(packagePath, "install") | ||||||
|  |  | ||||||
| 				imports = append(imports, fmt.Sprintf("%s \"%s\"", groupAlias, path.Vendorless(packagePath))) | 				imports = append(imports, fmt.Sprintf("%s \"%s\"", groupAlias, packagePath)) | ||||||
| 				break | 				break | ||||||
| 			} else { | 			} else { | ||||||
| 				imports = append(imports, fmt.Sprintf("%s%s \"%s\"", groupAlias, strings.ToLower(version.Version.NonEmpty()), path.Vendorless(packagePath))) | 				imports = append(imports, fmt.Sprintf("%s%s \"%s\"", groupAlias, strings.ToLower(version.Version.NonEmpty()), packagePath)) | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -1,31 +0,0 @@ | |||||||
| /* |  | ||||||
| Copyright 2017 The Kubernetes Authors. |  | ||||||
|  |  | ||||||
| Licensed under the Apache License, Version 2.0 (the "License"); |  | ||||||
| you may not use this file except in compliance with the License. |  | ||||||
| You may obtain a copy of the License at |  | ||||||
|  |  | ||||||
|     http://www.apache.org/licenses/LICENSE-2.0 |  | ||||||
|  |  | ||||||
| Unless required by applicable law or agreed to in writing, software |  | ||||||
| distributed under the License is distributed on an "AS IS" BASIS, |  | ||||||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |  | ||||||
| See the License for the specific language governing permissions and |  | ||||||
| limitations under the License. |  | ||||||
| */ |  | ||||||
|  |  | ||||||
| package path |  | ||||||
|  |  | ||||||
| import "strings" |  | ||||||
|  |  | ||||||
| // Vendorless removes the longest match of "*/vendor/" from the front of p. |  | ||||||
| // It is useful if a package locates in vendor/, e.g., |  | ||||||
| // k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/apis/meta/v1, because gengo |  | ||||||
| // indexes the package with its import path, e.g., |  | ||||||
| // k8s.io/apimachinery/pkg/apis/meta/v1, |  | ||||||
| func Vendorless(p string) string { |  | ||||||
| 	if pos := strings.LastIndex(p, "/vendor/"); pos != -1 { |  | ||||||
| 		return p[pos+len("/vendor/"):] |  | ||||||
| 	} |  | ||||||
| 	return p |  | ||||||
| } |  | ||||||
| @@ -33,7 +33,6 @@ import ( | |||||||
| 	"k8s.io/klog/v2" | 	"k8s.io/klog/v2" | ||||||
|  |  | ||||||
| 	conversionargs "k8s.io/code-generator/cmd/conversion-gen/args" | 	conversionargs "k8s.io/code-generator/cmd/conversion-gen/args" | ||||||
| 	genutil "k8s.io/code-generator/pkg/util" |  | ||||||
| ) | ) | ||||||
|  |  | ||||||
| // These are the comment tags that carry parameters for conversion generation. | // These are the comment tags that carry parameters for conversion generation. | ||||||
| @@ -273,19 +272,9 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	// Make sure explicit peer-packages are added. | 	// Make sure explicit peer-packages are added. | ||||||
| 	var sanitizedPeerPkgs []string |  | ||||||
| 	if customArgs, ok := arguments.CustomArgs.(*conversionargs.CustomArgs); ok { | 	if customArgs, ok := arguments.CustomArgs.(*conversionargs.CustomArgs); ok { | ||||||
| 		all := append(customArgs.BasePeerDirs, customArgs.ExtraPeerDirs...) | 		peers := append(customArgs.BasePeerDirs, customArgs.ExtraPeerDirs...) | ||||||
| 		for _, pkg := range all { | 		if expanded, err := context.FindPackages(peers...); err != nil { | ||||||
| 			// if the source path is within a /vendor/ directory (for example, |  | ||||||
| 			// k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/apis/meta/v1), allow |  | ||||||
| 			// generation to output to the proper relative path (under vendor). |  | ||||||
| 			// Otherwise, the generator will create the file in the wrong location |  | ||||||
| 			// in the output directory. |  | ||||||
| 			pkg = genutil.Vendorless(pkg) |  | ||||||
| 			sanitizedPeerPkgs = append(sanitizedPeerPkgs, pkg) |  | ||||||
| 		} |  | ||||||
| 		if expanded, err := context.FindPackages(sanitizedPeerPkgs...); err != nil { |  | ||||||
| 			klog.Fatalf("cannot find peer packages: %v", err) | 			klog.Fatalf("cannot find peer packages: %v", err) | ||||||
| 		} else { | 		} else { | ||||||
| 			otherPkgs = append(otherPkgs, expanded...) | 			otherPkgs = append(otherPkgs, expanded...) | ||||||
| @@ -326,7 +315,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat | |||||||
| 		pkg := context.Universe[i] | 		pkg := context.Universe[i] | ||||||
| 		// typesPkg is where the versioned types are defined. Sometimes it is | 		// typesPkg is where the versioned types are defined. Sometimes it is | ||||||
| 		// different from pkg. For example, kubernetes core/v1 types are defined | 		// different from pkg. For example, kubernetes core/v1 types are defined | ||||||
| 		// in vendor/k8s.io/api/core/v1, while pkg is at pkg/api/v1. | 		// in k8s.io/api/core/v1, while pkg is at pkg/api/v1. | ||||||
| 		typesPkg := pkg | 		typesPkg := pkg | ||||||
|  |  | ||||||
| 		// Add conversion and defaulting functions. | 		// Add conversion and defaulting functions. | ||||||
| @@ -341,29 +330,15 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat | |||||||
| 			unsafeEquality = noEquality{} | 			unsafeEquality = noEquality{} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		path := pkg.Path |  | ||||||
| 		// if the source path is within a /vendor/ directory (for example, |  | ||||||
| 		// k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/apis/meta/v1), allow |  | ||||||
| 		// generation to output to the proper relative path (under vendor). |  | ||||||
| 		// Otherwise, the generator will create the file in the wrong location |  | ||||||
| 		// in the output directory. |  | ||||||
| 		// TODO: build a more fundamental concept in gengo for dealing with modifications |  | ||||||
| 		// to vendored packages. |  | ||||||
| 		if strings.HasPrefix(pkg.SourcePath, arguments.OutputBase) { |  | ||||||
| 			expandedPath := strings.TrimPrefix(pkg.SourcePath, arguments.OutputBase) |  | ||||||
| 			if strings.Contains(expandedPath, "/vendor/") { |  | ||||||
| 				path = expandedPath |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 		packages = append(packages, | 		packages = append(packages, | ||||||
| 			&generator.DefaultPackage{ | 			&generator.DefaultPackage{ | ||||||
| 				PackageName: filepath.Base(pkg.Path), | 				PackageName: filepath.Base(pkg.Path), | ||||||
| 				PackagePath: path, | 				PackagePath: pkg.Path, | ||||||
| 				Source:      pkg.SourcePath, // output pkg is the same as the input | 				Source:      pkg.SourcePath, // output pkg is the same as the input | ||||||
| 				HeaderText:  header, | 				HeaderText:  header, | ||||||
| 				GeneratorFunc: func(c *generator.Context) (generators []generator.Generator) { | 				GeneratorFunc: func(c *generator.Context) (generators []generator.Generator) { | ||||||
| 					return []generator.Generator{ | 					return []generator.Generator{ | ||||||
| 						NewGenConversion(arguments.OutputFileBaseName, typesPkg.Path, pkg.Path, manualConversions, pkgToPeers[path], unsafeEquality), | 						NewGenConversion(arguments.OutputFileBaseName, typesPkg.Path, pkg.Path, manualConversions, pkgToPeers[pkg.Path], unsafeEquality), | ||||||
| 					} | 					} | ||||||
| 				}, | 				}, | ||||||
| 				FilterFunc: func(c *generator.Context, t *types.Type) bool { | 				FilterFunc: func(c *generator.Context, t *types.Type) bool { | ||||||
|   | |||||||
| @@ -122,7 +122,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat | |||||||
| 	internalGroupVersions := make(map[string]clientgentypes.GroupVersions) | 	internalGroupVersions := make(map[string]clientgentypes.GroupVersions) | ||||||
| 	groupGoNames := make(map[string]string) | 	groupGoNames := make(map[string]string) | ||||||
| 	for _, inputDir := range arguments.InputDirs { | 	for _, inputDir := range arguments.InputDirs { | ||||||
| 		p := context.Universe.Package(genutil.Vendorless(inputDir)) | 		p := context.Universe.Package(inputDir) | ||||||
|  |  | ||||||
| 		objectMeta, internal, err := objectMetaForPackage(p) | 		objectMeta, internal, err := objectMetaForPackage(p) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
|   | |||||||
| @@ -230,24 +230,10 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if pkgNeedsGeneration { | 		if pkgNeedsGeneration { | ||||||
| 			path := pkg.Path |  | ||||||
| 			// if the source path is within a /vendor/ directory (for example, |  | ||||||
| 			// k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/apis/meta/v1), allow |  | ||||||
| 			// generation to output to the proper relative path (under vendor). |  | ||||||
| 			// Otherwise, the generator will create the file in the wrong location |  | ||||||
| 			// in the output directory. |  | ||||||
| 			// TODO: build a more fundamental concept in gengo for dealing with modifications |  | ||||||
| 			// to vendored packages. |  | ||||||
| 			if strings.HasPrefix(pkg.SourcePath, arguments.OutputBase) { |  | ||||||
| 				expandedPath := strings.TrimPrefix(pkg.SourcePath, arguments.OutputBase) |  | ||||||
| 				if strings.Contains(expandedPath, "/vendor/") { |  | ||||||
| 					path = expandedPath |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 			packages = append(packages, | 			packages = append(packages, | ||||||
| 				&generator.DefaultPackage{ | 				&generator.DefaultPackage{ | ||||||
| 					PackageName: strings.Split(filepath.Base(pkg.Path), ".")[0], | 					PackageName: strings.Split(filepath.Base(pkg.Path), ".")[0], | ||||||
| 					PackagePath: path, | 					PackagePath: pkg.Path, | ||||||
| 					Source:      pkg.SourcePath, // output pkg is the same as the input | 					Source:      pkg.SourcePath, // output pkg is the same as the input | ||||||
| 					HeaderText:  header, | 					HeaderText:  header, | ||||||
| 					GeneratorFunc: func(c *generator.Context) (generators []generator.Generator) { | 					GeneratorFunc: func(c *generator.Context) (generators []generator.Generator) { | ||||||
|   | |||||||
| @@ -1,29 +0,0 @@ | |||||||
| /* |  | ||||||
| Copyright 2017 The Kubernetes Authors. |  | ||||||
|  |  | ||||||
| Licensed under the Apache License, Version 2.0 (the "License"); |  | ||||||
| you may not use this file except in compliance with the License. |  | ||||||
| You may obtain a copy of the License at |  | ||||||
|  |  | ||||||
|     http://www.apache.org/licenses/LICENSE-2.0 |  | ||||||
|  |  | ||||||
| Unless required by applicable law or agreed to in writing, software |  | ||||||
| distributed under the License is distributed on an "AS IS" BASIS, |  | ||||||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |  | ||||||
| See the License for the specific language governing permissions and |  | ||||||
| limitations under the License. |  | ||||||
| */ |  | ||||||
|  |  | ||||||
| package util |  | ||||||
|  |  | ||||||
| import ( |  | ||||||
| 	"strings" |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| // Vendorless trims vendor prefix from a package path to make it canonical |  | ||||||
| func Vendorless(p string) string { |  | ||||||
| 	if pos := strings.LastIndex(p, "/vendor/"); pos != -1 { |  | ||||||
| 		return p[pos+len("/vendor/"):] |  | ||||||
| 	} |  | ||||||
| 	return p |  | ||||||
| } |  | ||||||
| @@ -30,13 +30,13 @@ import ( | |||||||
| // We setup this list for allow and not fail on the current violations. | // We setup this list for allow and not fail on the current violations. | ||||||
| // Generally speaking, you need to fix the problem for a new metric rather than add it into the list. | // Generally speaking, you need to fix the problem for a new metric rather than add it into the list. | ||||||
| var exceptionMetrics = []string{ | var exceptionMetrics = []string{ | ||||||
| 	// k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/server/egressselector | 	// k8s.io/apiserver/pkg/server/egressselector | ||||||
| 	"apiserver_egress_dialer_dial_failure_count", // counter metrics should have "_total" suffix | 	"apiserver_egress_dialer_dial_failure_count", // counter metrics should have "_total" suffix | ||||||
|  |  | ||||||
| 	// k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/server/healthz | 	// k8s.io/apiserver/pkg/server/healthz | ||||||
| 	"apiserver_request_total", // label names should be written in 'snake_case' not 'camelCase' | 	"apiserver_request_total", // label names should be written in 'snake_case' not 'camelCase' | ||||||
|  |  | ||||||
| 	// k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/endpoints/filters | 	// k8s.io/apiserver/pkg/endpoints/filters | ||||||
| 	"authenticated_user_requests", // counter metrics should have "_total" suffix | 	"authenticated_user_requests", // counter metrics should have "_total" suffix | ||||||
| 	"authentication_attempts",     // counter metrics should have "_total" suffix | 	"authentication_attempts",     // counter metrics should have "_total" suffix | ||||||
|  |  | ||||||
|   | |||||||
| @@ -23,11 +23,11 @@ source "${KUBE_ROOT}/hack/lib/util.sh" | |||||||
|  |  | ||||||
| # Register function to be called on EXIT to remove generated binary. | # Register function to be called on EXIT to remove generated binary. | ||||||
| function cleanup { | function cleanup { | ||||||
|   rm "${KUBE_ROOT}/vendor/k8s.io/kube-aggregator/artifacts/simple-image/kube-aggregator" |   rm "${KUBE_ROOT}/staging/src/k8s.io/kube-aggregator/artifacts/simple-image/kube-aggregator" | ||||||
| } | } | ||||||
| trap cleanup EXIT | trap cleanup EXIT | ||||||
|  |  | ||||||
| pushd "${KUBE_ROOT}/vendor/k8s.io/kube-aggregator" | pushd "${KUBE_ROOT}/staging/src/k8s.io/kube-aggregator" | ||||||
| cp -v ../../../../_output/local/bin/linux/amd64/kube-aggregator ./artifacts/simple-image/kube-aggregator | cp -v ../../../../_output/local/bin/linux/amd64/kube-aggregator ./artifacts/simple-image/kube-aggregator | ||||||
| docker build -t kube-aggregator:latest ./artifacts/simple-image | docker build -t kube-aggregator:latest ./artifacts/simple-image | ||||||
| popd | popd | ||||||
| @@ -23,11 +23,11 @@ source "${KUBE_ROOT}/hack/lib/util.sh" | |||||||
|  |  | ||||||
| # Register function to be called on EXIT to remove generated binary. | # Register function to be called on EXIT to remove generated binary. | ||||||
| function cleanup { | function cleanup { | ||||||
|   rm "${KUBE_ROOT}/vendor/k8s.io/sample-apiserver/artifacts/simple-image/kube-sample-apiserver" |   rm "${KUBE_ROOT}/staging/src/k8s.io/sample-apiserver/artifacts/simple-image/kube-sample-apiserver" | ||||||
| } | } | ||||||
| trap cleanup EXIT | trap cleanup EXIT | ||||||
|  |  | ||||||
| pushd "${KUBE_ROOT}/vendor/k8s.io/sample-apiserver" | pushd "${KUBE_ROOT}/staging/src/k8s.io/sample-apiserver" | ||||||
| cp -v ../../../../_output/local/bin/linux/amd64/sample-apiserver ./artifacts/simple-image/kube-sample-apiserver | cp -v ../../../../_output/local/bin/linux/amd64/sample-apiserver ./artifacts/simple-image/kube-sample-apiserver | ||||||
| docker build -t kube-sample-apiserver:latest ./artifacts/simple-image | docker build -t kube-sample-apiserver:latest ./artifacts/simple-image | ||||||
| popd | popd | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Tim Hockin
					Tim Hockin