-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Description Update deps to use k8s 1.22 Update controller-tools to 0.7.0 Update sigs.k8s.io/controller-runtime to 0.10.0 Update ENV TEST to 1.22
- Loading branch information
1 parent
9817db7
commit 017e13c
Showing
118 changed files
with
2,056 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
Copyright 2021 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 v3 | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"path/filepath" | ||
"strings" | ||
|
||
"sigs.k8s.io/kubebuilder/v3/pkg/plugin/util" | ||
"sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v3/scaffolds" | ||
"sigs.k8s.io/kubebuilder/v3/pkg/utils" | ||
) | ||
|
||
// Update the makefile to allow generate CRDs/Webhooks with v1beta1 to ensure backwards compatibility | ||
// nolint:lll,gosec | ||
func applyScaffoldCustomizationsForVbeta1() error { | ||
makefilePath := filepath.Join("Makefile") | ||
bs, err := ioutil.ReadFile(makefilePath) | ||
if err != nil { | ||
return err | ||
} | ||
if !strings.Contains(string(bs), "CRD_OPTIONS") { | ||
const makefileTarget = `$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases` | ||
const makefileTargetForV1beta1 = `$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases` | ||
|
||
if err := utils.ReplaceInFile("Makefile", makefileTarget, makefileTargetForV1beta1); err != nil { | ||
fmt.Printf("unable to update the makefile to allow the usage of v1beta1: %s", err) | ||
} | ||
|
||
const makegentarget = ` | ||
manifests: controller-gen` | ||
const makegenV1beta1Options = `# Produce CRDs that work back to Kubernetes 1.11 (no version conversion) | ||
CRD_OPTIONS ?= "crd:crdVersions={v1beta1},trivialVersions=true,preserveUnknownFields=false" | ||
manifests: controller-gen` | ||
|
||
if err := utils.ReplaceInFile("Makefile", makegentarget, makegenV1beta1Options); err != nil { | ||
fmt.Printf("unable to update the makefile to allow the usage of v1beta1: %s", err) | ||
} | ||
|
||
// latest version of controller-tools where v1beta1 is supported | ||
const controllerToolsVersionForVBeta1 = "v0.6.2" | ||
if err := utils.ReplaceInFile("Makefile", | ||
fmt.Sprintf("controller-gen@%s", | ||
scaffolds.ControllerToolsVersion), | ||
fmt.Sprintf("controller-gen@%s", | ||
controllerToolsVersionForVBeta1)); err != nil { | ||
fmt.Printf("unable to update the makefile to allow the usage of v1beta1: %s", err) | ||
} | ||
|
||
if err := utils.ReplaceInFile("Makefile", | ||
"ENVTEST_K8S_VERSION = 1.22", | ||
"ENVTEST_K8S_VERSION = 1.21"); err != nil { | ||
fmt.Printf("unable to update the makefile to allow the usage of v1beta1: %s", err) | ||
} | ||
|
||
// latest version of controller-runtime where v1beta1 is supported | ||
const controllerRuntimeVersionForVBeta1 = "v0.9.0" | ||
if err := utils.ReplaceInFile("Makefile", | ||
"setup-envtest@latest", | ||
fmt.Sprintf("setup-envtest@%s", | ||
controllerRuntimeVersionForVBeta1)); err != nil { | ||
fmt.Printf("unable to update the makefile to allow the usage of v1beta1: %s", err) | ||
} | ||
|
||
err := util.RunCmd("Downgrade k8s.io/api", "go", "get", "-d", "k8s.io/[email protected]") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = util.RunCmd("Downgrade sigs.k8s.io/controller-runtime", "go", "get", "-d", fmt.Sprintf("sigs.k8s.io/controller-runtime@%s", controllerRuntimeVersionForVBeta1)) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = util.RunCmd("Update dependencies", "go", "mod", "tidy") | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.