Skip to content

Commit

Permalink
Fix deprecations
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Beck <simon.beck@vshn.ch>
  • Loading branch information
Kidswiss committed Mar 7, 2024
1 parent 5a5b511 commit a9e3dc6
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion cli/restore/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

func RandomStringGenerator(n int) string {
var characters = []rune("abcdefghijklmnopqrstuvwxyz1234567890")
rand.Seed(time.Now().UnixNano())
rand.New(rand.NewSource(time.Now().UnixNano()))
b := make([]rune, n)
for i := range b {
b[i] = characters[rand.Intn(len(characters))]
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ module github.com/k8up-io/k8up/v2

go 1.21

toolchain go1.22.1

require (
github.com/firepear/qsplit/v2 v2.5.0
github.com/go-logr/logr v1.4.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (ts *BackupTestSuite) newPvc(name string, accessMode corev1.PersistentVolum
},
Spec: corev1.PersistentVolumeClaimSpec{
AccessModes: []corev1.PersistentVolumeAccessMode{accessMode},
Resources: corev1.ResourceRequirements{
Resources: corev1.VolumeResourceRequirements{
Requests: map[corev1.ResourceName]resource.Quantity{
corev1.ResourceStorage: resource.MustParse("1Mi"),
},
Expand Down
4 changes: 2 additions & 2 deletions operator/backupcontroller/prebackup_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
controllerruntime "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
Expand Down Expand Up @@ -59,7 +59,7 @@ func (b *BackupExecutor) generateDeployments(ctx context.Context, templates []k8
},
},
Spec: appsv1.DeploymentSpec{
Replicas: pointer.Int32(1),
Replicas: ptr.To(int32(1)),
Template: template.Spec.Pod.PodTemplateSpec,
Selector: &metav1.LabelSelector{
MatchLabels: podLabels,
Expand Down
3 changes: 2 additions & 1 deletion restic/kubernetes/pod_exec.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package kubernetes

import (
"context"
"fmt"
"io"
"strings"
Expand Down Expand Up @@ -60,7 +61,7 @@ func PodExec(pod BackupPod, log logr.Logger) (*ExecData, error) {
var stdoutReader, stdoutWriter = io.Pipe()
done := make(chan bool, 1)
go func() {
err = exec.Stream(remotecommand.StreamOptions{
err = exec.StreamWithContext(context.Background(), remotecommand.StreamOptions{
Stdin: nil,
Stdout: stdoutWriter,
Stderr: logging.NewErrorWriter(log.WithName(pod.PodName)),
Expand Down
32 changes: 16 additions & 16 deletions restic/kubernetes/snapshots_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

k8upv1 "github.com/k8up-io/k8up/v2/api/v1"
"github.com/stretchr/testify/assert"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

func Test_diff(t *testing.T) {
Expand All @@ -29,7 +29,7 @@ func Test_diff(t *testing.T) {
Items: []k8upv1.Snapshot{
{
Spec: k8upv1.SnapshotSpec{
ID: pointer.String("2"),
ID: ptr.To("2"),
},
},
},
Expand All @@ -48,7 +48,7 @@ func Test_diff(t *testing.T) {
Items: []k8upv1.Snapshot{
{
Spec: k8upv1.SnapshotSpec{
ID: pointer.String("1"),
ID: ptr.To("1"),
},
},
},
Expand All @@ -57,7 +57,7 @@ func Test_diff(t *testing.T) {
Items: []k8upv1.Snapshot{
{
Spec: k8upv1.SnapshotSpec{
ID: pointer.String("1"),
ID: ptr.To("1"),
},
},
},
Expand All @@ -73,17 +73,17 @@ func Test_diff(t *testing.T) {
Items: []k8upv1.Snapshot{
{
Spec: k8upv1.SnapshotSpec{
ID: pointer.String("1"),
ID: ptr.To("1"),
},
},
{
Spec: k8upv1.SnapshotSpec{
ID: pointer.String("2"),
ID: ptr.To("2"),
},
},
{
Spec: k8upv1.SnapshotSpec{
ID: pointer.String("3"),
ID: ptr.To("3"),
},
},
},
Expand All @@ -92,7 +92,7 @@ func Test_diff(t *testing.T) {
Items: []k8upv1.Snapshot{
{
Spec: k8upv1.SnapshotSpec{
ID: pointer.String("1"),
ID: ptr.To("1"),
},
},
},
Expand All @@ -111,7 +111,7 @@ func Test_diff(t *testing.T) {
Items: []k8upv1.Snapshot{
{
Spec: k8upv1.SnapshotSpec{
ID: pointer.String("2"),
ID: ptr.To("2"),
},
},
},
Expand Down Expand Up @@ -152,12 +152,12 @@ func Test_filterByRepo(t *testing.T) {
Items: []k8upv1.Snapshot{
{
Spec: k8upv1.SnapshotSpec{
Repository: pointer.String("myrepo"),
Repository: ptr.To("myrepo"),
},
},
{
Spec: k8upv1.SnapshotSpec{
Repository: pointer.String("myrepo"),
Repository: ptr.To("myrepo"),
},
},
},
Expand All @@ -168,12 +168,12 @@ func Test_filterByRepo(t *testing.T) {
Items: []k8upv1.Snapshot{
{
Spec: k8upv1.SnapshotSpec{
Repository: pointer.String("myrepo"),
Repository: ptr.To("myrepo"),
},
},
{
Spec: k8upv1.SnapshotSpec{
Repository: pointer.String("myrepo"),
Repository: ptr.To("myrepo"),
},
},
},
Expand All @@ -186,7 +186,7 @@ func Test_filterByRepo(t *testing.T) {
Items: []k8upv1.Snapshot{
{
Spec: k8upv1.SnapshotSpec{
Repository: pointer.String("myrepo"),
Repository: ptr.To("myrepo"),
},
},
},
Expand All @@ -197,12 +197,12 @@ func Test_filterByRepo(t *testing.T) {
Items: []k8upv1.Snapshot{
{
Spec: k8upv1.SnapshotSpec{
Repository: pointer.String("yourrepo"),
Repository: ptr.To("yourrepo"),
},
},
{
Spec: k8upv1.SnapshotSpec{
Repository: pointer.String("myrepo"),
Repository: ptr.To("myrepo"),
},
},
},
Expand Down

0 comments on commit a9e3dc6

Please sign in to comment.