From 319b0d7bcb1af05bb5d6e1b760a3c13e251c1e0e Mon Sep 17 00:00:00 2001 From: "Adam D. Cornett" Date: Tue, 5 Nov 2024 14:29:33 -0700 Subject: [PATCH] removing env-test plugin since go/v2 scaffolding support has been removed Signed-off-by: Adam D. Cornett --- internal/plugins/envtest/v1/init.go | 76 --------------------------- internal/plugins/envtest/v1/plugin.go | 48 ----------------- 2 files changed, 124 deletions(-) delete mode 100644 internal/plugins/envtest/v1/init.go delete mode 100644 internal/plugins/envtest/v1/plugin.go diff --git a/internal/plugins/envtest/v1/init.go b/internal/plugins/envtest/v1/init.go deleted file mode 100644 index 53e5d3dca3..0000000000 --- a/internal/plugins/envtest/v1/init.go +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2021 The Operator-SDK 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 v1 - -import ( - "fmt" - "os" - "strings" - - "github.com/spf13/afero" - "sigs.k8s.io/kubebuilder/v4/pkg/config" - "sigs.k8s.io/kubebuilder/v4/pkg/machinery" - "sigs.k8s.io/kubebuilder/v4/pkg/plugin" -) - -const ( - // controllerRuntimeVersion version to be used to download the envtest setup script - controllerRuntimeVersion = "v0.6.3" - - filePath = "Makefile" -) - -var _ plugin.InitSubcommand = &initSubcommand{} - -type initSubcommand struct { - config config.Config -} - -func (s *initSubcommand) InjectConfig(c config.Config) error { - s.config = c - - return nil -} - -func (s *initSubcommand) Scaffold(fs machinery.Filesystem) error { - makefileBytes, err := afero.ReadFile(fs.FS, filePath) - if err != nil { - return err - } - - makefileBytes = []byte(strings.Replace(string(makefileBytes), oldMakefileTestTarget, fmt.Sprintf(makefileTestTarget, controllerRuntimeVersion), 1)) - - var mode os.FileMode = 0644 - if info, err := fs.FS.Stat(filePath); err == nil { - mode = info.Mode() - } - if err := os.WriteFile(filePath, makefileBytes, mode); err != nil { - return fmt.Errorf("error updating Makefile: %w", err) - } - - return nil -} - -const ( - oldMakefileTestTarget = `# Run tests -test: manifests generate fmt vet - go test ./... -coverprofile cover.out` - makefileTestTarget = `# Run tests -ENVTEST_ASSETS_DIR = $(shell pwd)/testbin -test: manifests generate fmt vet - mkdir -p $(ENVTEST_ASSETS_DIR) - test -f $(ENVTEST_ASSETS_DIR)/setup-envtest.sh || curl -sSLo $(ENVTEST_ASSETS_DIR)/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/%s/hack/setup-envtest.sh - source $(ENVTEST_ASSETS_DIR)/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test ./... -coverprofile cover.out` -) diff --git a/internal/plugins/envtest/v1/plugin.go b/internal/plugins/envtest/v1/plugin.go deleted file mode 100644 index b8825e9fbd..0000000000 --- a/internal/plugins/envtest/v1/plugin.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2021 The Operator-SDK 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. - -// This plugin replaces the test target of go/v2 plugins to match that of go/v3. -// More info: https://github.com/kubernetes-sigs/kubebuilder/pull/1711 -package v1 - -import ( - "sigs.k8s.io/kubebuilder/v4/pkg/config" - cfgv3 "sigs.k8s.io/kubebuilder/v4/pkg/config/v3" - "sigs.k8s.io/kubebuilder/v4/pkg/plugin" - - "github.com/operator-framework/operator-sdk/internal/plugins" -) - -const pluginName = "envtest" + plugins.DefaultNameQualifier - -var ( - pluginVersion = plugin.Version{Number: 1} - supportedProjectVersions = []config.Version{cfgv3.Version} -) - -var ( - _ plugin.Plugin = Plugin{} - _ plugin.Init = Plugin{} -) - -type Plugin struct { - initSubcommand -} - -func (Plugin) Name() string { return pluginName } -func (Plugin) Version() plugin.Version { return pluginVersion } -func (Plugin) SupportedProjectVersions() []config.Version { return supportedProjectVersions } -func (p Plugin) GetInitSubcommand() plugin.InitSubcommand { return &p.initSubcommand } - -type Config struct{}