From 74044c4d304217ff5fba9a4e7592958b7be5559e Mon Sep 17 00:00:00 2001 From: liamfallon Date: Tue, 23 Apr 2024 13:39:01 +0100 Subject: [PATCH 1/4] Upgrade Nephio to Go 1.22 --- Makefile | 2 +- controllers/pkg/cluster/capi/capi.go | 2 +- controllers/pkg/go.mod | 2 +- controllers/pkg/porch/util/packagevariant_test.go | 7 ++++--- controllers/pkg/reconcilers/token/reconciler.go | 2 +- default-go-lint.mk | 2 +- default-go-test.mk | 4 ++-- krm-functions/configinject-fn/Dockerfile | 2 +- krm-functions/configinject-fn/fn/function.go | 2 +- krm-functions/configinject-fn/go.mod | 2 +- krm-functions/dnn-fn/Dockerfile | 2 +- krm-functions/dnn-fn/fn/function.go | 2 +- krm-functions/dnn-fn/go.mod | 2 +- krm-functions/gen-configmap-fn/Dockerfile | 2 +- krm-functions/gen-configmap-fn/go.mod | 2 +- krm-functions/interface-fn/Dockerfile | 2 +- krm-functions/interface-fn/fn/function.go | 6 +++--- krm-functions/interface-fn/go.mod | 2 +- krm-functions/ipam-fn/Dockerfile | 2 +- krm-functions/ipam-fn/go.mod | 2 +- krm-functions/lib/go.mod | 2 +- krm-functions/lib/kubeobject/kubeobject.go | 3 +-- krm-functions/lib/kubeobject/lists.go | 3 +-- krm-functions/lib/nad/v1/nad_test.go | 7 ++++--- krm-functions/nad-fn/Dockerfile | 2 +- krm-functions/nad-fn/fn/function.go | 4 ++-- krm-functions/nad-fn/go.mod | 2 +- krm-functions/nfdeploy-fn/Dockerfile | 2 +- krm-functions/nfdeploy-fn/fn/function.go | 2 +- krm-functions/nfdeploy-fn/go.mod | 2 +- krm-functions/pipeline-tests/go.mod | 2 +- krm-functions/ueransim-deploy-fn/Dockerfile | 2 +- krm-functions/ueransim-deploy-fn/fn/function.go | 12 ++++++------ krm-functions/ueransim-deploy-fn/go.mod | 2 +- krm-functions/vlan-fn/Dockerfile | 2 +- krm-functions/vlan-fn/go.mod | 2 +- operators/nephio-controller-manager/Dockerfile | 2 +- operators/nephio-controller-manager/go.mod | 2 +- testing/mockeryutils/go.mod | 2 +- 39 files changed, 54 insertions(+), 54 deletions(-) diff --git a/Makefile b/Makefile index d07232fb..1c4fd040 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ .SHELLFLAGS = -ec -GO_VERSION ?= 1.20.2 +GO_VERSION ?= 1.22.2 IMG_REGISTRY ?= docker.io/nephio # find all subdirectories with a go.mod file in them diff --git a/controllers/pkg/cluster/capi/capi.go b/controllers/pkg/cluster/capi/capi.go index 12ca8c7d..85023eaf 100644 --- a/controllers/pkg/cluster/capi/capi.go +++ b/controllers/pkg/cluster/capi/capi.go @@ -61,7 +61,7 @@ func (r *Capi) isCapiClusterReady(ctx context.Context) bool { r.l = log.FromContext(ctx) name := r.GetClusterName() - cl := resource.GetUnstructuredFromGVK(&schema.GroupVersionKind{Group: capiv1beta1.GroupVersion.Group, Version: capiv1beta1.GroupVersion.Version, Kind: reflect.TypeOf(capiv1beta1.Cluster{}).Name()}) + cl := resource.GetUnstructuredFromGVK(&schema.GroupVersionKind{Group: capiv1beta1.GroupVersion.Group, Version: capiv1beta1.GroupVersion.Version, Kind: reflect.TypeFor[capiv1beta1.Cluster]().Name()}) if err := r.Get(ctx, types.NamespacedName{Namespace: r.Secret.GetNamespace(), Name: name}, cl); err != nil { r.l.Error(err, "cannot get cluster") return false diff --git a/controllers/pkg/go.mod b/controllers/pkg/go.mod index bbd98b22..f98872d1 100644 --- a/controllers/pkg/go.mod +++ b/controllers/pkg/go.mod @@ -1,6 +1,6 @@ module github.com/nephio-project/nephio/controllers/pkg -go 1.20 +go 1.22 replace ( github.com/GoogleContainerTools/kpt/porch => github.com/GoogleContainerTools/kpt/porch v0.0.0-20230526213300-77a54e3b8e88 diff --git a/controllers/pkg/porch/util/packagevariant_test.go b/controllers/pkg/porch/util/packagevariant_test.go index 1f377c84..fb403655 100644 --- a/controllers/pkg/porch/util/packagevariant_test.go +++ b/controllers/pkg/porch/util/packagevariant_test.go @@ -18,14 +18,15 @@ package util import ( "context" + "reflect" + "testing" + porchapi "github.com/GoogleContainerTools/kpt/porch/api/porch/v1alpha1" pvapi "github.com/GoogleContainerTools/kpt/porch/controllers/packagevariants/api/v1alpha1" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "reflect" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/yaml" - "testing" ) type fakeClient struct { @@ -67,7 +68,7 @@ func TestPackageRevisionIsReady(t *testing.T) { { APIVersion: "config.porch.kpt.dev/v1alpha1", Controller: &tr, - Kind: reflect.TypeOf(pvapi.PackageVariant{}).Name(), + Kind: reflect.TypeFor[pvapi.PackageVariant]().Name(), Name: "wc-argocd-argocd-cluster", }, }, diff --git a/controllers/pkg/reconcilers/token/reconciler.go b/controllers/pkg/reconcilers/token/reconciler.go index 4c36f38d..1c5842e3 100644 --- a/controllers/pkg/reconcilers/token/reconciler.go +++ b/controllers/pkg/reconcilers/token/reconciler.go @@ -185,7 +185,7 @@ func (r *reconciler) createToken(ctx context.Context, giteaClient giteaclient.Gi secret := &corev1.Secret{ TypeMeta: metav1.TypeMeta{ APIVersion: corev1.SchemeGroupVersion.Identifier(), - Kind: reflect.TypeOf(corev1.Secret{}).Name(), + Kind: reflect.TypeFor[corev1.Secret]().Name(), }, ObjectMeta: metav1.ObjectMeta{ Namespace: cr.GetNamespace(), diff --git a/default-go-lint.mk b/default-go-lint.mk index a0c8cfa4..216786f2 100644 --- a/default-go-lint.mk +++ b/default-go-lint.mk @@ -13,7 +13,7 @@ # limitations under the License. -GOLANG_CI_VER ?= v1.52 +GOLANG_CI_VER ?= v1.57 GIT_ROOT_DIR ?= $(dir $(lastword $(MAKEFILE_LIST))) include $(GIT_ROOT_DIR)/detect-container-runtime.mk diff --git a/default-go-test.mk b/default-go-test.mk index 3c49577a..832dfc84 100644 --- a/default-go-test.mk +++ b/default-go-test.mk @@ -13,7 +13,7 @@ # limitations under the License. -GO_VERSION ?= 1.20.2 +GO_VERSION ?= 1.22.2 TEST_COVERAGE_FILE=lcov.info TEST_COVERAGE_HTML_FILE=coverage_unit.html TEST_COVERAGE_FUNC_FILE=func_coverage.out @@ -28,7 +28,7 @@ unit: test .PHONY: test test: ## Run unit tests (go test) ifeq ($(CONTAINER_RUNNABLE), 0) - $(RUN_CONTAINER_COMMAND) docker.io/library/golang:${GO_VERSION}-alpine3.17 \ + $(RUN_CONTAINER_COMMAND) docker.io/library/golang:${GO_VERSION}-alpine3.19 \ sh -e -c "go test ./... -v -coverprofile ${TEST_COVERAGE_FILE}; \ go tool cover -html=${TEST_COVERAGE_FILE} -o ${TEST_COVERAGE_HTML_FILE}; \ go tool cover -func=${TEST_COVERAGE_FILE} -o ${TEST_COVERAGE_FUNC_FILE}" diff --git a/krm-functions/configinject-fn/Dockerfile b/krm-functions/configinject-fn/Dockerfile index cf3b17f4..4109c928 100644 --- a/krm-functions/configinject-fn/Dockerfile +++ b/krm-functions/configinject-fn/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM golang:1.20-alpine +FROM golang:1.22-alpine ENV CGO_ENABLED=0 WORKDIR /go/src/ COPY krm-functions/ krm-functions/ diff --git a/krm-functions/configinject-fn/fn/function.go b/krm-functions/configinject-fn/fn/function.go index 4963e367..f4b9ff80 100644 --- a/krm-functions/configinject-fn/fn/function.go +++ b/krm-functions/configinject-fn/fn/function.go @@ -63,7 +63,7 @@ func New(c client.Client) *FnR { Owns: map[corev1.ObjectReference]condkptsdk.ResourceKind{ { APIVersion: nephiorefv1alpha1.GroupVersion.Identifier(), - Kind: reflect.TypeOf(nephiorefv1alpha1.Config{}).Name(), + Kind: reflect.TypeFor[nephiorefv1alpha1.Config]().Name(), }: condkptsdk.ChildLocal, }, Watch: map[corev1.ObjectReference]condkptsdk.WatchCallbackFn{ diff --git a/krm-functions/configinject-fn/go.mod b/krm-functions/configinject-fn/go.mod index ea26389d..5d37b7a2 100644 --- a/krm-functions/configinject-fn/go.mod +++ b/krm-functions/configinject-fn/go.mod @@ -1,6 +1,6 @@ module github.com/nephio-project/nephio/krm-functions/configinject-fn -go 1.20 +go 1.22 replace github.com/nephio-project/nephio/krm-functions/lib => ../lib diff --git a/krm-functions/dnn-fn/Dockerfile b/krm-functions/dnn-fn/Dockerfile index 730d2012..1e20565d 100644 --- a/krm-functions/dnn-fn/Dockerfile +++ b/krm-functions/dnn-fn/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM golang:1.20-alpine +FROM golang:1.22-alpine ENV CGO_ENABLED=0 WORKDIR /go/src/ COPY krm-functions/ krm-functions/ diff --git a/krm-functions/dnn-fn/fn/function.go b/krm-functions/dnn-fn/fn/function.go index ffdf97d9..6ec46c3d 100644 --- a/krm-functions/dnn-fn/fn/function.go +++ b/krm-functions/dnn-fn/fn/function.go @@ -69,7 +69,7 @@ func Run(rl *fn.ResourceList) (bool, error) { Watch: map[corev1.ObjectReference]condkptsdk.WatchCallbackFn{ { APIVersion: infrav1alpha1.GroupVersion.Identifier(), - Kind: reflect.TypeOf(infrav1alpha1.WorkloadCluster{}).Name(), + Kind: reflect.TypeFor[infrav1alpha1.WorkloadCluster]().Name(), }: myFn.WorkloadClusterCallbackFn, }, PopulateOwnResourcesFn: myFn.desiredOwnedResourceList, diff --git a/krm-functions/dnn-fn/go.mod b/krm-functions/dnn-fn/go.mod index 62997e84..a2b7a35f 100644 --- a/krm-functions/dnn-fn/go.mod +++ b/krm-functions/dnn-fn/go.mod @@ -1,6 +1,6 @@ module github.com/nephio-project/nephio/krm-functions/dnn-fn -go 1.20 +go 1.22 replace github.com/nephio-project/nephio/krm-functions/lib => ../lib diff --git a/krm-functions/gen-configmap-fn/Dockerfile b/krm-functions/gen-configmap-fn/Dockerfile index e9f55093..07426245 100644 --- a/krm-functions/gen-configmap-fn/Dockerfile +++ b/krm-functions/gen-configmap-fn/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM golang:1.20-alpine +FROM golang:1.22-alpine ENV CGO_ENABLED=0 WORKDIR /go/src/ COPY krm-functions/ krm-functions/ diff --git a/krm-functions/gen-configmap-fn/go.mod b/krm-functions/gen-configmap-fn/go.mod index 1d9a6dd7..c2cf970c 100644 --- a/krm-functions/gen-configmap-fn/go.mod +++ b/krm-functions/gen-configmap-fn/go.mod @@ -1,6 +1,6 @@ module github.com/nephio-project/nephio/krm-functions/gen-configmap-fn -go 1.20 +go 1.22 replace github.com/nephio-project/nephio/krm-functions/lib => ../lib diff --git a/krm-functions/interface-fn/Dockerfile b/krm-functions/interface-fn/Dockerfile index f3e09c3a..1a47b91a 100644 --- a/krm-functions/interface-fn/Dockerfile +++ b/krm-functions/interface-fn/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM golang:1.20-alpine +FROM golang:1.22-alpine ENV CGO_ENABLED=0 WORKDIR /go/src/ COPY krm-functions/ krm-functions/ diff --git a/krm-functions/interface-fn/fn/function.go b/krm-functions/interface-fn/fn/function.go index 61f38b6e..d46c2708 100644 --- a/krm-functions/interface-fn/fn/function.go +++ b/krm-functions/interface-fn/fn/function.go @@ -56,7 +56,7 @@ func Run(rl *fn.ResourceList) (bool, error) { Owns: map[corev1.ObjectReference]condkptsdk.ResourceKind{ { APIVersion: nadv1.SchemeGroupVersion.Identifier(), - Kind: reflect.TypeOf(nadv1.NetworkAttachmentDefinition{}).Name(), + Kind: reflect.TypeFor[nadv1.NetworkAttachmentDefinition]().Name(), }: condkptsdk.ChildRemoteCondition, { APIVersion: ipamv1alpha1.GroupVersion.Identifier(), @@ -70,7 +70,7 @@ func Run(rl *fn.ResourceList) (bool, error) { Watch: map[corev1.ObjectReference]condkptsdk.WatchCallbackFn{ { APIVersion: infrav1alpha1.GroupVersion.Identifier(), - Kind: reflect.TypeOf(infrav1alpha1.WorkloadCluster{}).Name(), + Kind: reflect.TypeFor[infrav1alpha1.WorkloadCluster]().Name(), }: myFn.WorkloadClusterCallbackFn, }, PopulateOwnResourcesFn: myFn.desiredOwnedResourceList, @@ -289,7 +289,7 @@ func BuildNetworkAttachmentDefinition(meta metav1.ObjectMeta, spec nadv1.Network return &nadv1.NetworkAttachmentDefinition{ TypeMeta: metav1.TypeMeta{ APIVersion: nadv1.SchemeGroupVersion.Identifier(), - Kind: reflect.TypeOf(nadv1.NetworkAttachmentDefinition{}).Name(), + Kind: reflect.TypeFor[nadv1.NetworkAttachmentDefinition]().Name(), }, ObjectMeta: meta, Spec: spec, diff --git a/krm-functions/interface-fn/go.mod b/krm-functions/interface-fn/go.mod index 598a16f5..0866e88b 100644 --- a/krm-functions/interface-fn/go.mod +++ b/krm-functions/interface-fn/go.mod @@ -1,6 +1,6 @@ module github.com/nephio-project/nephio/krm-functions/interface-fn -go 1.20 +go 1.22 replace github.com/nephio-project/nephio/krm-functions/lib => ../lib diff --git a/krm-functions/ipam-fn/Dockerfile b/krm-functions/ipam-fn/Dockerfile index be57f25c..b986a71a 100644 --- a/krm-functions/ipam-fn/Dockerfile +++ b/krm-functions/ipam-fn/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM golang:1.20-alpine +FROM golang:1.22-alpine ENV CGO_ENABLED=0 WORKDIR /go/src/ COPY krm-functions/ krm-functions/ diff --git a/krm-functions/ipam-fn/go.mod b/krm-functions/ipam-fn/go.mod index ab2f37ea..c80a4523 100644 --- a/krm-functions/ipam-fn/go.mod +++ b/krm-functions/ipam-fn/go.mod @@ -1,6 +1,6 @@ module github.com/nephio-project/nephio/krm-functions/ipam-fn -go 1.20 +go 1.22 replace github.com/nephio-project/nephio/krm-functions/lib => ../lib diff --git a/krm-functions/lib/go.mod b/krm-functions/lib/go.mod index 15d9fb57..0d699bb4 100644 --- a/krm-functions/lib/go.mod +++ b/krm-functions/lib/go.mod @@ -1,6 +1,6 @@ module github.com/nephio-project/nephio/krm-functions/lib -go 1.20 +go 1.22 require ( github.com/GoogleContainerTools/kpt v1.0.0-beta.29.0.20230327202912-01513604feaa diff --git a/krm-functions/lib/kubeobject/kubeobject.go b/krm-functions/lib/kubeobject/kubeobject.go index 55dc726b..4c12b872 100644 --- a/krm-functions/lib/kubeobject/kubeobject.go +++ b/krm-functions/lib/kubeobject/kubeobject.go @@ -158,8 +158,7 @@ func (o *KubeObjectExt[T1]) getFieldOrPanic(value *T1, fieldName string) interfa } func validateTypeOrPanic[T1 any]() { - var x T1 - v := reflect.TypeOf(x) + v := reflect.TypeFor[T1]() if v.Kind() != reflect.Struct { panic(fmt.Sprintf("type %q is not a struct", v.Name())) } diff --git a/krm-functions/lib/kubeobject/lists.go b/krm-functions/lib/kubeobject/lists.go index 41a0b0bd..8160cb75 100644 --- a/krm-functions/lib/kubeobject/lists.go +++ b/krm-functions/lib/kubeobject/lists.go @@ -83,8 +83,7 @@ func GetSingleton[T any, PT PtrIsRuntimeObject[T]](objs fn.KubeObjects) (*T, err return nil, err } if len(typedObjs) != 1 { - var x T - return nil, fmt.Errorf("expected exactly 1 instance of %v in the kpt package, but got %v", reflect.TypeOf(x).Name(), len(typedObjs)) + return nil, fmt.Errorf("expected exactly 1 instance of %v in the kpt package, but got %v", reflect.TypeFor[T]().Name(), len(typedObjs)) } return typedObjs[0], nil } diff --git a/krm-functions/lib/nad/v1/nad_test.go b/krm-functions/lib/nad/v1/nad_test.go index 25bf933b..f37ebeec 100644 --- a/krm-functions/lib/nad/v1/nad_test.go +++ b/krm-functions/lib/nad/v1/nad_test.go @@ -17,14 +17,15 @@ limitations under the License. package v1 import ( + "reflect" + "testing" + "github.com/GoogleContainerTools/kpt-functions-sdk/go/fn" "github.com/google/go-cmp/cmp" nadv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1" "github.com/stretchr/testify/assert" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "reflect" "sigs.k8s.io/yaml" - "testing" ) var nadTestSriov = `apiVersion: "k8s.cni.cncf.io/v1" @@ -105,7 +106,7 @@ func TestNewFromGoStruct(t *testing.T) { input: &nadv1.NetworkAttachmentDefinition{ TypeMeta: metav1.TypeMeta{ APIVersion: nadv1.SchemeGroupVersion.Identifier(), - Kind: reflect.TypeOf(nadv1.NetworkAttachmentDefinition{}).Name(), + Kind: reflect.TypeFor[nadv1.NetworkAttachmentDefinition]().Name(), }, ObjectMeta: metav1.ObjectMeta{ Name: "a", diff --git a/krm-functions/nad-fn/Dockerfile b/krm-functions/nad-fn/Dockerfile index ee6ceb0c..73fa90c7 100644 --- a/krm-functions/nad-fn/Dockerfile +++ b/krm-functions/nad-fn/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM golang:1.20-alpine +FROM golang:1.22-alpine ENV CGO_ENABLED=0 WORKDIR /go/src/ COPY krm-functions/ krm-functions/ diff --git a/krm-functions/nad-fn/fn/function.go b/krm-functions/nad-fn/fn/function.go index e3bd0270..d9b0d755 100644 --- a/krm-functions/nad-fn/fn/function.go +++ b/krm-functions/nad-fn/fn/function.go @@ -55,7 +55,7 @@ func Run(rl *fn.ResourceList) (bool, error) { &condkptsdk.Config{ For: corev1.ObjectReference{ APIVersion: nadv1.SchemeGroupVersion.Identifier(), - Kind: reflect.TypeOf(nadv1.NetworkAttachmentDefinition{}).Name(), + Kind: reflect.TypeFor[nadv1.NetworkAttachmentDefinition]().Name(), }, Watch: map[corev1.ObjectReference]condkptsdk.WatchCallbackFn{ { @@ -168,7 +168,7 @@ func (f *nadFn) updateResourceFn(_ *fn.KubeObject, objs fn.KubeObjects) (fn.Kube nad, err := nadlibv1.NewFromGoStruct(&nadv1.NetworkAttachmentDefinition{ TypeMeta: metav1.TypeMeta{ APIVersion: nadv1.SchemeGroupVersion.Identifier(), - Kind: reflect.TypeOf(nadv1.NetworkAttachmentDefinition{}).Name(), + Kind: reflect.TypeFor[nadv1.NetworkAttachmentDefinition]().Name(), }, ObjectMeta: metav1.ObjectMeta{Name: fmt.Sprintf("%s-%s", f.forName, interfaceObjs[0].GetName()), Namespace: f.forNamespace}, }) diff --git a/krm-functions/nad-fn/go.mod b/krm-functions/nad-fn/go.mod index 76282ec9..680b5446 100644 --- a/krm-functions/nad-fn/go.mod +++ b/krm-functions/nad-fn/go.mod @@ -1,6 +1,6 @@ module github.com/nephio-project/nephio/krm-functions/nad-fn -go 1.20 +go 1.22 replace github.com/nephio-project/nephio/krm-functions/lib => ../lib diff --git a/krm-functions/nfdeploy-fn/Dockerfile b/krm-functions/nfdeploy-fn/Dockerfile index e896e680..f8bdd12b 100644 --- a/krm-functions/nfdeploy-fn/Dockerfile +++ b/krm-functions/nfdeploy-fn/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM golang:1.20-alpine +FROM golang:1.22-alpine ENV CGO_ENABLED=0 WORKDIR /go/src/ COPY krm-functions/ krm-functions/ diff --git a/krm-functions/nfdeploy-fn/fn/function.go b/krm-functions/nfdeploy-fn/fn/function.go index fa502894..faec2818 100644 --- a/krm-functions/nfdeploy-fn/fn/function.go +++ b/krm-functions/nfdeploy-fn/fn/function.go @@ -74,7 +74,7 @@ func Run(rl *fn.ResourceList) (bool, error) { Watch: map[corev1.ObjectReference]condkptsdk.WatchCallbackFn{ { APIVersion: infrav1alpha1.GroupVersion.Identifier(), - Kind: reflect.TypeOf(infrav1alpha1.WorkloadCluster{}).Name(), + Kind: reflect.TypeFor[infrav1alpha1.WorkloadCluster]().Name(), }: nfDeployFn.WorkloadClusterCallbackFn, }, PopulateOwnResourcesFn: nfDeployFn.desiredOwnedResourceList, diff --git a/krm-functions/nfdeploy-fn/go.mod b/krm-functions/nfdeploy-fn/go.mod index 477048fb..9d49f3e1 100644 --- a/krm-functions/nfdeploy-fn/go.mod +++ b/krm-functions/nfdeploy-fn/go.mod @@ -1,6 +1,6 @@ module github.com/nephio-project/nephio/krm-functions/nfdeploy-fn -go 1.20 +go 1.22 replace github.com/nephio-project/nephio/krm-functions/lib => ../lib diff --git a/krm-functions/pipeline-tests/go.mod b/krm-functions/pipeline-tests/go.mod index 50a94351..88177bcd 100644 --- a/krm-functions/pipeline-tests/go.mod +++ b/krm-functions/pipeline-tests/go.mod @@ -1,6 +1,6 @@ module github.com/nephio-project/nephio/krm-functions/pipeline-tests -go 1.20 +go 1.22 // always test the latest versions of all functions/libs replace ( diff --git a/krm-functions/ueransim-deploy-fn/Dockerfile b/krm-functions/ueransim-deploy-fn/Dockerfile index 8f7dc7f2..0cc10029 100644 --- a/krm-functions/ueransim-deploy-fn/Dockerfile +++ b/krm-functions/ueransim-deploy-fn/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM golang:1.20-alpine +FROM golang:1.22-alpine ENV CGO_ENABLED=0 WORKDIR /go/src/ COPY krm-functions/ krm-functions/ diff --git a/krm-functions/ueransim-deploy-fn/fn/function.go b/krm-functions/ueransim-deploy-fn/fn/function.go index 7cad5ccc..e72e135e 100644 --- a/krm-functions/ueransim-deploy-fn/fn/function.go +++ b/krm-functions/ueransim-deploy-fn/fn/function.go @@ -48,7 +48,7 @@ func Run(rl *fn.ResourceList) (bool, error) { &condkptsdk.Config{ For: corev1.ObjectReference{ APIVersion: appsv1.SchemeGroupVersion.Identifier(), - Kind: reflect.TypeOf(appsv1.Deployment{}).Name(), + Kind: reflect.TypeFor[appsv1.Deployment]().Name(), }, Owns: map[corev1.ObjectReference]condkptsdk.ResourceKind{ { @@ -61,17 +61,17 @@ func Run(rl *fn.ResourceList) (bool, error) { }: condkptsdk.ChildInitial, { APIVersion: corev1.SchemeGroupVersion.Identifier(), - Kind: reflect.TypeOf(corev1.ConfigMap{}).Name(), + Kind: reflect.TypeFor[corev1.ConfigMap]().Name(), }: condkptsdk.ChildLocal, { APIVersion: corev1.SchemeGroupVersion.Identifier(), - Kind: reflect.TypeOf(corev1.Service{}).Name(), + Kind: reflect.TypeFor[corev1.Service]().Name(), }: condkptsdk.ChildLocal, }, Watch: map[corev1.ObjectReference]condkptsdk.WatchCallbackFn{ { APIVersion: infrav1alpha1.GroupVersion.Identifier(), - Kind: reflect.TypeOf(infrav1alpha1.WorkloadCluster{}).Name(), + Kind: reflect.TypeFor[infrav1alpha1.WorkloadCluster]().Name(), }: myFn.WorkloadClusterCallbackFn, }, PopulateOwnResourcesFn: myFn.desiredOwnedResourceList, @@ -324,7 +324,7 @@ func buildConfigMapKubeObject(meta metav1.ObjectMeta, key, value string) (*fn.Ku o := &corev1.ConfigMap{ TypeMeta: metav1.TypeMeta{ APIVersion: corev1.SchemeGroupVersion.Identifier(), - Kind: reflect.TypeOf(corev1.ConfigMap{}).Name(), + Kind: reflect.TypeFor[corev1.ConfigMap]().Name(), }, ObjectMeta: meta, Data: map[string]string{ @@ -339,7 +339,7 @@ func buildServiceKubeObject(meta metav1.ObjectMeta, spec corev1.ServiceSpec) (*f o := &corev1.Service{ TypeMeta: metav1.TypeMeta{ APIVersion: corev1.SchemeGroupVersion.Identifier(), - Kind: reflect.TypeOf(corev1.Service{}).Name(), + Kind: reflect.TypeFor[corev1.Service]().Name(), }, ObjectMeta: meta, Spec: spec, diff --git a/krm-functions/ueransim-deploy-fn/go.mod b/krm-functions/ueransim-deploy-fn/go.mod index 83d418aa..76745181 100644 --- a/krm-functions/ueransim-deploy-fn/go.mod +++ b/krm-functions/ueransim-deploy-fn/go.mod @@ -1,6 +1,6 @@ module github.com/nephio-project/nephio/krm-functions/ueransim-deploy-fn -go 1.20 +go 1.22 replace github.com/nephio-project/nephio/krm-functions/lib => ../lib diff --git a/krm-functions/vlan-fn/Dockerfile b/krm-functions/vlan-fn/Dockerfile index 093ec49b..7dfed652 100644 --- a/krm-functions/vlan-fn/Dockerfile +++ b/krm-functions/vlan-fn/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM golang:1.20-alpine +FROM golang:1.22-alpine ENV CGO_ENABLED=0 WORKDIR /go/src/ COPY krm-functions/ krm-functions/ diff --git a/krm-functions/vlan-fn/go.mod b/krm-functions/vlan-fn/go.mod index aad5adf1..bc063929 100644 --- a/krm-functions/vlan-fn/go.mod +++ b/krm-functions/vlan-fn/go.mod @@ -1,6 +1,6 @@ module github.com/nephio-project/nephio/krm-functions/vlan-fn -go 1.20 +go 1.22 replace github.com/nephio-project/nephio/krm-functions/lib => ../lib diff --git a/operators/nephio-controller-manager/Dockerfile b/operators/nephio-controller-manager/Dockerfile index 606d6658..20595d39 100644 --- a/operators/nephio-controller-manager/Dockerfile +++ b/operators/nephio-controller-manager/Dockerfile @@ -1,5 +1,5 @@ # Build the manager binary -FROM golang:1.20 as builder +FROM golang:1.22 as builder ARG TARGETOS ARG TARGETARCH diff --git a/operators/nephio-controller-manager/go.mod b/operators/nephio-controller-manager/go.mod index 32ca7aa5..b57aa2aa 100644 --- a/operators/nephio-controller-manager/go.mod +++ b/operators/nephio-controller-manager/go.mod @@ -1,6 +1,6 @@ module github.com/nephio-project/nephio/operators/nephio-controller-manager -go 1.20 +go 1.22 replace ( github.com/GoogleContainerTools/kpt/porch => github.com/GoogleContainerTools/kpt/porch v0.0.0-20230526213300-77a54e3b8e88 diff --git a/testing/mockeryutils/go.mod b/testing/mockeryutils/go.mod index 8725128a..aa910e4f 100644 --- a/testing/mockeryutils/go.mod +++ b/testing/mockeryutils/go.mod @@ -1,6 +1,6 @@ module github.com/nephio-project/nephio/testing/mockeryutils -go 1.20 +go 1.22 require github.com/stretchr/testify v1.8.4 From 2fe0d673bf90382fff43178944d65c62c6d52b7c Mon Sep 17 00:00:00 2001 From: liamfallon Date: Thu, 25 Apr 2024 07:07:42 +0100 Subject: [PATCH 2/4] Revert linting upgrade to remove lint errors --- default-go-lint.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default-go-lint.mk b/default-go-lint.mk index 216786f2..a0c8cfa4 100644 --- a/default-go-lint.mk +++ b/default-go-lint.mk @@ -13,7 +13,7 @@ # limitations under the License. -GOLANG_CI_VER ?= v1.57 +GOLANG_CI_VER ?= v1.52 GIT_ROOT_DIR ?= $(dir $(lastword $(MAKEFILE_LIST))) include $(GIT_ROOT_DIR)/detect-container-runtime.mk From 43da889d31680a7476a500c667537d7e59422302 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Thu, 25 Apr 2024 08:58:07 +0100 Subject: [PATCH 3/4] Restore linting version upgrade --- default-go-lint.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default-go-lint.mk b/default-go-lint.mk index a0c8cfa4..216786f2 100644 --- a/default-go-lint.mk +++ b/default-go-lint.mk @@ -13,7 +13,7 @@ # limitations under the License. -GOLANG_CI_VER ?= v1.52 +GOLANG_CI_VER ?= v1.57 GIT_ROOT_DIR ?= $(dir $(lastword $(MAKEFILE_LIST))) include $(GIT_ROOT_DIR)/detect-container-runtime.mk From 9b8de7e8c701534f38310d3170324a04bf38aadf Mon Sep 17 00:00:00 2001 From: liamfallon Date: Sun, 28 Apr 2024 11:30:59 +0100 Subject: [PATCH 4/4] Ignore fals positive security checks --- krm-functions/lib/condkptsdk/sdk_stage1_update_children.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/krm-functions/lib/condkptsdk/sdk_stage1_update_children.go b/krm-functions/lib/condkptsdk/sdk_stage1_update_children.go index 7a2c1134..2519a084 100644 --- a/krm-functions/lib/condkptsdk/sdk_stage1_update_children.go +++ b/krm-functions/lib/condkptsdk/sdk_stage1_update_children.go @@ -133,6 +133,7 @@ func (r *sdk) updateChildren() { for _, obj := range diff.createObjs { if r.debug { fn.Logf("stage1: diff action -> create obj: ref: %s, ownkind: %s\n", kptfilelibv1.GetConditionType(&obj.ref), obj.ownKind) + // #nosec G601 } status := kptv1.ConditionFalse if obj.ownKind == ChildLocal { @@ -151,6 +152,7 @@ func (r *sdk) updateChildren() { for _, obj := range diff.updateObjs { if r.debug { fn.Logf("stage1: diff action -> update obj: %s\n", kptfilelibv1.GetConditionType(&obj.ref)) + // #nosec G601 } if err := r.upsertChildObject(ownGVKKind, []corev1.ObjectReference{forRef, obj.ref}, obj, nil, "update resource", kptv1.ConditionFalse, false); err != nil { // the errors are already logged, we set the result in the for condition @@ -163,6 +165,7 @@ func (r *sdk) updateChildren() { for _, obj := range diff.deleteObjs { if r.debug { fn.Logf("stage1: diff action -> delete obj: %s\n", kptfilelibv1.GetConditionType(&obj.ref)) + // #nosec G601 } if err := r.deleteChildObject(ownGVKKind, []corev1.ObjectReference{forRef, obj.ref}, obj, "delete resource"); err != nil { // the errors are already logged, we set the result in the for condition