mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-19 01:27:10 +00:00
chore: replace int32Ptr usage with ptr.To
Kubernetes-commit: e0f9914ef726bd5bcafcdadf5a6a0a6e92d9a885
This commit is contained in:
parent
5439ef7b0c
commit
81caec87ee
@ -32,6 +32,7 @@ import (
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
"k8s.io/client-go/util/homedir"
|
||||
"k8s.io/client-go/util/retry"
|
||||
"k8s.io/utils/ptr"
|
||||
//
|
||||
// Uncomment to load all auth plugins
|
||||
// _ "k8s.io/client-go/plugin/pkg/client/auth"
|
||||
@ -67,7 +68,7 @@ func main() {
|
||||
Name: "demo-deployment",
|
||||
},
|
||||
Spec: appsv1.DeploymentSpec{
|
||||
Replicas: int32Ptr(2),
|
||||
Replicas: ptr.To[int32](2),
|
||||
Selector: &metav1.LabelSelector{
|
||||
MatchLabels: map[string]string{
|
||||
"app": "demo",
|
||||
@ -130,7 +131,7 @@ func main() {
|
||||
panic(fmt.Errorf("Failed to get latest version of Deployment: %v", getErr))
|
||||
}
|
||||
|
||||
result.Spec.Replicas = int32Ptr(1) // reduce replica count
|
||||
result.Spec.Replicas = ptr.To[int32](1) // reduce replica count
|
||||
result.Spec.Template.Spec.Containers[0].Image = "nginx:1.13" // change nginx version
|
||||
_, updateErr := deploymentsClient.Update(context.TODO(), result, metav1.UpdateOptions{})
|
||||
return updateErr
|
||||
@ -174,5 +175,3 @@ func prompt() {
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
func int32Ptr(i int32) *int32 { return &i }
|
||||
|
Loading…
Reference in New Issue
Block a user