Repository: helm/helm
Pull request #13458 (2024-11-17 16:11:36)

#13449 Resolves: Replacing NewSimpleClientSet to NewClientSet due to deprecation
<!--  Thanks for sending a pull request!  Here are some tips for you:
1. Make sure to read the Contributing Guide before submitting your PR: https://github.com/helm/helm/blob/main/CONTRIBUTING.md
2. If this PR closes another issue, add 'closes #13449' somewhere in the PR summary. GitHub will automatically close that issue when this PR gets merged. Alternatively, adding 'refs #13449' will not close the issue, but help provide the reviewer more context.-->

**What this PR does / why we need it**:

NewSimpleClientSet is deprecated, This PR will resolve it.

**Special notes for your reviewer**:

**If applicable**:
- [ ] this PR contains user facing changes (the `docs needed` label should be applied if so)
- [ ] this PR contains unit tests
- [ ] this PR has been tested for backwards compatibility



Patch:
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 0c2f88453..0c9e5affe 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -11,10 +11,6 @@ vulnerability_, please email a report to
 [cncf-helm-security@lists.cncf.io](mailto:cncf-helm-security@lists.cncf.io). This will give us a
 chance to try to fix the issue before it is exploited in the wild.
 
-## Helm v3 and v4
-
-Helm v4 is currently under development on the `main` branch. During the development of Helm v4 and for some time after its released, Helm v3 will continue to be supported and developed on the `dev-v3` branch. Helm v3 will continue to get bug fixes and updates for new Kubernetes releases. Helm v4 is where new features and major changes will happen. For features to be backported to Helm v3, an exception will be needed. Bugs should first be fixed on Helm v4 and then backported to Helm v3.
-
 ## Sign Your Work
 
 The sign-off is a simple line at the end of the explanation for a commit. All commits need to be
diff --git a/README.md b/README.md
index 2488147c7..294a03d46 100644
--- a/README.md
+++ b/README.md
@@ -56,8 +56,6 @@ Get started with the [Quick Start guide](https://helm.sh/docs/intro/quickstart/)
 
 The [Helm roadmap uses GitHub milestones](https://github.com/helm/helm/milestones) to track the progress of the project.
 
-The development of Helm v4 is currently happening on the `main` branch while the development of Helm v3, the stable branch, is happening on the `dev-v3` branch. Changes should be made to the `main` branch prior to being added to the `dev-v3` branch so that all changes are carried along to Helm v4.
-
 ## Community, discussion, contribution, and support
 
 You can reach the Helm community and developers via the following channels:
diff --git a/cmd/helm/install.go b/cmd/helm/install.go
index 1e451486b..23ff29d95 100644
--- a/cmd/helm/install.go
+++ b/cmd/helm/install.go
@@ -184,7 +184,7 @@ func addInstallFlags(cmd *cobra.Command, f *pflag.FlagSet, client *action.Instal
 	f.Lookup("dry-run").NoOptDefVal = "client"
 	f.BoolVar(&client.Force, "force", false, "force resource updates through a replacement strategy")
 	f.BoolVar(&client.DisableHooks, "no-hooks", false, "prevent hooks from running during install")
-	f.BoolVar(&client.Replace, "replace", false, "reuse the given name, only if that name is a deleted release which remains in the history. This is unsafe in production")
+	f.BoolVar(&client.Replace, "replace", false, "re-use the given name, only if that name is a deleted release which remains in the history. This is unsafe in production")
 	f.DurationVar(&client.Timeout, "timeout", 300*time.Second, "time to wait for any individual Kubernetes operation (like Jobs for hooks)")
 	f.BoolVar(&client.Wait, "wait", false, "if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment, StatefulSet, or ReplicaSet are in a ready state before marking the release as successful. It will wait for as long as --timeout")
 	f.BoolVar(&client.WaitForJobs, "wait-for-jobs", false, "if set and --wait enabled, will wait until all Jobs have been completed before marking the release as successful. It will wait for as long as --timeout")
diff --git a/pkg/action/action.go b/pkg/action/action.go
index 45f1a14e2..fe91de048 100644
--- a/pkg/action/action.go
+++ b/pkg/action/action.go
@@ -394,8 +394,8 @@ func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namesp
 		if cfg.Releases != nil {
 			if mem, ok := cfg.Releases.Driver.(*driver.Memory); ok {
 				// This function can be called more than once (e.g., helm list --all-namespaces).
-				// If a memory driver was already initialized, reuse it but set the possibly new namespace.
-				// We reuse it in case some releases where already created in the existing memory driver.
+				// If a memory driver was already initialized, re-use it but set the possibly new namespace.
+				// We re-use it in case some releases where already created in the existing memory driver.
 				d = mem
 			}
 		}
diff --git a/pkg/action/install.go b/pkg/action/install.go
index 6869b268b..7ca40c88a 100644
--- a/pkg/action/install.go
+++ b/pkg/action/install.go
@@ -450,7 +450,7 @@ func (i *Install) performInstall(rel *release.Release, toBeAdopted kube.Resource
 	}
 
 	// At this point, we can do the install. Note that before we were detecting whether to
-	// do an update, but it's not clear whether we WANT to do an update if the reuse is set
+	// do an update, but it's not clear whether we WANT to do an update if the re-use is set
 	// to true, since that is basically an upgrade operation.
 	if len(toBeAdopted) == 0 && len(resources) > 0 {
 		_, err = i.cfg.KubeClient.Create(resources)
@@ -544,7 +544,7 @@ func (i *Install) availableName() error {
 	if st := rel.Info.Status; i.Replace && (st == release.StatusUninstalled || st == release.StatusFailed) {
 		return nil
 	}
-	return errors.New("cannot reuse a name that is still in use")
+	return errors.New("cannot re-use a name that is still in use")
 }
 
 // createRelease creates a new release object
@@ -574,7 +574,7 @@ func (i *Install) recordRelease(r *release.Release) error {
 
 // replaceRelease replaces an older release with this one
 //
-// This allows us to reuse names by superseding an existing release with a new one
+// This allows us to re-use names by superseding an existing release with a new one
 func (i *Install) replaceRelease(rel *release.Release) error {
 	hist, err := i.cfg.Releases.History(rel.Name)
 	if err != nil || len(hist) == 0 {
diff --git a/pkg/action/upgrade.go b/pkg/action/upgrade.go
index 5002406ca..a08d68495 100644
--- a/pkg/action/upgrade.go
+++ b/pkg/action/upgrade.go
@@ -83,7 +83,7 @@ type Upgrade struct {
 	Force bool
 	// ResetValues will reset the values to the chart's built-ins rather than merging with existing.
 	ResetValues bool
-	// ReuseValues will reuse the user's last supplied values.
+	// ReuseValues will re-use the user's last supplied values.
 	ReuseValues bool
 	// ResetThenReuseValues will reset the values to the chart's built-ins then merge with user's last supplied values.
 	ResetThenReuseValues bool


Test patch:
diff --git a/cmd/helm/install_test.go b/cmd/helm/install_test.go
index 682b25164..3709c393e 100644
--- a/cmd/helm/install_test.go
+++ b/cmd/helm/install_test.go
@@ -96,7 +96,7 @@ func TestInstall(t *testing.T) {
 			golden:    "output/install-no-args.txt",
 			wantError: true,
 		},
-		// Install, reuse name
+		// Install, re-use name
 		{
 			name:   "install and replace release",
 			cmd:    "install aeneas testdata/testcharts/empty --replace",
diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go
index 149eb85b1..3bf64c3e0 100644
--- a/pkg/action/action_test.go
+++ b/pkg/action/action_test.go
@@ -344,7 +344,7 @@ func TestConfiguration_Init(t *testing.T) {
 }
 
 func TestGetVersionSet(t *testing.T) {
-	client := fakeclientset.NewSimpleClientset()
+	client := fakeclientset.NewClientset()
 
 	vs, err := GetVersionSet(client.Discovery())
 	if err != nil {
diff --git a/pkg/kube/ready_test.go b/pkg/kube/ready_test.go
index 14bf8588b..32840fb6e 100644
--- a/pkg/kube/ready_test.go
+++ b/pkg/kube/ready_test.go
@@ -58,7 +58,7 @@ func Test_ReadyChecker_IsReady_Pod(t *testing.T) {
 		{
 			name: "IsReady Pod",
 			fields: fields{
-				client:        fake.NewSimpleClientset(),
+				client:        fake.NewClientset(),
 				log:           func(string, ...interface{}) {},
 				checkJobs:     true,
 				pausedAsReady: false,
@@ -74,7 +74,7 @@ func Test_ReadyChecker_IsReady_Pod(t *testing.T) {
 		{
 			name: "IsReady Pod returns error",
 			fields: fields{
-				client:        fake.NewSimpleClientset(),
+				client:        fake.NewClientset(),
 				log:           func(string, ...interface{}) {},
 				checkJobs:     true,
 				pausedAsReady: false,
@@ -134,7 +134,7 @@ func Test_ReadyChecker_IsReady_Job(t *testing.T) {
 		{
 			name: "IsReady Job error while getting job",
 			fields: fields{
-				client:        fake.NewSimpleClientset(),
+				client:        fake.NewClientset(),
 				log:           func(string, ...interface{}) {},
 				checkJobs:     true,
 				pausedAsReady: false,
@@ -150,7 +150,7 @@ func Test_ReadyChecker_IsReady_Job(t *testing.T) {
 		{
 			name: "IsReady Job",
 			fields: fields{
-				client:        fake.NewSimpleClientset(),
+				client:        fake.NewClientset(),
 				log:           func(string, ...interface{}) {},
 				checkJobs:     true,
 				pausedAsReady: false,
@@ -210,7 +210,7 @@ func Test_ReadyChecker_IsReady_Deployment(t *testing.T) {
 		{
 			name: "IsReady Deployments error while getting current Deployment",
 			fields: fields{
-				client:        fake.NewSimpleClientset(),
+				client:        fake.NewClientset(),
 				log:           func(string, ...interface{}) {},
 				checkJobs:     true,
 				pausedAsReady: false,
@@ -227,7 +227,7 @@ func Test_ReadyChecker_IsReady_Deployment(t *testing.T) {
 		{
 			name: "IsReady Deployments", //TODO fix this one
 			fields: fields{
-				client:        fake.NewSimpleClientset(),
+				client:        fake.NewClientset(),
 				log:           func(string, ...interface{}) {},
 				checkJobs:     true,
 				pausedAsReady: false,
@@ -291,7 +291,7 @@ func Test_ReadyChecker_IsReady_PersistentVolumeClaim(t *testing.T) {
 		{
 			name: "IsReady PersistentVolumeClaim",
 			fields: fields{
-				client:        fake.NewSimpleClientset(),
+				client:        fake.NewClientset(),
 				log:           func(string, ...interface{}) {},
 				checkJobs:     true,
 				pausedAsReady: false,
@@ -307,7 +307,7 @@ func Test_ReadyChecker_IsReady_PersistentVolumeClaim(t *testing.T) {
 		{
 			name: "IsReady PersistentVolumeClaim with error",
 			fields: fields{
-				client:        fake.NewSimpleClientset(),
+				client:        fake.NewClientset(),
 				log:           func(string, ...interface{}) {},
 				checkJobs:     true,
 				pausedAsReady: false,
@@ -366,7 +366,7 @@ func Test_ReadyChecker_IsReady_Service(t *testing.T) {
 		{
 			name: "IsReady Service",
 			fields: fields{
-				client:        fake.NewSimpleClientset(),
+				client:        fake.NewClientset(),
 				log:           func(string, ...interface{}) {},
 				checkJobs:     true,
 				pausedAsReady: false,
@@ -382,7 +382,7 @@ func Test_ReadyChecker_IsReady_Service(t *testing.T) {
 		{
 			name: "IsReady Service with error",
 			fields: fields{
-				client:        fake.NewSimpleClientset(),
+				client:        fake.NewClientset(),
 				log:           func(string, ...interface{}) {},
 				checkJobs:     true,
 				pausedAsReady: false,
@@ -441,7 +441,7 @@ func Test_ReadyChecker_IsReady_DaemonSet(t *testing.T) {
 		{
 			name: "IsReady DaemonSet",
 			fields: fields{
-				client:        fake.NewSimpleClientset(),
+				client:        fake.NewClientset(),
 				log:           func(string, ...interface{}) {},
 				checkJobs:     true,
 				pausedAsReady: false,
@@ -457,7 +457,7 @@ func Test_ReadyChecker_IsReady_DaemonSet(t *testing.T) {
 		{
 			name: "IsReady DaemonSet with error",
 			fields: fields{
-				client:        fake.NewSimpleClientset(),
+				client:        fake.NewClientset(),
 				log:           func(string, ...interface{}) {},
 				checkJobs:     true,
 				pausedAsReady: false,
@@ -516,7 +516,7 @@ func Test_ReadyChecker_IsReady_StatefulSet(t *testing.T) {
 		{
 			name: "IsReady StatefulSet",
 			fields: fields{
-				client:        fake.NewSimpleClientset(),
+				client:        fake.NewClientset(),
 				log:           func(string, ...interface{}) {},
 				checkJobs:     true,
 				pausedAsReady: false,
@@ -532,7 +532,7 @@ func Test_ReadyChecker_IsReady_StatefulSet(t *testing.T) {
 		{
 			name: "IsReady StatefulSet with error",
 			fields: fields{
-				client:        fake.NewSimpleClientset(),
+				client:        fake.NewClientset(),
 				log:           func(string, ...interface{}) {},
 				checkJobs:     true,
 				pausedAsReady: false,
@@ -591,7 +591,7 @@ func Test_ReadyChecker_IsReady_ReplicationController(t *testing.T) {
 		{
 			name: "IsReady ReplicationController",
 			fields: fields{
-				client:        fake.NewSimpleClientset(),
+				client:        fake.NewClientset(),
 				log:           func(string, ...interface{}) {},
 				checkJobs:     true,
 				pausedAsReady: false,
@@ -607,7 +607,7 @@ func Test_ReadyChecker_IsReady_ReplicationController(t *testing.T) {
 		{
 			name: "IsReady ReplicationController with error",
 			fields: fields{
-				client:        fake.NewSimpleClientset(),
+				client:        fake.NewClientset(),
 				log:           func(string, ...interface{}) {},
 				checkJobs:     true,
 				pausedAsReady: false,
@@ -623,7 +623,7 @@ func Test_ReadyChecker_IsReady_ReplicationController(t *testing.T) {
 		{
 			name: "IsReady ReplicationController and pods not ready for object",
 			fields: fields{
-				client:        fake.NewSimpleClientset(),
+				client:        fake.NewClientset(),
 				log:           func(string, ...interface{}) {},
 				checkJobs:     true,
 				pausedAsReady: false,
@@ -682,7 +682,7 @@ func Test_ReadyChecker_IsReady_ReplicaSet(t *testing.T) {
 		{
 			name: "IsReady ReplicaSet",
 			fields: fields{
-				client:        fake.NewSimpleClientset(),
+				client:        fake.NewClientset(),
 				log:           func(string, ...interface{}) {},
 				checkJobs:     true,
 				pausedAsReady: false,
@@ -698,7 +698,7 @@ func Test_ReadyChecker_IsReady_ReplicaSet(t *testing.T) {
 		{
 			name: "IsReady ReplicaSet not ready",
 			fields: fields{
-				client:        fake.NewSimpleClientset(),
+				client:        fake.NewClientset(),
 				log:           func(string, ...interface{}) {},
 				checkJobs:     true,
 				pausedAsReady: false,
@@ -793,7 +793,7 @@ func Test_ReadyChecker_deploymentReady(t *testing.T) {
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-			c := NewReadyChecker(fake.NewSimpleClientset(), nil)
+			c := NewReadyChecker(fake.NewClientset(), nil)
 			if got := c.deploymentReady(tt.args.rs, tt.args.dep); got != tt.want {
 				t.Errorf("deploymentReady() = %v, want %v", got, tt.want)
 			}
@@ -827,7 +827,7 @@ func Test_ReadyChecker_replicaSetReady(t *testing.T) {
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-			c := NewReadyChecker(fake.NewSimpleClientset(), nil)
+			c := NewReadyChecker(fake.NewClientset(), nil)
 			if got := c.replicaSetReady(tt.args.rs); got != tt.want {
 				t.Errorf("replicaSetReady() = %v, want %v", got, tt.want)
 			}
@@ -861,7 +861,7 @@ func Test_ReadyChecker_replicationControllerReady(t *testing.T) {
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-			c := NewReadyChecker(fake.NewSimpleClientset(), nil)
+			c := NewReadyChecker(fake.NewClientset(), nil)
 			if got := c.replicationControllerReady(tt.args.rc); got != tt.want {
 				t.Errorf("replicationControllerReady() = %v, want %v", got, tt.want)
 			}
@@ -916,7 +916,7 @@ func Test_ReadyChecker_daemonSetReady(t *testing.T) {
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-			c := NewReadyChecker(fake.NewSimpleClientset(), nil)
+			c := NewReadyChecker(fake.NewClientset(), nil)
 			if got := c.daemonSetReady(tt.args.ds); got != tt.want {
 				t.Errorf("daemonSetReady() = %v, want %v", got, tt.want)
 			}
@@ -992,7 +992,7 @@ func Test_ReadyChecker_statefulSetReady(t *testing.T) {
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-			c := NewReadyChecker(fake.NewSimpleClientset(), nil)
+			c := NewReadyChecker(fake.NewClientset(), nil)
 			if got := c.statefulSetReady(tt.args.sts); got != tt.want {
 				t.Errorf("statefulSetReady() = %v, want %v", got, tt.want)
 			}
@@ -1051,7 +1051,7 @@ func Test_ReadyChecker_podsReadyForObject(t *testing.T) {
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-			c := NewReadyChecker(fake.NewSimpleClientset(), nil)
+			c := NewReadyChecker(fake.NewClientset(), nil)
 			for _, pod := range tt.existPods {
 				if _, err := c.client.CoreV1().Pods(defaultNamespace).Create(context.TODO(), &pod, metav1.CreateOptions{}); err != nil {
 					t.Errorf("Failed to create Pod error: %v", err)
@@ -1130,7 +1130,7 @@ func Test_ReadyChecker_jobReady(t *testing.T) {
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-			c := NewReadyChecker(fake.NewSimpleClientset(), nil)
+			c := NewReadyChecker(fake.NewClientset(), nil)
 			got, err := c.jobReady(tt.args.job)
 			if (err != nil) != tt.wantErr {
 				t.Errorf("jobReady() error = %v, wantErr %v", err, tt.wantErr)
@@ -1169,7 +1169,7 @@ func Test_ReadyChecker_volumeReady(t *testing.T) {
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-			c := NewReadyChecker(fake.NewSimpleClientset(), nil)
+			c := NewReadyChecker(fake.NewClientset(), nil)
 			if got := c.volumeReady(tt.args.v); got != tt.want {
 				t.Errorf("volumeReady() = %v, want %v", got, tt.want)
 			}
@@ -1214,7 +1214,7 @@ func Test_ReadyChecker_serviceReady(t *testing.T) {
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-			c := NewReadyChecker(fake.NewSimpleClientset(), nil)
+			c := NewReadyChecker(fake.NewClientset(), nil)
 			got := c.serviceReady(tt.args.service)
 			if got != tt.want {
 				t.Errorf("serviceReady() = %v, want %v", got, tt.want)
@@ -1283,7 +1283,7 @@ func Test_ReadyChecker_crdBetaReady(t *testing.T) {
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-			c := NewReadyChecker(fake.NewSimpleClientset(), nil)
+			c := NewReadyChecker(fake.NewClientset(), nil)
 			got := c.crdBetaReady(tt.args.crdBeta)
 			if got != tt.want {
 				t.Errorf("crdBetaReady() = %v, want %v", got, tt.want)
@@ -1352,7 +1352,7 @@ func Test_ReadyChecker_crdReady(t *testing.T) {
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-			c := NewReadyChecker(fake.NewSimpleClientset(), nil)
+			c := NewReadyChecker(fake.NewClientset(), nil)
 			got := c.crdReady(tt.args.crdBeta)
 			if got != tt.want {
 				t.Errorf("crdBetaReady() = %v, want %v", got, tt.want)