diff --git a/hack/make-rules/test-integration.sh b/hack/make-rules/test-integration.sh index 2665ca5c160..c0bc848b9e8 100755 --- a/hack/make-rules/test-integration.sh +++ b/hack/make-rules/test-integration.sh @@ -49,7 +49,7 @@ kube::test::find_integration_test_dirs() { find test/integration/ -name '*_test.go' -print0 \ | xargs -0n1 dirname | sed "s|^|${KUBE_GO_PACKAGE}/|" \ | 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}/|" \ | LC_ALL=C sort -u ) diff --git a/hack/make-rules/test.sh b/hack/make-rules/test.sh index bd16994db25..e59e3daa6ed 100755 --- a/hack/make-rules/test.sh +++ b/hack/make-rules/test.sh @@ -53,7 +53,7 @@ kube::test::find_dirs() { \) -prune \ \) -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 # 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" "${@}" \ - | grep -Ev ${cover_ignore_dirs} \ | xargs -I{} -n 1 -P "${KUBE_COVERPROCS}" \ bash -c "set -o pipefail; _pkg=\"\$0\"; _pkg_out=\${_pkg//\//_}; \ go test ${goflags[*]:+${goflags[*]}} \ diff --git a/hack/verify-netparse-cve.sh b/hack/verify-netparse-cve.sh index 323eb9e46d8..cfd18b28bf5 100755 --- a/hack/verify-netparse-cve.sh +++ b/hack/verify-netparse-cve.sh @@ -41,7 +41,6 @@ find_files() { -o -wholename './target' \ -o -wholename '*/third_party/*' \ -o -wholename '*/vendor/*' \ - -o -wholename './staging/src/k8s.io/client-go/*vendor/*' \ \) -prune \ \) -name '*.go' } diff --git a/hack/verify-readonly-packages.sh b/hack/verify-readonly-packages.sh index e0bf6ce3c08..2b0244366b6 100755 --- a/hack/verify-readonly-packages.sh +++ b/hack/verify-readonly-packages.sh @@ -37,7 +37,6 @@ find_files() { -o -wholename './target' \ -o -wholename '*/third_party/*' \ -o -wholename '*/vendor/*' \ - -o -wholename './staging/src/k8s.io/client-go/*vendor/*' \ -o -wholename './staging/src/k8s.io/client-go/pkg/*' \ \) -prune \ \) -name '.readonly' diff --git a/pkg/generated/openapi/cmd/models-schema/main.go b/pkg/generated/openapi/cmd/models-schema/main.go index 0d743db9bc2..ac046d3ad6c 100644 --- a/pkg/generated/openapi/cmd/models-schema/main.go +++ b/pkg/generated/openapi/cmd/models-schema/main.go @@ -76,7 +76,7 @@ func output() error { 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 { nameParts := strings.Split(name, "/") // Reverse first part. e.g., io.k8s... instead of k8s.io... diff --git a/staging/README.md b/staging/README.md index 0939cc10341..159b0304d93 100644 --- a/staging/README.md +++ b/staging/README.md @@ -42,11 +42,10 @@ code. You can directly modify such code. ## Using staged repositories from Kubernetes code -Kubernetes code uses the repositories in this directory via symlinks in the -`vendor/k8s.io` directory into this staging area. For example, when -Kubernetes code imports a package from the `k8s.io/client-go` repository, that -import is resolved to `staging/src/k8s.io/client-go` relative to the project -root: +Kubernetes code uses the repositories in this directory via a Go workspace and +module `replace` statements. For example, when Kubernetes code imports a +package from the `k8s.io/client-go` repository, that import is resolved to +`staging/src/k8s.io/client-go` relative to the project root: ```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/`. - ## Creating a new repository in staging ### Adding the staging repository in `kubernetes/kubernetes`: -1. Send an email to the SIG Architecture -[mailing list](https://groups.google.com/forum/#!forum/kubernetes-sig-architecture) -and the mailing list of the SIG which would own the repo requesting approval -for creating the staging repository. +1. Send an email to the SIG Architecture [mailing + list](https://groups.google.com/forum/#!forum/kubernetes-sig-architecture) + and the mailing list of the SIG which would own the repo requesting approval + for creating the 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) -to add the list of other staging repos that this new repo can import. +4. Add all mandatory template files to the staging repo as mentioned in + https://github.com/kubernetes/kubernetes-template-project. -5. Add all mandatory template files to the staging repo as mentioned in -https://github.com/kubernetes/kubernetes-template-project. +5. Make sure that the `.github/PULL_REQUEST_TEMPLATE.md` and `CONTRIBUTING.md` + files mention that PRs are not directly accepted to the repo. -6. Make sure that the `.github/PULL_REQUEST_TEMPLATE.md` and -`CONTRIBUTING.md` files mention that PRs are not directly accepted to the repo. +6. 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. 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. - -8. NOTE: Do not edit go.mod or go.sum in the new repo (staging/src/k8s.io//) manually. Run the following instead: +7. NOTE: Do not edit go.mod or go.sum in the new repo (staging/src/k8s.io//) manually. Run the following instead: ``` ./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 1. Create an [issue](https://github.com/kubernetes/org/issues/new?template=repo-create.md) diff --git a/staging/src/k8s.io/api/testdata/README.md b/staging/src/k8s.io/api/testdata/README.md index f6c9277215e..8989ed7ca9c 100644 --- a/staging/src/k8s.io/api/testdata/README.md +++ b/staging/src/k8s.io/api/testdata/README.md @@ -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: ```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.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: ```sh -cd vendor/k8s.io/api/testdata/v1.14.0/ +cd staging/src/k8s.io/api/testdata/v1.14.0/ diff -u \ <(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) @@ -138,4 +138,4 @@ diff -u \ > } > 2 { > 1: "\347\210\237\302\274\302\252ov\351\210\266" -> ``` \ No newline at end of file +> ``` diff --git a/staging/src/k8s.io/apiextensions-apiserver/hack/build-image.sh b/staging/src/k8s.io/apiextensions-apiserver/hack/build-image.sh index 8b7ef99c4f3..12814ebbc6f 100755 --- a/staging/src/k8s.io/apiextensions-apiserver/hack/build-image.sh +++ b/staging/src/k8s.io/apiextensions-apiserver/hack/build-image.sh @@ -23,11 +23,11 @@ source "${KUBE_ROOT}/hack/lib/util.sh" # Register function to be called on EXIT to remove generated binary. 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 -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 docker build -t apiextensions-apiserver:latest ./artifacts/simple-image popd diff --git a/staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/mutating/plugin_test.go b/staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/mutating/plugin_test.go index f776505a7d5..5da27169bfc 100644 --- a/staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/mutating/plugin_test.go +++ b/staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/mutating/plugin_test.go @@ -42,7 +42,7 @@ func BenchmarkAdmit(b *testing.B) { if len(testServerURL) == 0 { 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("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.StartTLS() defer testServer.Close() diff --git a/staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/validating/plugin_test.go b/staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/validating/plugin_test.go index b9ea6662d9c..a7c8e1dbedc 100644 --- a/staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/validating/plugin_test.go +++ b/staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/validating/plugin_test.go @@ -38,7 +38,7 @@ func BenchmarkValidate(b *testing.B) { if len(testServerURL) == 0 { 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("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.StartTLS() defer testServer.Close() diff --git a/staging/src/k8s.io/client-go/restmapper/shortcut.go b/staging/src/k8s.io/client-go/restmapper/shortcut.go index ca517a01d4d..0afc8689d7a 100644 --- a/staging/src/k8s.io/client-go/restmapper/shortcut.go +++ b/staging/src/k8s.io/client-go/restmapper/shortcut.go @@ -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 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 - // 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 // read Kind to the user or an error. gvk, err := e.RESTMapper.KindFor(e.expandResourceShortcut(resource)) diff --git a/staging/src/k8s.io/code-generator/cmd/applyconfiguration-gen/generators/packages.go b/staging/src/k8s.io/code-generator/cmd/applyconfiguration-gen/generators/packages.go index e5bb2fae301..520b73f6533 100644 --- a/staging/src/k8s.io/code-generator/cmd/applyconfiguration-gen/generators/packages.go +++ b/staging/src/k8s.io/code-generator/cmd/applyconfiguration-gen/generators/packages.go @@ -158,9 +158,6 @@ func friendlyName(name string) string { func typeName(t *types.Type) string { 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) } diff --git a/staging/src/k8s.io/code-generator/cmd/client-gen/generators/client_generator.go b/staging/src/k8s.io/code-generator/cmd/client-gen/generators/client_generator.go index a1c9c4edb3f..fc1ba081c0b 100644 --- a/staging/src/k8s.io/code-generator/cmd/client-gen/generators/client_generator.go +++ b/staging/src/k8s.io/code-generator/cmd/client-gen/generators/client_generator.go @@ -26,10 +26,8 @@ import ( "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/util" - "k8s.io/code-generator/cmd/client-gen/path" clientgentypes "k8s.io/code-generator/cmd/client-gen/types" codegennamer "k8s.io/code-generator/pkg/namer" - genutil "k8s.io/code-generator/pkg/util" "k8s.io/gengo/v2/args" "k8s.io/gengo/v2/generator" "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. changes := make(map[clientgentypes.GroupVersion]clientgentypes.GroupVersion) 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 { newGV := clientgentypes.GroupVersion{ Group: clientgentypes.Group(override[0]), @@ -324,7 +322,7 @@ func sanitizePackagePaths(context *generator.Context, ca *clientgenargs.CustomAr for j := range pkg.Versions { ver := &pkg.Versions[j] input := ver.Package - p := context.Universe[path.Vendorless(input)] + p := context.Universe[input] if p == nil || p.Name == "" { pkgs, err := context.FindPackages(input) if err != nil { @@ -362,7 +360,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat gvToTypes := map[clientgentypes.GroupVersion][]*types.Type{} groupGoNames := make(map[clientgentypes.GroupVersion]string) 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 // 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]) } - // Package are indexed with the vendor prefix stripped for n, t := range p.Types { // filter out types which are not included in user specified overrides. typesOverride, ok := includedTypesOverrides[gv] diff --git a/staging/src/k8s.io/code-generator/cmd/client-gen/generators/generator_for_group.go b/staging/src/k8s.io/code-generator/cmd/client-gen/generators/generator_for_group.go index c5a75676c73..08fcac47897 100644 --- a/staging/src/k8s.io/code-generator/cmd/client-gen/generators/generator_for_group.go +++ b/staging/src/k8s.io/code-generator/cmd/client-gen/generators/generator_for_group.go @@ -25,7 +25,6 @@ import ( "k8s.io/gengo/v2/types" "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. @@ -83,7 +82,7 @@ func (g *genGroup) GenerateType(c *generator.Context, t *types.Type, w io.Writer groupName = "" } // 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 { 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"}), "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"}), - "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(groupClientTemplate, m) diff --git a/staging/src/k8s.io/code-generator/cmd/client-gen/generators/scheme/generator_for_scheme.go b/staging/src/k8s.io/code-generator/cmd/client-gen/generators/scheme/generator_for_scheme.go index 8bfe7f625be..eae3a3ae94b 100644 --- a/staging/src/k8s.io/code-generator/cmd/client-gen/generators/scheme/generator_for_scheme.go +++ b/staging/src/k8s.io/code-generator/cmd/client-gen/generators/scheme/generator_for_scheme.go @@ -23,7 +23,6 @@ import ( "path/filepath" "strings" - "k8s.io/code-generator/cmd/client-gen/path" clientgentypes "k8s.io/code-generator/cmd/client-gen/types" "k8s.io/gengo/v2/generator" "k8s.io/gengo/v2/namer" @@ -70,10 +69,10 @@ func (g *GenScheme) Imports(c *generator.Context) (imports []string) { } 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 } 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)) } } } diff --git a/staging/src/k8s.io/code-generator/cmd/client-gen/path/path.go b/staging/src/k8s.io/code-generator/cmd/client-gen/path/path.go deleted file mode 100644 index 19b269bdf28..00000000000 --- a/staging/src/k8s.io/code-generator/cmd/client-gen/path/path.go +++ /dev/null @@ -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 -} diff --git a/staging/src/k8s.io/code-generator/cmd/conversion-gen/generators/conversion.go b/staging/src/k8s.io/code-generator/cmd/conversion-gen/generators/conversion.go index a85117ae849..6dfd5901ec6 100644 --- a/staging/src/k8s.io/code-generator/cmd/conversion-gen/generators/conversion.go +++ b/staging/src/k8s.io/code-generator/cmd/conversion-gen/generators/conversion.go @@ -33,7 +33,6 @@ import ( "k8s.io/klog/v2" 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. @@ -273,19 +272,9 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat } // Make sure explicit peer-packages are added. - var sanitizedPeerPkgs []string if customArgs, ok := arguments.CustomArgs.(*conversionargs.CustomArgs); ok { - all := append(customArgs.BasePeerDirs, customArgs.ExtraPeerDirs...) - for _, pkg := range all { - // 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 { + peers := append(customArgs.BasePeerDirs, customArgs.ExtraPeerDirs...) + if expanded, err := context.FindPackages(peers...); err != nil { klog.Fatalf("cannot find peer packages: %v", err) } else { otherPkgs = append(otherPkgs, expanded...) @@ -326,7 +315,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat pkg := context.Universe[i] // typesPkg is where the versioned types are defined. Sometimes it is // 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 // Add conversion and defaulting functions. @@ -341,29 +330,15 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat 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, &generator.DefaultPackage{ PackageName: filepath.Base(pkg.Path), - PackagePath: path, + PackagePath: pkg.Path, Source: pkg.SourcePath, // output pkg is the same as the input HeaderText: header, GeneratorFunc: func(c *generator.Context) (generators []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 { diff --git a/staging/src/k8s.io/code-generator/cmd/informer-gen/generators/packages.go b/staging/src/k8s.io/code-generator/cmd/informer-gen/generators/packages.go index a10491e5152..7f785e2bdff 100644 --- a/staging/src/k8s.io/code-generator/cmd/informer-gen/generators/packages.go +++ b/staging/src/k8s.io/code-generator/cmd/informer-gen/generators/packages.go @@ -122,7 +122,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat internalGroupVersions := make(map[string]clientgentypes.GroupVersions) groupGoNames := make(map[string]string) for _, inputDir := range arguments.InputDirs { - p := context.Universe.Package(genutil.Vendorless(inputDir)) + p := context.Universe.Package(inputDir) objectMeta, internal, err := objectMetaForPackage(p) if err != nil { diff --git a/staging/src/k8s.io/code-generator/cmd/prerelease-lifecycle-gen/prerelease-lifecycle-generators/status.go b/staging/src/k8s.io/code-generator/cmd/prerelease-lifecycle-gen/prerelease-lifecycle-generators/status.go index 8acd5fb9c2e..53c2c3ca114 100644 --- a/staging/src/k8s.io/code-generator/cmd/prerelease-lifecycle-gen/prerelease-lifecycle-generators/status.go +++ b/staging/src/k8s.io/code-generator/cmd/prerelease-lifecycle-gen/prerelease-lifecycle-generators/status.go @@ -230,24 +230,10 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat } 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, &generator.DefaultPackage{ PackageName: strings.Split(filepath.Base(pkg.Path), ".")[0], - PackagePath: path, + PackagePath: pkg.Path, Source: pkg.SourcePath, // output pkg is the same as the input HeaderText: header, GeneratorFunc: func(c *generator.Context) (generators []generator.Generator) { diff --git a/staging/src/k8s.io/code-generator/pkg/util/build.go b/staging/src/k8s.io/code-generator/pkg/util/build.go deleted file mode 100644 index 1cf4bbfcb92..00000000000 --- a/staging/src/k8s.io/code-generator/pkg/util/build.go +++ /dev/null @@ -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 -} diff --git a/staging/src/k8s.io/component-base/metrics/testutil/promlint.go b/staging/src/k8s.io/component-base/metrics/testutil/promlint.go index 4c537be225b..550de013818 100644 --- a/staging/src/k8s.io/component-base/metrics/testutil/promlint.go +++ b/staging/src/k8s.io/component-base/metrics/testutil/promlint.go @@ -30,13 +30,13 @@ import ( // 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. 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 - // 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' - // 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 "authentication_attempts", // counter metrics should have "_total" suffix diff --git a/staging/src/k8s.io/kube-aggregator/hack/build-image.sh b/staging/src/k8s.io/kube-aggregator/hack/build-image.sh index cae43ecac10..f9a87dbf120 100755 --- a/staging/src/k8s.io/kube-aggregator/hack/build-image.sh +++ b/staging/src/k8s.io/kube-aggregator/hack/build-image.sh @@ -23,11 +23,11 @@ source "${KUBE_ROOT}/hack/lib/util.sh" # Register function to be called on EXIT to remove generated binary. 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 -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 docker build -t kube-aggregator:latest ./artifacts/simple-image -popd \ No newline at end of file +popd diff --git a/staging/src/k8s.io/sample-apiserver/hack/build-image.sh b/staging/src/k8s.io/sample-apiserver/hack/build-image.sh index 1402e366a9a..03a82af3820 100755 --- a/staging/src/k8s.io/sample-apiserver/hack/build-image.sh +++ b/staging/src/k8s.io/sample-apiserver/hack/build-image.sh @@ -23,11 +23,11 @@ source "${KUBE_ROOT}/hack/lib/util.sh" # Register function to be called on EXIT to remove generated binary. 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 -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 docker build -t kube-sample-apiserver:latest ./artifacts/simple-image popd