Skip to content

Commit

Permalink
Transition from deprecated pointer library to ptr
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Nola <derek.nola@suse.com>
  • Loading branch information
dereknola committed Mar 27, 2024
1 parent b5d0d4e commit 025949a
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ require (
k8s.io/kube-proxy v0.0.0
k8s.io/kubectl v0.25.0
k8s.io/kubernetes v1.29.3
k8s.io/utils v0.0.0-20230726121419-3b25d923346b
k8s.io/utils v0.0.0-20240310230437-4693a0247e57
sigs.k8s.io/yaml v1.4.0
)

Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2170,8 +2170,9 @@ k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/A
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA=
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI=
k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
k8s.io/utils v0.0.0-20240310230437-4693a0247e57 h1:gbqbevonBh57eILzModw6mrkbwM0gQBEuevE/AaBsHY=
k8s.io/utils v0.0.0-20240310230437-4693a0247e57/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI=
lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k=
lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
Expand Down
6 changes: 3 additions & 3 deletions pkg/agent/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import (
app2 "k8s.io/kubernetes/cmd/kube-proxy/app"
kubeproxyconfig "k8s.io/kubernetes/pkg/proxy/apis/config"
utilsnet "k8s.io/utils/net"
utilpointer "k8s.io/utils/pointer"
utilsptr "k8s.io/utils/ptr"
)

func run(ctx context.Context, cfg cmds.Agent, proxy proxy.Proxy) error {
Expand Down Expand Up @@ -201,8 +201,8 @@ func run(ctx context.Context, cfg cmds.Agent, proxy proxy.Proxy) error {
// When running rootless, we do not attempt to set conntrack sysctls - this behavior is copied from kubeadm.
func getConntrackConfig(nodeConfig *daemonconfig.Node) (*kubeproxyconfig.KubeProxyConntrackConfiguration, error) {
ctConfig := &kubeproxyconfig.KubeProxyConntrackConfiguration{
MaxPerCore: utilpointer.Int32Ptr(0),
Min: utilpointer.Int32Ptr(0),
MaxPerCore: utilsptr.To(int32(0)),
Min: utilsptr.To(int32(0)),
TCPEstablishedTimeout: &metav1.Duration{},
TCPCloseWaitTimeout: &metav1.Duration{},
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/agent/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
v1alpha1 "k8s.io/kube-proxy/config/v1alpha1"
kubeproxyconfig "k8s.io/kubernetes/pkg/proxy/apis/config"
kubeproxyconfigv1alpha1 "k8s.io/kubernetes/pkg/proxy/apis/config/v1alpha1"
utilpointer "k8s.io/utils/pointer"
utilsptr "k8s.io/utils/ptr"
)

func Test_UnitGetConntrackConfig(t *testing.T) {
Expand All @@ -23,7 +23,7 @@ func Test_UnitGetConntrackConfig(t *testing.T) {
}

customConfig := defaultConfig.DeepCopy()
customConfig.Conntrack.Min = utilpointer.Int32Ptr(100)
customConfig.Conntrack.Min = utilsptr.To(int32(100))
customConfig.Conntrack.TCPCloseWaitTimeout.Duration = 42 * time.Second

type args struct {
Expand Down
14 changes: 7 additions & 7 deletions pkg/cli/secretsencrypt/secrets_encrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/k3s-io/k3s/pkg/version"
"github.com/pkg/errors"
"github.com/urfave/cli"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

func commandPrep(cfg *cmds.Server) (*clientaccess.Info, error) {
Expand Down Expand Up @@ -54,7 +54,7 @@ func Enable(app *cli.Context) error {
if err != nil {
return err
}
b, err := json.Marshal(server.EncryptionRequest{Enable: pointer.Bool(true)})
b, err := json.Marshal(server.EncryptionRequest{Enable: ptr.To(true)})
if err != nil {
return err
}
Expand All @@ -74,7 +74,7 @@ func Disable(app *cli.Context) error {
if err != nil {
return err
}
b, err := json.Marshal(server.EncryptionRequest{Enable: pointer.Bool(false)})
b, err := json.Marshal(server.EncryptionRequest{Enable: ptr.To(false)})
if err != nil {
return err
}
Expand Down Expand Up @@ -155,7 +155,7 @@ func Prepare(app *cli.Context) error {
return err
}
b, err := json.Marshal(server.EncryptionRequest{
Stage: pointer.String(secretsencrypt.EncryptionPrepare),
Stage: ptr.To(secretsencrypt.EncryptionPrepare),
Force: cmds.ServerConfig.EncryptForce,
})
if err != nil {
Expand All @@ -177,7 +177,7 @@ func Rotate(app *cli.Context) error {
return err
}
b, err := json.Marshal(server.EncryptionRequest{
Stage: pointer.String(secretsencrypt.EncryptionRotate),
Stage: ptr.To(secretsencrypt.EncryptionRotate),
Force: cmds.ServerConfig.EncryptForce,
})
if err != nil {
Expand All @@ -199,7 +199,7 @@ func Reencrypt(app *cli.Context) error {
return err
}
b, err := json.Marshal(server.EncryptionRequest{
Stage: pointer.String(secretsencrypt.EncryptionReencryptActive),
Stage: ptr.To(secretsencrypt.EncryptionReencryptActive),
Force: cmds.ServerConfig.EncryptForce,
Skip: cmds.ServerConfig.EncryptSkip,
})
Expand All @@ -222,7 +222,7 @@ func RotateKeys(app *cli.Context) error {
return err
}
b, err := json.Marshal(server.EncryptionRequest{
Stage: pointer.String(secretsencrypt.EncryptionRotateKeys),
Stage: ptr.To(secretsencrypt.EncryptionRotateKeys),
})
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/token/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"k8s.io/client-go/tools/clientcmd"
bootstrapapi "k8s.io/cluster-bootstrap/token/api"
bootstraputil "k8s.io/cluster-bootstrap/token/util"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

func Create(app *cli.Context) error {
Expand Down Expand Up @@ -155,7 +155,7 @@ func Rotate(app *cli.Context) error {
return err
}
b, err := json.Marshal(server.TokenRotateRequest{
NewToken: pointer.String(cmds.TokenConfig.NewToken),
NewToken: ptr.To(cmds.TokenConfig.NewToken),
})
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions pkg/cloudprovider/servicelb.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
servicehelper "k8s.io/cloud-provider/service/helpers"
"k8s.io/kubernetes/pkg/features"
utilsnet "k8s.io/utils/net"
utilpointer "k8s.io/utils/pointer"
utilsptr "k8s.io/utils/ptr"
)

var (
Expand Down Expand Up @@ -488,7 +488,7 @@ func (k *k3s) newDaemonSet(svc *core.Service) (*apps.DaemonSet, error) {
},
Spec: core.PodSpec{
ServiceAccountName: "svclb",
AutomountServiceAccountToken: utilpointer.Bool(false),
AutomountServiceAccountToken: utilsptr.To(false),
SecurityContext: &core.PodSecurityContext{
Sysctls: sysctls,
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/etcd/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (
"k8s.io/apimachinery/pkg/util/validation"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/util/retry"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

const (
Expand Down Expand Up @@ -1068,7 +1068,7 @@ func (sf *snapshotFile) toETCDSnapshotFile(esf *apisv1.ETCDSnapshotFile) {
esf.Spec.SnapshotName = sf.Name
esf.Spec.Location = sf.Location
esf.Status.CreationTime = sf.CreatedAt
esf.Status.ReadyToUse = pointer.Bool(sf.Status == successfulSnapshotStatus)
esf.Status.ReadyToUse = ptr.To(sf.Status == successfulSnapshotStatus)
esf.Status.Size = resource.NewQuantity(sf.Size, resource.DecimalSI)

if sf.nodeSource != "" {
Expand Down
4 changes: 2 additions & 2 deletions pkg/nodepassword/nodepassword.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
v1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

var (
Expand Down Expand Up @@ -80,7 +80,7 @@ func Ensure(secretClient coreclient.SecretController, nodeName, pass string) err
Name: getSecretName(nodeName),
Namespace: metav1.NamespaceSystem,
},
Immutable: pointer.Bool(true),
Immutable: ptr.To(true),
Data: map[string][]byte{"hash": []byte(hash)},
})
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/server/secrets-encrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"k8s.io/apimachinery/pkg/labels"
apiserverconfigv1 "k8s.io/apiserver/pkg/apis/config/v1"
"k8s.io/client-go/util/retry"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

const aescbcKeySize = 32
Expand Down Expand Up @@ -84,9 +84,9 @@ func encryptionStatus(server *config.Control) (EncryptionState, error) {
return state, err
}
if providers[1].Identity != nil && providers[0].AESCBC != nil {
state.Enable = pointer.Bool(true)
state.Enable = ptr.To(true)
} else if providers[0].Identity != nil && providers[1].AESCBC != nil || !server.EncryptSecrets {
state.Enable = pointer.Bool(false)
state.Enable = ptr.To(false)
}

if err := verifyEncryptionHashAnnotation(server.Runtime, server.Runtime.Core.Core(), ""); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/spegel/spegel.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apiserver/pkg/authentication/authenticator"
"k8s.io/apiserver/pkg/authentication/request/union"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

"github.com/go-logr/logr"
"github.com/go-logr/stdr"
Expand Down Expand Up @@ -141,7 +141,7 @@ func (c *Config) Start(ctx context.Context, nodeConfig *config.Node) error {
if logrus.IsLevelEnabled(logrus.DebugLevel) {
level = ipfslog.LevelDebug
stdlog := log.New(logrus.StandardLogger().Writer(), "spegel ", log.LstdFlags)
logger := stdr.NewWithOptions(stdlog, stdr.Options{Verbosity: pointer.Int(10)})
logger := stdr.NewWithOptions(stdlog, stdr.Options{Verbosity: ptr.To(10)})
ctx = logr.NewContext(ctx, logger)
}
ipfslog.SetAllLoggers(level)
Expand Down

0 comments on commit 025949a

Please sign in to comment.