Skip to content

Commit

Permalink
Upgrade the k8s.io/utils dependency.
Browse files Browse the repository at this point in the history
* Remove all usages of the deprecated `k8s.io/utils/pointer` package
  and replace them with `k8s.io/utils/ptr`.
  • Loading branch information
renormalize committed Oct 18, 2024
1 parent a5fdddd commit 0eafac0
Show file tree
Hide file tree
Showing 14 changed files with 309 additions and 445 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require (
k8s.io/apimachinery v0.26.1
k8s.io/client-go v0.26.1
k8s.io/helm v2.17.0+incompatible // haven't upgraded yet
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448
k8s.io/utils v0.0.0-20240921022957-49e7df575cb6
sigs.k8s.io/controller-runtime v0.14.4 // haven't upgraded yet
sigs.k8s.io/yaml v1.4.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,8 @@ k8s.io/klog/v2 v2.80.1 h1:atnLQ121W371wYYFawwYx1aEY2eUfs4l3J72wtgAwV4=
k8s.io/klog/v2 v2.80.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 h1:+70TFaan3hfJzs+7VK2o+OGxg8HsuBr/5f6tVAjDu6E=
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280/go.mod h1:+Axhij7bCpeqhklhUTe3xmOn6bWxolyZEeyaFpjGtl4=
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 h1:KTgPnR10d5zhztWptI952TNtt/4u5h3IzDXkdIMuo2Y=
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
k8s.io/utils v0.0.0-20240921022957-49e7df575cb6 h1:MDF6h2H/h4tbzmtIKTuctcwZmY0tY9mD9fNT47QO6HI=
k8s.io/utils v0.0.0-20240921022957-49e7df575cb6/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
sigs.k8s.io/controller-runtime v0.14.4 h1:Kd/Qgx5pd2XUL08eOV2vwIq3L9GhIbJ5Nxengbd4/0M=
sigs.k8s.io/controller-runtime v0.14.4/go.mod h1:WqIdsAY6JBsjfc/CqO0CORmNtoCtE4S6qbPc9s68h+0=
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
coordv1 "k8s.io/api/coordination/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

var _ = Describe("Membergarbagecollector", func() {
Expand Down Expand Up @@ -226,7 +226,7 @@ func getStsWithName(name string, replicas int32) *appsv1.StatefulSet {
Namespace: os.Getenv("POD_NAMESPACE"),
},
Spec: appsv1.StatefulSetSpec{
Replicas: pointer.Int32Ptr(replicas),
Replicas: ptr.To(int32(replicas)),
},
Status: appsv1.StatefulSetStatus{
Replicas: replicas,
Expand Down
6 changes: 3 additions & 3 deletions pkg/miscellaneous/miscellaneous.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/util/retry"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
"sigs.k8s.io/yaml"

appsv1 "k8s.io/api/apps/v1"
Expand Down Expand Up @@ -436,11 +436,11 @@ func GetInitialClusterStateIfScaleup(ctx context.Context, logger logrus.Entry, c
}

if IsAnnotationPresent(etcdSts, ScaledToMultiNodeAnnotationKey) {
return pointer.StringPtr(ClusterStateExisting), nil
return ptr.To(ClusterStateExisting), nil
}

if *etcdSts.Spec.Replicas > 1 && *etcdSts.Spec.Replicas > etcdSts.Status.UpdatedReplicas {
return pointer.StringPtr(ClusterStateExisting), nil
return ptr.To(ClusterStateExisting), nil
}
return nil, nil
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/miscellaneous/miscellaneous_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"go.etcd.io/etcd/etcdserver/etcdserverpb"
appsv1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

var (
Expand Down Expand Up @@ -466,7 +466,7 @@ var _ = Describe("Miscellaneous Tests", func() {
Context("In single node etcd: no scale-up", func() {
BeforeEach(func() {
sts.Spec = appsv1.StatefulSetSpec{
Replicas: pointer.Int32Ptr(1),
Replicas: ptr.To(int32(1)),
}
sts.Status = appsv1.StatefulSetStatus{
UpdatedReplicas: 1,
Expand All @@ -488,7 +488,7 @@ var _ = Describe("Miscellaneous Tests", func() {
Context("In multi-node etcd bootstrap: no scale-up", func() {
BeforeEach(func() {
sts.Spec = appsv1.StatefulSetSpec{
Replicas: pointer.Int32Ptr(3),
Replicas: ptr.To(int32(3)),
}
sts.Status = appsv1.StatefulSetStatus{
UpdatedReplicas: 3,
Expand All @@ -510,7 +510,7 @@ var _ = Describe("Miscellaneous Tests", func() {
Context("In case of Scaling up from single node to multi-node etcd with no scale-up annotation set", func() {
BeforeEach(func() {
sts.Spec = appsv1.StatefulSetSpec{
Replicas: pointer.Int32Ptr(3),
Replicas: ptr.To(int32(3)),
}
sts.Status = appsv1.StatefulSetStatus{
UpdatedReplicas: 1,
Expand All @@ -532,7 +532,7 @@ var _ = Describe("Miscellaneous Tests", func() {
Context("scaling of single node to multi-node etcd with scale-up annotation set", func() {
BeforeEach(func() {
sts.Spec = appsv1.StatefulSetSpec{
Replicas: pointer.Int32Ptr(3),
Replicas: ptr.To(int32(3)),
}
sts.Status = appsv1.StatefulSetStatus{
UpdatedReplicas: 3,
Expand Down Expand Up @@ -567,7 +567,7 @@ var _ = Describe("Miscellaneous Tests", func() {
Namespace: namespace,
},
Spec: appsv1.StatefulSetSpec{
Replicas: pointer.Int32Ptr(3),
Replicas: ptr.To(int32(3)),
},
Status: appsv1.StatefulSetStatus{
UpdatedReplicas: 1,
Expand Down
4 changes: 2 additions & 2 deletions pkg/snapstore/abs_snapstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blockblob"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
"github.com/sirupsen/logrus"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

brtypes "github.com/gardener/etcd-backup-restore/pkg/types"
)
Expand Down Expand Up @@ -247,7 +247,7 @@ func readABSCredentialFiles(dirname string) (*absCredentials, error) {
if err != nil {
return nil, err
}
absConfig.Domain = pointer.String(string(data))
absConfig.Domain = ptr.To(string(data))
}
}

Expand Down
14 changes: 7 additions & 7 deletions pkg/snapstore/s3_snapstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/aws/aws-sdk-go/service/s3"
"github.com/aws/aws-sdk-go/service/s3/s3iface"
"github.com/sirupsen/logrus"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

brtypes "github.com/gardener/etcd-backup-restore/pkg/types"
)
Expand Down Expand Up @@ -163,7 +163,7 @@ func readAWSCredentialsJSONFile(filename string) (session.Options, SSECredential
return session.Options{
Config: aws.Config{
Credentials: credentials.NewStaticCredentials(awsConfig.AccessKeyID, awsConfig.SecretAccessKey, ""),
Region: pointer.String(awsConfig.Region),
Region: ptr.To(awsConfig.Region),
Endpoint: awsConfig.Endpoint,
S3ForcePathStyle: awsConfig.S3ForcePathStyle,
HTTPClient: httpClient,
Expand Down Expand Up @@ -216,7 +216,7 @@ func readAWSCredentialFiles(dirname string) (session.Options, SSECredentials, er
return session.Options{
Config: aws.Config{
Credentials: credentials.NewStaticCredentials(awsConfig.AccessKeyID, awsConfig.SecretAccessKey, ""),
Region: pointer.String(awsConfig.Region),
Region: ptr.To(awsConfig.Region),
Endpoint: awsConfig.Endpoint,
S3ForcePathStyle: awsConfig.S3ForcePathStyle,
HTTPClient: httpClient,
Expand Down Expand Up @@ -257,7 +257,7 @@ func readAWSCredentialFromDir(dirname string) (*awsCredentials, error) {
if err != nil {
return nil, err
}
awsConfig.Endpoint = pointer.String(string(data))
awsConfig.Endpoint = ptr.To(string(data))
case "s3ForcePathStyle":
data, err := os.ReadFile(dirname + "/s3ForcePathStyle")
if err != nil {
Expand All @@ -283,19 +283,19 @@ func readAWSCredentialFromDir(dirname string) (*awsCredentials, error) {
if err != nil {
return nil, err
}
awsConfig.TrustedCaCert = pointer.String(string(data))
awsConfig.TrustedCaCert = ptr.To(string(data))
case "sseCustomerKey":
data, err := os.ReadFile(dirname + "/sseCustomerKey")
if err != nil {
return nil, err
}
awsConfig.SSECustomerKey = pointer.String(string(data))
awsConfig.SSECustomerKey = ptr.To(string(data))
case "sseCustomerAlgorithm":
data, err := os.ReadFile(dirname + "/sseCustomerAlgorithm")
if err != nil {
return nil, err
}
awsConfig.SSECustomerAlgorithm = pointer.String(string(data))
awsConfig.SSECustomerAlgorithm = ptr.To(string(data))
}
}

Expand Down
26 changes: 16 additions & 10 deletions vendor/k8s.io/utils/integer/integer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0eafac0

Please sign in to comment.