Skip to content

Commit 98d5f4f

Browse files
authored
bump k8s to 1.23.1 (#145)
* bump k8s to 1.23.1 Signed-off-by: Joe Lanford <[email protected]> * use client.Object in controllerutil.SupportsOwnerReference Signed-off-by: Joe Lanford <[email protected]>
1 parent a423fef commit 98d5f4f

26 files changed

+312
-132
lines changed

Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,13 @@ all: test lint build
4545
# kubernetes release notes for the minor version you're building tools for.
4646
ENVTEST_VERSION = $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\{1,\}\)\.[[:digit:]]\{1,\}$$/1.\1.x/')
4747
TESTPKG ?= ./...
48-
# TODO: Modify this to use setup-envtest binary
4948
test: build
5049
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
5150
eval $$(setup-envtest use -p env $(ENVTEST_VERSION)) && go test -race -covermode atomic -coverprofile cover.out $(TESTPKG)
5251

5352
.PHONY: test-sanity
54-
test-sanity: generate fix ## Test repo formatting, linting, etc.
53+
test-sanity: generate fix lint ## Test repo formatting, linting, etc.
5554
go vet ./...
56-
$(SCRIPTS_DIR)/fetch golangci-lint 1.31.0 && $(TOOLS_BIN_DIR)/golangci-lint run
5755
git diff --exit-code # diff again to ensure other checks don't change repo
5856

5957
# Build manager binary
@@ -71,7 +69,7 @@ fix:
7169
# Run various checks against code
7270
.PHONY: lint
7371
lint:
74-
fetch golangci-lint 1.35.2 && golangci-lint run
72+
fetch golangci-lint 1.43.0 && golangci-lint run
7573

7674
.PHONY: release
7775
release: GORELEASER_ARGS ?= --snapshot --rm-dist --skip-sign

go.mod

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,30 @@ go 1.16
44

55
require (
66
github.com/blang/semver/v4 v4.0.0
7-
github.com/go-logr/logr v0.4.0
7+
github.com/go-logr/logr v1.2.0
88
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0
99
github.com/iancoleman/strcase v0.1.2
1010
github.com/kr/text v0.2.0
11-
github.com/onsi/ginkgo v1.16.4
12-
github.com/onsi/gomega v1.14.0
11+
github.com/onsi/ginkgo v1.16.5
12+
github.com/onsi/gomega v1.17.0
1313
github.com/operator-framework/operator-lib v0.3.0
1414
github.com/prometheus/client_golang v1.11.0
1515
github.com/sirupsen/logrus v1.8.1
16-
github.com/spf13/afero v1.2.2
17-
github.com/spf13/cobra v1.1.3
16+
github.com/spf13/afero v1.6.0
17+
github.com/spf13/cobra v1.2.1
1818
github.com/spf13/pflag v1.0.5
1919
github.com/stretchr/testify v1.7.0
2020
gomodules.xyz/jsonpatch/v2 v2.2.0
2121
helm.sh/helm/v3 v3.6.2
22-
k8s.io/api v0.22.1
23-
k8s.io/apiextensions-apiserver v0.22.1
24-
k8s.io/apimachinery v0.22.1
25-
k8s.io/cli-runtime v0.22.1
26-
k8s.io/client-go v0.22.1
27-
k8s.io/kubectl v0.22.1
28-
sigs.k8s.io/controller-runtime v0.9.6
22+
k8s.io/api v0.23.1
23+
k8s.io/apiextensions-apiserver v0.23.1
24+
k8s.io/apimachinery v0.23.1
25+
k8s.io/cli-runtime v0.23.1
26+
k8s.io/client-go v0.23.1
27+
k8s.io/kubectl v0.23.1
28+
sigs.k8s.io/controller-runtime v0.11.0
2929
sigs.k8s.io/kubebuilder/v3 v3.0.0-alpha.0.0.20210716121009-fde793f20067
30-
sigs.k8s.io/yaml v1.2.0
30+
sigs.k8s.io/yaml v1.3.0
3131
)
3232

3333
replace (

go.sum

Lines changed: 256 additions & 74 deletions
Large diffs are not rendered by default.

pkg/sdk/controllerutil/controllerutil.go renamed to internal/sdk/controllerutil/controllerutil.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
apierrors "k8s.io/apimachinery/pkg/api/errors"
2424
"k8s.io/apimachinery/pkg/api/meta"
2525
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
26-
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2726
"k8s.io/apimachinery/pkg/util/wait"
2827
"sigs.k8s.io/controller-runtime/pkg/client"
2928
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
@@ -57,7 +56,7 @@ func WaitForDeletion(ctx context.Context, cl client.Reader, o client.Object) err
5756
}, ctx.Done())
5857
}
5958

60-
func SupportsOwnerReference(restMapper meta.RESTMapper, owner, dependent *unstructured.Unstructured) (bool, error) {
59+
func SupportsOwnerReference(restMapper meta.RESTMapper, owner, dependent client.Object) (bool, error) {
6160
ownerGVK := owner.GetObjectKind().GroupVersionKind()
6261
ownerMapping, err := restMapper.RESTMapping(ownerGVK.GroupKind(), ownerGVK.Version)
6362
if err != nil {

pkg/sdk/controllerutil/controllerutil_test.go renamed to internal/sdk/controllerutil/controllerutil_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
"sigs.k8s.io/controller-runtime/pkg/client"
3232
"sigs.k8s.io/controller-runtime/pkg/client/fake"
3333

34-
. "github.com/operator-framework/helm-operator-plugins/pkg/sdk/controllerutil"
34+
. "github.com/operator-framework/helm-operator-plugins/internal/sdk/controllerutil"
3535
)
3636

3737
var _ = Describe("Controllerutil", func() {
@@ -74,8 +74,8 @@ var _ = Describe("Controllerutil", func() {
7474
Describe("SupportsOwnerReference", func() {
7575
var (
7676
rm *meta.DefaultRESTMapper
77-
owner *unstructured.Unstructured
78-
dependent *unstructured.Unstructured
77+
owner client.Object
78+
dependent client.Object
7979
clusterScoped = schema.GroupVersionKind{Group: "example.com", Version: "v1", Kind: "ClusterScoped"}
8080
namespaceScoped = schema.GroupVersionKind{Group: "example.com", Version: "v1", Kind: "NamespaceScoped"}
8181
)

pkg/client/actionclient.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ import (
4444
"sigs.k8s.io/controller-runtime/pkg/client"
4545
"sigs.k8s.io/yaml"
4646

47+
"github.com/operator-framework/helm-operator-plugins/internal/sdk/controllerutil"
4748
"github.com/operator-framework/helm-operator-plugins/pkg/manifestutil"
48-
"github.com/operator-framework/helm-operator-plugins/pkg/sdk/controllerutil"
4949
)
5050

5151
type ActionClientGetter interface {
@@ -331,7 +331,7 @@ func (pr *ownerPostRenderer) Run(in *bytes.Buffer) (*bytes.Buffer, error) {
331331
return err
332332
}
333333
u := &unstructured.Unstructured{Object: objMap}
334-
useOwnerRef, err := controllerutil.SupportsOwnerReference(pr.rm, pr.owner.(*unstructured.Unstructured), u)
334+
useOwnerRef, err := controllerutil.SupportsOwnerReference(pr.rm, pr.owner, u)
335335
if err != nil {
336336
return err
337337
}

pkg/client/actionclient_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"errors"
2323
"strconv"
2424

25+
"github.com/go-logr/logr"
2526
. "github.com/onsi/ginkgo"
2627
. "github.com/onsi/gomega"
2728
"helm.sh/helm/v3/pkg/action"
@@ -59,7 +60,7 @@ var _ = Describe("ActionClient", func() {
5960
})
6061
var _ = Describe("NewActionClientGetter", func() {
6162
It("should return a valid ActionConfigGetter", func() {
62-
actionConfigGetter := NewActionConfigGetter(cfg, rm, nil)
63+
actionConfigGetter := NewActionConfigGetter(cfg, rm, logr.Discard())
6364
Expect(NewActionClientGetter(actionConfigGetter)).NotTo(BeNil())
6465
})
6566
})
@@ -85,7 +86,7 @@ var _ = Describe("ActionClient", func() {
8586
obj = testutil.BuildTestCR(gvk)
8687
})
8788
It("should return a valid ActionClient", func() {
88-
acg := NewActionClientGetter(NewActionConfigGetter(cfg, rm, nil))
89+
acg := NewActionClientGetter(NewActionConfigGetter(cfg, rm, logr.Discard()))
8990
ac, err := acg.ActionClientFor(obj)
9091
Expect(err).To(BeNil())
9192
Expect(ac).NotTo(BeNil())
@@ -103,7 +104,7 @@ var _ = Describe("ActionClient", func() {
103104
obj = testutil.BuildTestCR(gvk)
104105

105106
var err error
106-
actionConfigGetter := NewActionConfigGetter(cfg, rm, nil)
107+
actionConfigGetter := NewActionConfigGetter(cfg, rm, logr.Discard())
107108
acg := NewActionClientGetter(actionConfigGetter)
108109
ac, err = acg.ActionClientFor(obj)
109110
Expect(err).To(BeNil())

pkg/client/actionconfig.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (acg *actionConfigGetter) ActionConfigFor(obj client.Object) (*action.Confi
6060

6161
// Setup the debug log function that Helm will use
6262
debugLog := func(format string, v ...interface{}) {
63-
if acg.log != nil {
63+
if acg.log.GetSink() != nil {
6464
acg.log.V(1).Info(fmt.Sprintf(format, v...))
6565
}
6666
}

pkg/client/actionconfig_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package client
1818

1919
import (
20+
"github.com/go-logr/logr"
2021
. "github.com/onsi/ginkgo"
2122
. "github.com/onsi/gomega"
2223
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -28,7 +29,7 @@ import (
2829
var _ = Describe("ActionConfig", func() {
2930
var _ = Describe("NewActionConfigGetter", func() {
3031
It("should return a valid ActionConfigGetter", func() {
31-
Expect(NewActionConfigGetter(nil, nil, nil)).NotTo(BeNil())
32+
Expect(NewActionConfigGetter(nil, nil, logr.Discard())).NotTo(BeNil())
3233
})
3334
})
3435

@@ -41,7 +42,7 @@ var _ = Describe("ActionConfig", func() {
4142
rm, err := apiutil.NewDiscoveryRESTMapper(cfg)
4243
Expect(err).To(BeNil())
4344

44-
acg := NewActionConfigGetter(cfg, rm, nil)
45+
acg := NewActionConfigGetter(cfg, rm, logr.Discard())
4546
ac, err := acg.ActionConfigFor(obj)
4647
Expect(err).To(BeNil())
4748
Expect(ac).NotTo(BeNil())

0 commit comments

Comments
 (0)