From d98b2dd2d62607fd2dc888e8cb2e81ae23c8cde6 Mon Sep 17 00:00:00 2001 From: Nabarun Pal Date: Tue, 1 Jun 2021 17:20:09 +0530 Subject: [PATCH] generated: remove usage of go-bindata Signed-off-by: Nabarun Pal --- hack/generate-bindata.sh | 65 ----------------------- test/e2e/e2e_test.go | 8 --- test/e2e/framework/testfiles/testfiles.go | 31 ----------- test/e2e/generated/gobindata_util.go | 34 ------------ test/e2e/generated/main.go | 19 ------- 5 files changed, 157 deletions(-) delete mode 100755 hack/generate-bindata.sh delete mode 100644 test/e2e/generated/gobindata_util.go delete mode 100644 test/e2e/generated/main.go diff --git a/hack/generate-bindata.sh b/hack/generate-bindata.sh deleted file mode 100755 index 2e7a234e5be..00000000000 --- a/hack/generate-bindata.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2016 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. - -set -o errexit -set -o pipefail -set -o nounset - -KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. -export KUBE_ROOT -source "${KUBE_ROOT}/hack/lib/init.sh" -source "${KUBE_ROOT}/hack/lib/logging.sh" - -if [[ ! -d "${KUBE_ROOT}/pkg" ]]; then - echo "${KUBE_ROOT}/pkg not detected. This script should be run from a location where the source dirs are available." - exit 1 -fi - -# Ensure that we find the binaries we build before anything else. -export GOBIN="${KUBE_OUTPUT_BINPATH}" -PATH="${GOBIN}:${PATH}" - -# Install tools we need, but only from vendor/... -go install k8s.io/kubernetes/vendor/github.com/go-bindata/go-bindata/go-bindata - -# run the generation from the root directory for stable output -pushd "${KUBE_ROOT}" >/dev/null - -# These are files for e2e tests. -BINDATA_OUTPUT="test/e2e/generated/bindata.go" -go-bindata -nometadata -o "${BINDATA_OUTPUT}.tmp" -pkg generated \ - -ignore .jpg -ignore .png -ignore .md \ - "test/conformance/testdata/..." \ - "test/e2e/testing-manifests/..." \ - "test/e2e_node/testing-manifests/..." \ - "test/images/..." \ - "test/fixtures/..." - -gofmt -s -w "${BINDATA_OUTPUT}.tmp" - -# Here we compare and overwrite only if different to avoid updating the -# timestamp and triggering a rebuild. The 'cat' redirect trick to preserve file -# permissions of the target file. -if ! cmp -s "${BINDATA_OUTPUT}.tmp" "${BINDATA_OUTPUT}" ; then - cat "${BINDATA_OUTPUT}.tmp" > "${BINDATA_OUTPUT}" - V=2 kube::log::info "Generated bindata file : ${BINDATA_OUTPUT} has $(wc -l ${BINDATA_OUTPUT}) lines of lovely automated artifacts" -else - V=2 kube::log::info "No changes in generated bindata file: ${BINDATA_OUTPUT}" -fi - -rm -f "${BINDATA_OUTPUT}.tmp" - -popd >/dev/null diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index 88cc6f58c63..3d6bb5ceceb 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -37,7 +37,6 @@ import ( "k8s.io/kubernetes/test/e2e/framework" "k8s.io/kubernetes/test/e2e/framework/config" "k8s.io/kubernetes/test/e2e/framework/testfiles" - "k8s.io/kubernetes/test/e2e/generated" e2etestingmanifests "k8s.io/kubernetes/test/e2e/testing-manifests" testfixtures "k8s.io/kubernetes/test/fixtures" "k8s.io/kubernetes/test/utils/image" @@ -88,13 +87,6 @@ func TestMain(m *testing.M) { os.Exit(0) } - // Enable bindata file lookup as fallback. - // TODO: To be removed once all data sources have been moved to embeds. - testfiles.AddFileSource(testfiles.BindataFileSource{ - Asset: generated.Asset, - AssetNames: generated.AssetNames, - }) - // Enable embedded FS file lookup as fallback testfiles.AddFileSource(e2etestingmanifests.GetE2ETestingManifestsFS()) testfiles.AddFileSource(testfixtures.GetTestFixturesFS()) diff --git a/test/e2e/framework/testfiles/testfiles.go b/test/e2e/framework/testfiles/testfiles.go index 2d45d9fd119..155a06f81bd 100644 --- a/test/e2e/framework/testfiles/testfiles.go +++ b/test/e2e/framework/testfiles/testfiles.go @@ -33,7 +33,6 @@ import ( "os" "path" "path/filepath" - "sort" "strings" ) @@ -149,36 +148,6 @@ func (r RootFileSource) DescribeFiles() string { return description } -// BindataFileSource handles files stored in a package generated with bindata. -type BindataFileSource struct { - Asset func(string) ([]byte, error) - AssetNames func() []string -} - -// ReadTestFile looks for an asset with the given path. -func (b BindataFileSource) ReadTestFile(filePath string) ([]byte, error) { - fileBytes, err := b.Asset(filePath) - if err != nil { - // It would be nice to have a better way to detect - // "not found" errors :-/ - if strings.HasSuffix(err.Error(), "not found") { - return nil, nil - } - } - return fileBytes, nil -} - -// DescribeFiles explains about gobindata and then lists all available files. -func (b BindataFileSource) DescribeFiles() string { - var lines []string - lines = append(lines, "The following files are built into the test executable via gobindata. For questions on maintaining gobindata, contact the sig-testing group.") - assets := b.AssetNames() - sort.Strings(assets) - lines = append(lines, assets...) - description := strings.Join(lines, "\n ") - return description -} - // EmbeddedFileSource handles files stored in a package generated with bindata. type EmbeddedFileSource struct { EmbeddedFS embed.FS diff --git a/test/e2e/generated/gobindata_util.go b/test/e2e/generated/gobindata_util.go deleted file mode 100644 index 474eaaa028e..00000000000 --- a/test/e2e/generated/gobindata_util.go +++ /dev/null @@ -1,34 +0,0 @@ -/* -Copyright 2016 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 generated - -import "k8s.io/klog/v2" - -/* -ReadOrDie reads a file from gobindata. -Relies heavily on the successful generation of build artifacts as per the go:generate directives above. -*/ -func ReadOrDie(filePath string) []byte { - - fileBytes, err := Asset(filePath) - if err != nil { - gobindataMsg := "An error occurred, possibly gobindata doesn't know about the file you're opening. For questions on maintaining gobindata, contact the sig-testing group." - klog.Infof("Available gobindata files: %v ", AssetNames()) - klog.Fatalf("Failed opening %v , with error %v. %v.", filePath, err, gobindataMsg) - } - return fileBytes -} diff --git a/test/e2e/generated/main.go b/test/e2e/generated/main.go deleted file mode 100644 index 86ca01972a8..00000000000 --- a/test/e2e/generated/main.go +++ /dev/null @@ -1,19 +0,0 @@ -/* -Copyright 2015 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 generated - -// No code is needed here. This is a stub for compilation purposes.