Skip to content

Commit e3b2d64

Browse files
committed
⬆️ First pass on upgrading dependencies.
1 parent c63ad0a commit e3b2d64

File tree

10 files changed

+699
-347
lines changed

10 files changed

+699
-347
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
steps:
1515
- uses: actions/setup-go@v3
1616
with:
17-
go-version: 1.17
17+
go-version: 1.20
1818
- uses: actions/checkout@v3
1919
- name: golangci-lint
2020
uses: golangci/golangci-lint-action@v3
@@ -32,15 +32,15 @@ jobs:
3232
- uses: actions/checkout@v2
3333
- uses: actions/setup-go@v3
3434
with:
35-
go-version: 1.17
35+
go-version: 1.20
3636
- name: Install Kubebuilder
3737
id: install-kubebuilder
3838
run: |
3939
os=$(go env GOOS)
4040
arch=$(go env GOARCH)
41-
version=2.3.1
42-
curl -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${version}/kubebuilder_${version}_${os}_${arch}.tar.gz | tar -xz -C /tmp/
43-
sudo mv /tmp/kubebuilder_2.3.1_${os}_${arch} /usr/local/kubebuilder
41+
version=1.24.2
42+
curl -L https://storage.googleapis.com/kubebuilder-tools/kubebuilder-tools-${version}-${os}-${arch}.tar.gz | tar -xz -C /tmp/
43+
sudo mv /tmp/kubebuilder /usr/local/kubebuilder
4444
- run: make test
4545

4646
build:

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.17 as builder
2+
FROM golang:1.20 AS builder
33

44
WORKDIR /workspace
55
# Copy the Go Modules manifests

Makefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,7 @@ controller-gen:
6969
ifeq (, $(shell which controller-gen))
7070
@{ \
7171
set -e ;\
72-
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
73-
cd $$CONTROLLER_GEN_TMP_DIR ;\
74-
go mod init tmp ;\
75-
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.4.1 ;\
76-
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
72+
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.4.1 ;\
7773
}
7874
CONTROLLER_GEN=$(GOBIN)/controller-gen
7975
else

cmd/waiter/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"bytes"
2121
"encoding/json"
2222
"fmt"
23-
"io/ioutil"
23+
"io"
2424
"log"
2525
"net/http"
2626
"os"
@@ -63,7 +63,7 @@ func migratorReady(targetImage, migratorNamespace, migratorName, apiUrl string)
6363
return false, err
6464
}
6565
defer resp.Body.Close()
66-
body, err := ioutil.ReadAll(resp.Body)
66+
body, err := io.ReadAll(resp.Body)
6767
if err != nil {
6868
return false, err
6969
}

components/migrations.go

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -65,33 +65,30 @@ func (comp *migrationsComponent) Setup(ctx *cu.Context, bldr *ctrl.Builder) erro
6565
bldr.Owns(&batchv1.Job{})
6666
bldr.Watches(
6767
&source.Kind{Type: &corev1.Pod{}},
68-
&handler.EnqueueRequestsFromMapFunc{ToRequests: &migrationsComponentWatchMap{client: ctx.Client, log: ctx.Log}},
68+
handler.EnqueueRequestsFromMapFunc(func(obj client.Object) []reconcile.Request {
69+
// Obj is a Pod that just got an event, map it back to any matching Migrators.
70+
requests := []reconcile.Request{}
71+
// Find any Migrator objects that match this pod.
72+
migrators, err := utils.ListMatchingMigrators(context.Background(), ctx.Client, obj)
73+
if err != nil {
74+
ctx.Log.Error(err, "error listing matching migrators")
75+
// TODO Metric to track this for alerting.
76+
return requests
77+
}
78+
for _, migrator := range migrators {
79+
requests = append(requests, reconcile.Request{
80+
NamespacedName: types.NamespacedName{
81+
Name: migrator.Name,
82+
Namespace: migrator.Namespace,
83+
},
84+
})
85+
}
86+
return requests
87+
}),
6988
)
7089
return nil
7190
}
7291

73-
// Watch map function used above.
74-
// Obj is a Pod that just got an event, map it back to any matching Migrators.
75-
func (m *migrationsComponentWatchMap) Map(obj handler.MapObject) []reconcile.Request {
76-
requests := []reconcile.Request{}
77-
// Find any Migrator objects that match this pod.
78-
migrators, err := utils.ListMatchingMigrators(context.Background(), m.client, obj.Meta)
79-
if err != nil {
80-
m.log.Error(err, "error listing matching migrators")
81-
// TODO Metric to track this for alerting.
82-
return requests
83-
}
84-
for _, migrator := range migrators {
85-
requests = append(requests, reconcile.Request{
86-
NamespacedName: types.NamespacedName{
87-
Name: migrator.Name,
88-
Namespace: migrator.Namespace,
89-
},
90-
})
91-
}
92-
return requests
93-
}
94-
9592
func (comp *migrationsComponent) Reconcile(ctx *cu.Context) (cu.Result, error) {
9693
obj := ctx.Object.(*migrationsv1beta1.Migrator)
9794

@@ -310,9 +307,9 @@ func (comp *migrationsComponent) Reconcile(ctx *cu.Context) (cu.Result, error) {
310307
return cu.Result{}, nil
311308
}
312309

313-
func (_ *migrationsComponent) findOwners(ctx *cu.Context, obj cu.Object) ([]cu.Object, error) {
310+
func (_ *migrationsComponent) findOwners(ctx *cu.Context, obj client.Object) ([]client.Object, error) {
314311
namespace := obj.GetNamespace()
315-
owners := []cu.Object{}
312+
owners := []client.Object{}
316313
for {
317314
owners = append(owners, obj)
318315
ref := metav1.GetControllerOfNoCopy(obj)
@@ -329,15 +326,15 @@ func (_ *migrationsComponent) findOwners(ctx *cu.Context, obj cu.Object) ([]cu.O
329326
}
330327
return nil, errors.Wrapf(err, "error finding object type for owner reference %v", ref)
331328
}
332-
err = ctx.Client.Get(ctx, types.NamespacedName{Name: ref.Name, Namespace: namespace}, ownerObj)
329+
obj = ownerObj.(client.Object)
330+
err = ctx.Client.Get(ctx, types.NamespacedName{Name: ref.Name, Namespace: namespace}, obj)
333331
if err != nil {
334332
// Gracefully handle objects we don't have access to
335333
if kerrors.IsForbidden(err) {
336334
break
337335
}
338336
return nil, errors.Wrapf(err, "error finding object type for owner reference %v", ref)
339337
}
340-
obj = ownerObj.(cu.Object)
341338
}
342339
// Reverse the slice so it goes top -> bottom.
343340
for i, j := 0, len(owners)-1; i < j; i, j = i+1, j-1 {
@@ -346,7 +343,7 @@ func (_ *migrationsComponent) findOwners(ctx *cu.Context, obj cu.Object) ([]cu.O
346343
return owners, nil
347344
}
348345

349-
func (_ *migrationsComponent) findSpecFor(ctx *cu.Context, obj cu.Object) *corev1.PodSpec {
346+
func (_ *migrationsComponent) findSpecFor(ctx *cu.Context, obj client.Object) *corev1.PodSpec {
350347
switch v := obj.(type) {
351348
case *corev1.Pod:
352349
return &v.Spec
@@ -373,7 +370,7 @@ func (_ *migrationsComponent) findSpecFor(ctx *cu.Context, obj cu.Object) *corev
373370
}
374371
}
375372

376-
func (comp *migrationsComponent) findOwnerSpec(ctx *cu.Context, obj cu.Object) (*corev1.PodSpec, error) {
373+
func (comp *migrationsComponent) findOwnerSpec(ctx *cu.Context, obj client.Object) (*corev1.PodSpec, error) {
377374
owners, err := comp.findOwners(ctx, obj)
378375
if err != nil {
379376
return nil, err

controllers/suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func TestControllers(t *testing.T) {
4040
}
4141

4242
var _ = BeforeSuite(func(done Done) {
43-
logf.SetLogger(zap.New(zap.UseDevMode(true), zap.WriteTo(GinkgoWriter)))
43+
logf.SetLogger(zap.New(zap.UseDevMode(true), zap.WriteTo(GinkgoWriter))) //nolint
4444

4545
By("bootstrapping test environment")
4646
suiteHelper = cu.Functional().

go.mod

Lines changed: 79 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,87 @@
11
module github.com/coderanger/migrations-operator
22

3-
go 1.15
3+
go 1.20
44

55
// replace github.com/coderanger/controller-utils => /Users/coderanger/src/gm/controller-utils
66

7-
replace sigs.k8s.io/controller-runtime => github.com/coderanger/controller-runtime v0.2.0-beta.1.0.20201115004253-9bec1fefa8ca
8-
97
require (
10-
github.com/coderanger/controller-utils v0.0.0-20201115005928-cf3babb815dd
11-
github.com/go-logr/logr v0.1.0
12-
github.com/onsi/ginkgo v1.14.1
13-
github.com/onsi/gomega v1.10.2
8+
github.com/coderanger/controller-utils v0.0.0-20230810025233-8343320aaff8
9+
github.com/go-logr/logr v1.2.3
10+
github.com/onsi/ginkgo v1.16.5
11+
github.com/onsi/gomega v1.19.0
1412
github.com/pkg/errors v0.9.1
15-
golang.org/x/sys v0.0.0-20220325203850-36772127a21f // indirect
16-
k8s.io/api v0.18.6
17-
k8s.io/apimachinery v0.18.6
18-
k8s.io/client-go v0.18.6
19-
sigs.k8s.io/controller-runtime v0.6.3
13+
k8s.io/api v0.25.0
14+
k8s.io/apimachinery v0.25.0
15+
k8s.io/client-go v0.25.0
16+
sigs.k8s.io/controller-runtime v0.13.0
17+
)
18+
19+
require (
20+
cloud.google.com/go v0.97.0 // indirect
21+
github.com/Masterminds/goutils v1.1.0 // indirect
22+
github.com/Masterminds/semver v1.5.0 // indirect
23+
github.com/Masterminds/sprig v2.22.0+incompatible // indirect
24+
github.com/PuerkitoBio/purell v1.1.1 // indirect
25+
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
26+
github.com/beorn7/perks v1.0.1 // indirect
27+
github.com/cespare/xxhash/v2 v2.1.2 // indirect
28+
github.com/davecgh/go-spew v1.1.1 // indirect
29+
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
30+
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
31+
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
32+
github.com/fsnotify/fsnotify v1.5.4 // indirect
33+
github.com/go-logr/zapr v1.2.3 // indirect
34+
github.com/go-openapi/jsonpointer v0.19.5 // indirect
35+
github.com/go-openapi/jsonreference v0.19.5 // indirect
36+
github.com/go-openapi/swag v0.19.14 // indirect
37+
github.com/gogo/protobuf v1.3.2 // indirect
38+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
39+
github.com/golang/protobuf v1.5.2 // indirect
40+
github.com/google/gnostic v0.5.7-v3refs // indirect
41+
github.com/google/go-cmp v0.5.8 // indirect
42+
github.com/google/gofuzz v1.1.0 // indirect
43+
github.com/google/uuid v1.1.2 // indirect
44+
github.com/huandu/xstrings v1.3.2 // indirect
45+
github.com/imdario/mergo v0.3.12 // indirect
46+
github.com/josharian/intern v1.0.0 // indirect
47+
github.com/json-iterator/go v1.1.12 // indirect
48+
github.com/mailru/easyjson v0.7.6 // indirect
49+
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
50+
github.com/mitchellh/copystructure v1.0.0 // indirect
51+
github.com/mitchellh/reflectwalk v1.0.0 // indirect
52+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
53+
github.com/modern-go/reflect2 v1.0.2 // indirect
54+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
55+
github.com/nxadm/tail v1.4.8 // indirect
56+
github.com/prometheus/client_golang v1.12.2 // indirect
57+
github.com/prometheus/client_model v0.2.0 // indirect
58+
github.com/prometheus/common v0.32.1 // indirect
59+
github.com/prometheus/procfs v0.7.3 // indirect
60+
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 // indirect
61+
github.com/spf13/pflag v1.0.5 // indirect
62+
go.uber.org/atomic v1.7.0 // indirect
63+
go.uber.org/multierr v1.6.0 // indirect
64+
go.uber.org/zap v1.21.0 // indirect
65+
golang.org/x/crypto v0.11.0 // indirect
66+
golang.org/x/net v0.10.0 // indirect
67+
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
68+
golang.org/x/sys v0.10.0 // indirect
69+
golang.org/x/term v0.10.0 // indirect
70+
golang.org/x/text v0.11.0 // indirect
71+
golang.org/x/time v0.0.0-20220609170525-579cf78fd858 // indirect
72+
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
73+
google.golang.org/appengine v1.6.7 // indirect
74+
google.golang.org/protobuf v1.28.0 // indirect
75+
gopkg.in/inf.v0 v0.9.1 // indirect
76+
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
77+
gopkg.in/yaml.v2 v2.4.0 // indirect
78+
gopkg.in/yaml.v3 v3.0.1 // indirect
79+
k8s.io/apiextensions-apiserver v0.25.0 // indirect
80+
k8s.io/component-base v0.25.0 // indirect
81+
k8s.io/klog/v2 v2.70.1 // indirect
82+
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect
83+
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed // indirect
84+
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
85+
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
86+
sigs.k8s.io/yaml v1.3.0 // indirect
2087
)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy