diff --git a/.golangci.yml b/.golangci.yml index a4e69f6ae1..7fc78a2a17 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -47,7 +47,7 @@ linters: settings: goconst: min-len: 4 - min-occurrences: 5 + min-occurrences: 10 ignore-calls: true numbers: false lll: diff --git a/go.mod b/go.mod index 0ff7c537dd..b815d371f3 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/apache/camel-k/v2 -go 1.25.9 +go 1.26.2 require ( dario.cat/mergo v1.0.2 @@ -40,17 +40,17 @@ require ( golang.org/x/text v0.36.0 golang.org/x/time v0.15.0 gopkg.in/yaml.v2 v2.4.0 - k8s.io/api v0.35.4 - k8s.io/apimachinery v0.35.4 - k8s.io/cli-runtime v0.35.3 - k8s.io/client-go v0.35.4 + k8s.io/api v0.36.0 + k8s.io/apimachinery v0.36.0 + k8s.io/cli-runtime v0.36.0 + k8s.io/client-go v0.36.0 k8s.io/gengo v0.0.0-20251215205346-5ee0d033ba5b k8s.io/klog/v2 v2.140.0 k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2 knative.dev/eventing v0.49.0 knative.dev/pkg v0.0.0-20260422015212-ec452872dcc1 knative.dev/serving v0.49.0 - sigs.k8s.io/controller-runtime v0.23.3 + sigs.k8s.io/controller-runtime v0.24.0 sigs.k8s.io/gateway-api v1.5.1 sigs.k8s.io/structured-merge-diff/v6 v6.4.0 ) @@ -94,7 +94,6 @@ require ( github.com/go-openapi/swag/yamlutils v0.25.4 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect - github.com/google/btree v1.1.3 // indirect github.com/google/gnostic-models v0.7.1 // indirect github.com/google/go-cmp v0.7.0 // indirect github.com/google/go-containerregistry v0.20.3 // indirect @@ -112,7 +111,6 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/pelletier/go-toml/v2 v2.2.4 // indirect github.com/pjbgf/sha1cd v0.3.2 // indirect @@ -143,13 +141,14 @@ require ( golang.org/x/sys v0.43.0 // indirect golang.org/x/tools v0.44.0 // indirect gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect - google.golang.org/protobuf v1.36.11 // indirect + google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af // indirect gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/apiextensions-apiserver v0.35.4 // indirect + k8s.io/apiextensions-apiserver v0.36.0 // indirect k8s.io/kube-openapi v0.0.0-20260317180543-43fb72c5454a // indirect + k8s.io/streaming v0.36.0 // indirect knative.dev/networking v0.0.0-20260422140718-e9578ef11562 // indirect sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect sigs.k8s.io/randfill v1.0.0 // indirect diff --git a/go.sum b/go.sum index caeb4b0a5e..c982884a5d 100644 --- a/go.sum +++ b/go.sum @@ -136,8 +136,6 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg= -github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= github.com/google/gnostic-models v0.7.1 h1:SisTfuFKJSKM5CPZkffwi6coztzzeYUhc3v4yxLWH8c= github.com/google/gnostic-models v0.7.1/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -216,8 +214,6 @@ github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee h1:W5t00kpgFd github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus= -github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1 h1:mFwc4LvZ0xpSvDZ3E+k8Yte0hLOMxXUlP+yXtJqkYfQ= @@ -445,8 +441,8 @@ google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQ google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= -google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= +google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af h1:+5/Sw3GsDNlEmu7TfklWKPdQ0Ykja5VEmq2i817+jbI= +google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= @@ -468,18 +464,18 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.35.4 h1:P7nFYKl5vo9AGUp1Z+Pmd3p2tA7bX2wbFWCvDeRv988= -k8s.io/api v0.35.4/go.mod h1:yl4lqySWOgYJJf9RERXKUwE9g2y+CkuwG+xmcOK8wXU= -k8s.io/apiextensions-apiserver v0.35.4 h1:HeP+Upp7ItdvnyGmub0yoix+2z5+ev4M5cE5TCgtOUU= -k8s.io/apiextensions-apiserver v0.35.4/go.mod h1:ogQlk+stIE8mnoRthSYCwlOS12fVqgWFiErMwPaXA7c= -k8s.io/apimachinery v0.35.4 h1:xtdom9RG7e+yDp71uoXoJDWEE2eOiHgeO4GdBzwWpds= -k8s.io/apimachinery v0.35.4/go.mod h1:NNi1taPOpep0jOj+oRha3mBJPqvi0hGdaV8TCqGQ+cc= -k8s.io/apiserver v0.35.4 h1:vtuFqNFmF9bPRdHDL2lpK6qCTPWDreZJL4LRPwVM6ho= -k8s.io/apiserver v0.35.4/go.mod h1:JnBcb+J8kFXKpZkgcbcUnPBBHi4qgBii1I7dLxFY/oo= -k8s.io/cli-runtime v0.35.3 h1:UZq4ipNimtzBmhN7PPKbfAdqo8quK0H0UdGl6qAQnqI= -k8s.io/cli-runtime v0.35.3/go.mod h1:O7MUmCqcKSd5xI+O5X7/pRkB5l0O2NIhOdUVwbHLXu4= -k8s.io/client-go v0.35.4 h1:DN6fyaGuzK64UvnKO5fOA6ymSjvfGAnCAHAR0C66kD8= -k8s.io/client-go v0.35.4/go.mod h1:2Pg9WpsS4NeOpoYTfHHfMxBG8zFMSAUi4O/qoiJC3nY= +k8s.io/api v0.36.0 h1:SgqDhZzHdOtMk40xVSvCXkP9ME0H05hPM3p9AB1kL80= +k8s.io/api v0.36.0/go.mod h1:m1LVrGPNYax5NBHdO+QuAedXyuzTt4RryI/qnmNvs34= +k8s.io/apiextensions-apiserver v0.36.0 h1:Wt7E8J+VBCbj4FjiBfDTK/neXDDjyJVJc7xfuOHImZ0= +k8s.io/apiextensions-apiserver v0.36.0/go.mod h1:kGDjH0msuiIB3tgsYRV0kS9GqpMYMUsQ3GHv7TApyug= +k8s.io/apimachinery v0.36.0 h1:jZyPzhd5Z+3h9vJLt0z9XdzW9VzNzWAUw+P1xZ9PXtQ= +k8s.io/apimachinery v0.36.0/go.mod h1:FklypaRJt6n5wUIwWXIP6GJlIpUizTgfo1T/As+Tyxc= +k8s.io/apiserver v0.36.0 h1:Jg5OFAENUACByUCg15CmhZAYrr5ZyJ+jodyA1mHl3YE= +k8s.io/apiserver v0.36.0/go.mod h1:mHvwdHf+qKEm+1/hYm756SV+oREOKSPnsjagOpx6Vho= +k8s.io/cli-runtime v0.36.0 h1:HNxciQpQMMOKS0/GiUXcKDyA6J2FDILJj9NmP2BZrTg= +k8s.io/cli-runtime v0.36.0/go.mod h1:KObkknK9Ro5LYX+1RdiKc7C8CvGg4aX+V/Zv+E8WPHA= +k8s.io/client-go v0.36.0 h1:pOYi7C4RHChYjMiHpZSpSbIM6ZxVbRXBy7CuiIwqA3c= +k8s.io/client-go v0.36.0/go.mod h1:ZKKcpwF0aLYfkHFCjillCKaTK/yBkEDHTDXCFY6AS9Y= k8s.io/gengo v0.0.0-20251215205346-5ee0d033ba5b h1:X0Afwan8Q1l7bMcNgh6DAah2jKCQ2irT7EoAXIChFqk= k8s.io/gengo v0.0.0-20251215205346-5ee0d033ba5b/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= @@ -487,6 +483,8 @@ k8s.io/klog/v2 v2.140.0 h1:Tf+J3AH7xnUzZyVVXhTgGhEKnFqye14aadWv7bzXdzc= k8s.io/klog/v2 v2.140.0/go.mod h1:o+/RWfJ6PwpnFn7OyAG3QnO47BFsymfEfrz6XyYSSp0= k8s.io/kube-openapi v0.0.0-20260317180543-43fb72c5454a h1:xCeOEAOoGYl2jnJoHkC3hkbPJgdATINPMAxaynU2Ovg= k8s.io/kube-openapi v0.0.0-20260317180543-43fb72c5454a/go.mod h1:uGBT7iTA6c6MvqUvSXIaYZo9ukscABYi2btjhvgKGZ0= +k8s.io/streaming v0.36.0 h1:agnTxU+NFulUrtYzXUGKO3ndEa8jKwht1Kwn9nu9x+4= +k8s.io/streaming v0.36.0/go.mod h1:z6fV3D+NVkoeqRMtWwlUZK6U17SY/LqNzOxWL6GyR/s= k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2 h1:AZYQSJemyQB5eRxqcPky+/7EdBj0xi3g0ZcxxJ7vbWU= k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2/go.mod h1:xDxuJ0whA3d0I4mf/C4ppKHxXynQ+fxnkmQH0vTHnuk= knative.dev/eventing v0.49.0 h1:Gole9D1AXnZVBCzoqO00/5n8MApy8rRJpTHYXvUFfQc= @@ -497,8 +495,8 @@ knative.dev/pkg v0.0.0-20260422015212-ec452872dcc1 h1:bO5X2bugzMqoVltm2n16mHpAdp knative.dev/pkg v0.0.0-20260422015212-ec452872dcc1/go.mod h1:EZeB2nBW4QcpZuCPB5a/UnoVIH2N+5z5fwNw1PUeqMg= knative.dev/serving v0.49.0 h1:5B1JsytwZ+5bh9vOCNnu4GQJ/m6oj61Z/rVKziAY6MA= knative.dev/serving v0.49.0/go.mod h1:KXvVnXohxsbE3rCRbr1TZlxeC20qIzhVckDwbsgLWPI= -sigs.k8s.io/controller-runtime v0.23.3 h1:VjB/vhoPoA9l1kEKZHBMnQF33tdCLQKJtydy4iqwZ80= -sigs.k8s.io/controller-runtime v0.23.3/go.mod h1:B6COOxKptp+YaUT5q4l6LqUJTRpizbgf9KSRNdQGns0= +sigs.k8s.io/controller-runtime v0.24.0 h1:Ck6N2LdS8Lovy1o25BB4r1xjvLEKUl1s2o9kU+KWDE4= +sigs.k8s.io/controller-runtime v0.24.0/go.mod h1:vFkfY5fGt5xAC/sKb8IBFKgWPNKG9OUG29dR8Y2wImw= sigs.k8s.io/gateway-api v1.5.1 h1:RqVRIlkhLhUO8wOHKTLnTJA6o/1un4po4/6M1nRzdd0= sigs.k8s.io/gateway-api v1.5.1/go.mod h1:GvCETiaMAlLym5CovLxGjS0NysqFk3+Yuq3/rh6QL2o= sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5EXP7sU1kvOlxwZh5txg= diff --git a/pkg/apis/camel/v1/camelcatalog_types.go b/pkg/apis/camel/v1/camelcatalog_types.go index 0ba20d6bf2..18734384c9 100644 --- a/pkg/apis/camel/v1/camelcatalog_types.go +++ b/pkg/apis/camel/v1/camelcatalog_types.go @@ -24,7 +24,8 @@ import ( const ( // CamelCatalogKind -- . - CamelCatalogKind string = "CamelCatalog" + CamelCatalogKind string = "CamelCatalog" + MavenQuarkusGroupID string = "org.apache.camel.quarkus" ) // +genclient diff --git a/pkg/apis/camel/v1/camelcatalog_types_support.go b/pkg/apis/camel/v1/camelcatalog_types_support.go index f7d50b2f7e..fb73204f13 100644 --- a/pkg/apis/camel/v1/camelcatalog_types_support.go +++ b/pkg/apis/camel/v1/camelcatalog_types_support.go @@ -229,7 +229,7 @@ func (c *CamelCatalogSpec) HasCapability(capability string) bool { // GetDependencyID returns a Camel K recognizable maven dependency for the artifact. func (in *CamelArtifact) GetDependencyID() string { switch { - case in.GroupID == "org.apache.camel.quarkus" && strings.HasPrefix(in.ArtifactID, "camel-quarkus-"): + case in.GroupID == MavenQuarkusGroupID && strings.HasPrefix(in.ArtifactID, "camel-quarkus-"): return "camel:" + in.ArtifactID[14:] case in.Version == "": return "mvn:" + in.GroupID + ":" + in.ArtifactID diff --git a/pkg/cmd/debug.go b/pkg/cmd/debug.go index 25a3be9f22..fc6bc34b90 100644 --- a/pkg/cmd/debug.go +++ b/pkg/cmd/debug.go @@ -33,7 +33,6 @@ import ( "github.com/spf13/cobra" k8serrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/ptr" ) func newCmdDebug(rootCmdOptions *RootCmdOptions) (*cobra.Command, *debugCmdOptions) { @@ -145,8 +144,8 @@ func (o *debugCmdOptions) toggle(it *v1.Integration, active bool) *v1.Integratio jvmTrait := it.Spec.Traits.JVM if active { - jvmTrait.Debug = ptr.To(true) - jvmTrait.DebugSuspend = ptr.To(o.Suspend) + jvmTrait.Debug = new(true) + jvmTrait.DebugSuspend = new(o.Suspend) } else { jvmTrait.Debug = nil jvmTrait.DebugSuspend = nil diff --git a/pkg/cmd/util.go b/pkg/cmd/util.go index aeb19181a8..865aa342ec 100644 --- a/pkg/cmd/util.go +++ b/pkg/cmd/util.go @@ -223,9 +223,7 @@ func clone(dst any, src any) error { func fieldByMapstructureTagName(target reflect.Value, tagName string) (reflect.StructField, bool) { pl := p.NewClient() - for i := range target.Type().NumField() { - f := target.Type().Field(i) - + for f := range target.Type().Fields() { tag, ok := f.Tag.Lookup(MapstructureTagName) if !ok { continue diff --git a/pkg/controller/integration/monitor.go b/pkg/controller/integration/monitor.go index 23281024e3..de4e7869e4 100644 --- a/pkg/controller/integration/monitor.go +++ b/pkg/controller/integration/monitor.go @@ -335,7 +335,7 @@ func getIntegrationSecretAndConfigmapResourceVersions(ctx context.Context, clien if conf.StorageType() == utilResource.StorageTypeConfigmap { cm := corev1.ConfigMap{ TypeMeta: metav1.TypeMeta{ - Kind: "ConfigMap", + Kind: corev1.ResourceConfigMaps.String(), APIVersion: corev1.SchemeGroupVersion.String(), }, ObjectMeta: metav1.ObjectMeta{ @@ -347,7 +347,7 @@ func getIntegrationSecretAndConfigmapResourceVersions(ctx context.Context, clien } else if conf.StorageType() == utilResource.StorageTypeSecret { sec := corev1.Secret{ TypeMeta: metav1.TypeMeta{ - Kind: "Secret", + Kind: corev1.ResourceSecrets.String(), APIVersion: corev1.SchemeGroupVersion.String(), }, ObjectMeta: metav1.ObjectMeta{ diff --git a/pkg/controller/integrationplatform/kamelets.go b/pkg/controller/integrationplatform/kamelets.go index 6aadcd7d9b..63fcf2bf59 100644 --- a/pkg/controller/integrationplatform/kamelets.go +++ b/pkg/controller/integrationplatform/kamelets.go @@ -29,7 +29,6 @@ import ( "strings" v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1" - "k8s.io/utils/ptr" "github.com/apache/camel-k/v2/pkg/client" "github.com/apache/camel-k/v2/pkg/util" @@ -77,9 +76,13 @@ func prepareKameletDirectory() (string, error) { } // If the directory exists, it is likely a leftover from any previous Kamelet // catalog installation. We should remove to be able to proceed + // + //nolint:gosec // deprecated code to be removed soon if err := os.RemoveAll(kameletDir); err != nil { return kameletDirEnv, err } + // + //nolint:gosec // deprecated code to be removed soon err := os.MkdirAll(kameletDir, os.ModePerm) return kameletDir, err @@ -239,8 +242,8 @@ func loadKamelet(path string, platform *v1.IntegrationPlatform) (*v1.Kamelet, er Kind: platform.Kind, Name: platform.Name, UID: platform.UID, - Controller: ptr.To(true), - BlockOwnerDeletion: ptr.To(true), + Controller: new(true), + BlockOwnerDeletion: new(true), }, } kamelet.SetOwnerReferences(references) diff --git a/pkg/controller/integrationplatform/monitor.go b/pkg/controller/integrationplatform/monitor.go index 5808dddbd0..f1afad53be 100644 --- a/pkg/controller/integrationplatform/monitor.go +++ b/pkg/controller/integrationplatform/monitor.go @@ -243,7 +243,7 @@ func (action *monitorAction) addPlainQuarkusCatalog(ctx context.Context, catalog clonedCatalog.Spec.Runtime.Provider = v1.RuntimeProviderPlainQuarkus clonedCatalog.Spec.Runtime.Dependencies = []v1.MavenArtifact{ { - GroupID: "org.apache.camel.quarkus", + GroupID: v1.MavenQuarkusGroupID, ArtifactID: "camel-quarkus-core", }, } @@ -254,7 +254,7 @@ func (action *monitorAction) addPlainQuarkusCatalog(ctx context.Context, catalog clonedCatalog.Spec.Runtime.Capabilities["knative"] = v1.Capability{ Dependencies: []v1.MavenArtifact{ { - GroupID: "org.apache.camel.quarkus", + GroupID: v1.MavenQuarkusGroupID, ArtifactID: "camel-quarkus-knative", }, }, @@ -263,15 +263,15 @@ func (action *monitorAction) addPlainQuarkusCatalog(ctx context.Context, catalog clonedCatalog.Spec.Runtime.Capabilities["master"] = v1.Capability{ Dependencies: []v1.MavenArtifact{ { - GroupID: "org.apache.camel.quarkus", + GroupID: v1.MavenQuarkusGroupID, ArtifactID: "camel-quarkus-master", }, { - GroupID: "org.apache.camel.quarkus", + GroupID: v1.MavenQuarkusGroupID, ArtifactID: "camel-quarkus-kubernetes", }, { - GroupID: "org.apache.camel.quarkus", + GroupID: v1.MavenQuarkusGroupID, ArtifactID: "camel-quarkus-kubernetes-cluster-service", }, }, @@ -283,11 +283,11 @@ func (action *monitorAction) addPlainQuarkusCatalog(ctx context.Context, catalog clonedCatalog.Spec.Runtime.Capabilities["jolokia"] = v1.Capability{ Dependencies: []v1.MavenArtifact{ { - GroupID: "org.apache.camel.quarkus", + GroupID: v1.MavenQuarkusGroupID, ArtifactID: "camel-quarkus-jaxb", }, { - GroupID: "org.apache.camel.quarkus", + GroupID: v1.MavenQuarkusGroupID, ArtifactID: "camel-quarkus-management", }, { diff --git a/pkg/trait/camel.go b/pkg/trait/camel.go index 973511fc47..2bad26cb5f 100644 --- a/pkg/trait/camel.go +++ b/pkg/trait/camel.go @@ -239,7 +239,7 @@ func (t *camelTrait) computeUserProperties(e *Environment) []ctrl.Object { var userPropertiesSb238 strings.Builder for _, prop := range e.collectConfigurationPairs("property") { // properties in resource configuration are expected to be pre-encoded using properties format - userPropertiesSb238.WriteString(fmt.Sprintf("%s=%s\n", prop.Name, prop.Value)) + fmt.Fprintf(&userPropertiesSb238, "%s=%s\n", prop.Name, prop.Value) } userProperties += userPropertiesSb238.String() @@ -248,7 +248,7 @@ func (t *camelTrait) computeUserProperties(e *Environment) []ctrl.Object { var userPropertiesSb245 strings.Builder for _, prop := range t.Properties { k, v := property.SplitPropertyFileEntry(prop) - userPropertiesSb245.WriteString(fmt.Sprintf("%s=%s\n", k, v)) + fmt.Fprintf(&userPropertiesSb245, "%s=%s\n", k, v) } userProperties += userPropertiesSb245.String() } diff --git a/pkg/trait/container.go b/pkg/trait/container.go index 620a7a69eb..77fa58fdf4 100644 --- a/pkg/trait/container.go +++ b/pkg/trait/container.go @@ -93,7 +93,7 @@ func (t *containerTrait) Configure(e *Environment) (bool, *TraitCondition, error if ptr.Deref(t.Auto, true) { if t.Expose == nil { if e.Resources.GetServiceForIntegration(e.Integration) != nil { - t.Expose = ptr.To(true) + t.Expose = new(true) } } } @@ -420,7 +420,7 @@ func (t *containerTrait) getContainerName() string { func (t *containerTrait) getRunAsNonRoot() *bool { if t.RunAsNonRoot == nil { - return ptr.To(defaultContainerRunAsNonRoot) + return new(defaultContainerRunAsNonRoot) } return t.RunAsNonRoot @@ -436,7 +436,7 @@ func (t *containerTrait) getSeccompProfileType() corev1.SeccompProfileType { func (t *containerTrait) getAllowPrivilegeEscalation() *bool { if t.AllowPrivilegeEscalation == nil { - return ptr.To(defaultContainerAllowPrivilegeEscalation) + return new(defaultContainerAllowPrivilegeEscalation) } return t.AllowPrivilegeEscalation diff --git a/pkg/trait/cron.go b/pkg/trait/cron.go index 731ee42ec1..375432a6e9 100644 --- a/pkg/trait/cron.go +++ b/pkg/trait/cron.go @@ -145,7 +145,7 @@ func (t *cronTrait) Configure(e *Environment) (bool, *TraitCondition, error) { } if t.Schedule != "" { - t.Enabled = ptr.To(true) + t.Enabled = new(true) } return ptr.Deref(t.Enabled, false), nil, nil @@ -177,7 +177,7 @@ func (t *cronTrait) autoConfigure(e *Environment) error { } for _, fromURI := range fromURIs { if uri.GetComponent(fromURI) == genericCronComponent { - t.Fallback = ptr.To(true) + t.Fallback = new(true) break } diff --git a/pkg/trait/gateway.go b/pkg/trait/gateway.go index c3889f3e63..adb5e9ceb5 100644 --- a/pkg/trait/gateway.go +++ b/pkg/trait/gateway.go @@ -162,7 +162,7 @@ func buildHTTPRoute(routeName, gatewayName, serviceName, namespace string, servi BackendRef: gwv1.BackendRef{ BackendObjectReference: gwv1.BackendObjectReference{ Name: gwv1.ObjectName(serviceName), - Port: ptr.To(p), + Port: new(p), }, }, }, diff --git a/pkg/trait/ingress.go b/pkg/trait/ingress.go index c87451afad..8f3e4505f2 100644 --- a/pkg/trait/ingress.go +++ b/pkg/trait/ingress.go @@ -188,7 +188,7 @@ func (t *ingressTrait) getPaths(service *corev1.Service) []networkingv1.HTTPIngr func (t *ingressTrait) getPathType() *networkingv1.PathType { if t.PathType == nil { - return ptr.To(defaultPathTypePrefix) + return new(defaultPathTypePrefix) } return t.PathType diff --git a/pkg/trait/knative.go b/pkg/trait/knative.go index 4612278bd5..f5175bba6d 100644 --- a/pkg/trait/knative.go +++ b/pkg/trait/knative.go @@ -115,7 +115,7 @@ func (t *knativeTrait) Configure(e *Environment) (bool, *TraitCondition, error) hasKnativeEndpoint := len(t.ChannelSources) > 0 || len(t.ChannelSinks) > 0 || len(t.EndpointSources) > 0 || len(t.EndpointSinks) > 0 || len(t.EventSources) > 0 || len(t.EventSinks) > 0 - t.Enabled = ptr.To(hasKnativeEndpoint) + t.Enabled = new(hasKnativeEndpoint) } if ptr.Deref(t.Enabled, false) { diff --git a/pkg/trait/knative_service.go b/pkg/trait/knative_service.go index 5de9e9b140..666bdcd7a8 100644 --- a/pkg/trait/knative_service.go +++ b/pkg/trait/knative_service.go @@ -108,10 +108,10 @@ func (t *knativeServiceTrait) Configure(e *Environment) (bool, *TraitCondition, } if strategy == ControllerStrategyKnativeService { - t.Enabled = ptr.To(true) + t.Enabled = new(true) } else if e.IntegrationInPhase(v1.IntegrationPhaseRunning, v1.IntegrationPhaseError) { condition := e.Integration.Status.GetCondition(v1.IntegrationConditionKnativeServiceAvailable) - t.Enabled = ptr.To(condition != nil && condition.Status == corev1.ConditionTrue) + t.Enabled = new(condition != nil && condition.Status == corev1.ConditionTrue) } return ptr.Deref(t.Enabled, false), nil, nil diff --git a/pkg/trait/master.go b/pkg/trait/master.go index 8bd60a9388..2ab0ee38ca 100644 --- a/pkg/trait/master.go +++ b/pkg/trait/master.go @@ -91,7 +91,7 @@ func (t *masterTrait) Configure(e *Environment) (bool, *TraitCondition, error) { return false, nil, err } if enabled { - t.Enabled = ptr.To(enabled) + t.Enabled = new(enabled) if t.ResourceName == nil { val := e.Integration.Name + "-lock" t.ResourceName = &val diff --git a/pkg/trait/security_context.go b/pkg/trait/security_context.go index b74ad8bff4..e452369770 100644 --- a/pkg/trait/security_context.go +++ b/pkg/trait/security_context.go @@ -21,7 +21,6 @@ import ( "fmt" corev1 "k8s.io/api/core/v1" - "k8s.io/utils/ptr" v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1" traitv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1/trait" @@ -128,7 +127,7 @@ func (t *securityContextTrait) getUser(e *Environment) (*int64, error) { func (t *securityContextTrait) getRunAsNonRoot() *bool { if t.RunAsNonRoot == nil { - return ptr.To(defaultPodRunAsNonRoot) + return new(defaultPodRunAsNonRoot) } return t.RunAsNonRoot diff --git a/pkg/trait/service.go b/pkg/trait/service.go index fcfcfb3c0f..6de61b7dca 100644 --- a/pkg/trait/service.go +++ b/pkg/trait/service.go @@ -34,6 +34,7 @@ import ( ) const ( + serviceKind = "Service" serviceTraitID = "service" serviceTraitOrder = 1500 ) @@ -65,7 +66,7 @@ func (t *serviceTrait) Configure(e *Environment) (bool, *TraitCondition, error) } if !ptr.Deref(t.Enabled, true) { return false, NewIntegrationCondition( - "Service", + serviceKind, v1.IntegrationConditionServiceAvailable, corev1.ConditionFalse, v1.IntegrationConditionServiceNotAvailableReason, @@ -77,7 +78,7 @@ func (t *serviceTrait) Configure(e *Environment) (bool, *TraitCondition, error) if e.GetTrait(knativeServiceTraitID) != nil { knativeServiceTrait, _ := e.GetTrait(knativeServiceTraitID).(*knativeServiceTrait) if ptr.Deref(knativeServiceTrait.Enabled, true) { - return false, NewIntegrationConditionPlatformDisabledWithMessage("Service", "knative-service trait has priority over this trait"), nil + return false, NewIntegrationConditionPlatformDisabledWithMessage(serviceKind, "knative-service trait has priority over this trait"), nil } } @@ -92,7 +93,7 @@ func (t *serviceTrait) Configure(e *Environment) (bool, *TraitCondition, error) var condition *TraitCondition if err != nil { condition = NewIntegrationCondition( - "Service", + serviceKind, v1.IntegrationConditionServiceAvailable, corev1.ConditionFalse, v1.IntegrationConditionServiceNotAvailableReason, @@ -102,7 +103,7 @@ func (t *serviceTrait) Configure(e *Environment) (bool, *TraitCondition, error) return false, condition, err } - t.Enabled = ptr.To(exposeHTTPServices) + t.Enabled = new(exposeHTTPServices) } servicePorts, err := t.parseServicePorts() diff --git a/pkg/trait/util.go b/pkg/trait/util.go index 4bdd39cbe1..f82c391bd5 100644 --- a/pkg/trait/util.go +++ b/pkg/trait/util.go @@ -360,7 +360,6 @@ func ExtractAndMaybeDeleteTraits(c client.Client, annotations map[string]string, // return an array with the values or with the single value passed as a parameter. func extractAsArray(value string) []string { if strings.HasPrefix(value, "[") && strings.HasSuffix(value, "]") { - //nolint: prealloc // cannot prealloc as SplitSeq is an iterator var arrayValue []string data := value[1 : len(value)-1] vals := strings.SplitSeq(data, ",") diff --git a/pkg/util/bindings/knative_uri.go b/pkg/util/bindings/knative_uri.go index 9259f67768..2178aa1db0 100644 --- a/pkg/util/bindings/knative_uri.go +++ b/pkg/util/bindings/knative_uri.go @@ -24,7 +24,6 @@ import ( v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1" traitv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1/trait" knativeapis "github.com/apache/camel-k/v2/pkg/internal/knative" - "k8s.io/utils/ptr" "github.com/apache/camel-k/v2/pkg/util/uri" ) @@ -86,7 +85,7 @@ func (k KnativeURIBindingProvider) Translate(ctx BindingContext, endpointCtx End Traits: v1.Traits{ Knative: &traitv1.KnativeTrait{ Configuration: config, - SinkBinding: ptr.To(false), + SinkBinding: new(false), }, }, }, nil diff --git a/pkg/util/camel/camel_dependencies.go b/pkg/util/camel/camel_dependencies.go index b5d99aa042..422b44acda 100644 --- a/pkg/util/camel/camel_dependencies.go +++ b/pkg/util/camel/camel_dependencies.go @@ -168,7 +168,7 @@ func addCamelComponent(project *maven.Project, catalog *RuntimeCatalog, dependen if !strings.HasPrefix(artifactID, "camel-") { artifactID = "camel-quarkus-" + artifactID } - project.AddDependencyGAV("org.apache.camel.quarkus", artifactID, "") + project.AddDependencyGAV(v1.MavenQuarkusGroupID, artifactID, "") } else { if !strings.HasPrefix(artifactID, "camel-") { artifactID = "camel-" + artifactID @@ -190,7 +190,7 @@ func addCamelQuarkusComponent(project *maven.Project, dependency string) { if !strings.HasPrefix(artifactID, "camel-quarkus-") { artifactID = "camel-quarkus-" + artifactID } - project.AddDependencyGAV("org.apache.camel.quarkus", artifactID, "") + project.AddDependencyGAV(v1.MavenQuarkusGroupID, artifactID, "") } func addMavenDependency(project *maven.Project, dependency string) { diff --git a/pkg/util/camel/camel_runtime_catalog.go b/pkg/util/camel/camel_runtime_catalog.go index 3c83c9b382..c20887cd0a 100644 --- a/pkg/util/camel/camel_runtime_catalog.go +++ b/pkg/util/camel/camel_runtime_catalog.go @@ -40,7 +40,7 @@ func NewRuntimeCatalog(cat v1.CamelCatalog) *RuntimeCatalog { // In case of duplicate only, choose the "org.apache.camel.quarkus" artifact (if present). // Workaround for https://github.com/apache/camel-k/v2-runtime/issues/592 if _, duplicate := catalog.artifactByScheme[scheme.ID]; duplicate { - if artifact.GroupID != "org.apache.camel.quarkus" { + if artifact.GroupID != v1.MavenQuarkusGroupID { continue } } diff --git a/pkg/util/camel/catalog_test.go b/pkg/util/camel/catalog_test.go index 7ff0f25167..9ef830b806 100644 --- a/pkg/util/camel/catalog_test.go +++ b/pkg/util/camel/catalog_test.go @@ -20,6 +20,7 @@ package camel import ( "testing" + v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1" "github.com/apache/camel-k/v2/pkg/util/defaults" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -53,7 +54,7 @@ func TestRuntimeContainsEmbeddedArtifacts(t *testing.T) { artifact := catalog.GetArtifactByScheme("knative") assert.Equal(t, 1, len(artifact.Schemes)) - assert.Equal(t, "org.apache.camel.quarkus", artifact.GroupID) + assert.Equal(t, v1.MavenQuarkusGroupID, artifact.GroupID) assert.Equal(t, "camel-quarkus-knative", artifact.ArtifactID) scheme, found := catalog.GetScheme("knative") diff --git a/pkg/util/knative/knative.go b/pkg/util/knative/knative.go index 95596ea93c..0aa68910e3 100644 --- a/pkg/util/knative/knative.go +++ b/pkg/util/knative/knative.go @@ -46,6 +46,8 @@ import ( util "github.com/apache/camel-k/v2/pkg/util/kubernetes" ) +const knativeService = "Service" + func CreateSubscription(channelReference corev1.ObjectReference, serviceName string, path string) *messaging.Subscription { return &messaging.Subscription{ TypeMeta: metav1.TypeMeta{ @@ -65,7 +67,7 @@ func CreateSubscription(channelReference corev1.ObjectReference, serviceName str Subscriber: &duckv1.Destination{ Ref: &duckv1.KReference{ APIVersion: serving.SchemeGroupVersion.String(), - Kind: "Service", + Kind: knativeService, Name: serviceName, }, URI: &apis.URL{ @@ -80,7 +82,7 @@ func CreateSubscription(channelReference corev1.ObjectReference, serviceName str func CreateServiceTrigger(brokerReference corev1.ObjectReference, serviceName string, eventType string, path string, attributes map[string]string) (*eventing.Trigger, error) { subscriberRef := duckv1.KReference{ APIVersion: "v1", - Kind: "Service", + Kind: knativeService, Name: serviceName, } @@ -91,7 +93,7 @@ func CreateServiceTrigger(brokerReference corev1.ObjectReference, serviceName st func CreateKnativeServiceTrigger(brokerReference corev1.ObjectReference, serviceName string, eventType string, path string, attributes map[string]string) (*eventing.Trigger, error) { subscriberRef := duckv1.KReference{ APIVersion: serving.SchemeGroupVersion.String(), - Kind: "Service", + Kind: knativeService, Name: serviceName, } @@ -214,7 +216,7 @@ func getSinkURI(ctx context.Context, c client.Client, sink *corev1.ObjectReferen objIdentifier := fmt.Sprintf("\"%s/%s\" (%s)", u.GetNamespace(), u.GetName(), u.GroupVersionKind()) // Special case v1/Service allowing it to be addressable - if u.GroupVersionKind().Kind == "Service" && u.GroupVersionKind().Group == "" && u.GroupVersionKind().Version == "v1" { + if u.GroupVersionKind().Kind == knativeService && u.GroupVersionKind().Group == "" && u.GroupVersionKind().Version == "v1" { return fmt.Sprintf("http://%s.%s.svc/", u.GetName(), u.GetNamespace()), nil } diff --git a/pkg/util/kubernetes/log/annotation_scraper.go b/pkg/util/kubernetes/log/annotation_scraper.go index 87b8fcd2df..6857516ae9 100644 --- a/pkg/util/kubernetes/log/annotation_scraper.go +++ b/pkg/util/kubernetes/log/annotation_scraper.go @@ -46,7 +46,7 @@ type SelectorScraper struct { defaultContainerName string labelSelector string podScrapers sync.Map - counter uint64 + counter atomic.Uint64 L klog.Logger tailLines *int64 } @@ -142,7 +142,7 @@ func (s *SelectorScraper) synchronize(ctx context.Context, out *bufio.Writer) er func (s *SelectorScraper) addPodScraper(ctx context.Context, podName string, out *bufio.Writer) { podScraper := NewPodScraper(s.client, s.namespace, podName, s.defaultContainerName, s.tailLines) podCtx, podCancel := context.WithCancel(ctx) - id := atomic.AddUint64(&s.counter, 1) + id := s.counter.Add(1) prefix := "[" + strconv.FormatUint(id, 10) + "] " podReader := podScraper.Start(podCtx) s.podScrapers.Store(podName, podCancel) diff --git a/pkg/util/kubernetes/service.go b/pkg/util/kubernetes/service.go index 8093ce8e1e..13bd620ef7 100644 --- a/pkg/util/kubernetes/service.go +++ b/pkg/util/kubernetes/service.go @@ -31,7 +31,7 @@ func GetClusterTypeServiceURI(svc *corev1.Service) string { loop: for _, port := range svc.Spec.Ports { if port.Port != 80 { // Assuming HTTP default port - urlSb30.WriteString(fmt.Sprintf(":%d", port.Port)) + fmt.Fprintf(&urlSb30, ":%d", port.Port) break loop } diff --git a/pkg/util/openshift/openshift.go b/pkg/util/openshift/openshift.go index 9456e6e68c..c2ce1b7813 100644 --- a/pkg/util/openshift/openshift.go +++ b/pkg/util/openshift/openshift.go @@ -28,7 +28,6 @@ import ( k8serrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" - "k8s.io/utils/ptr" ) // IsOpenShift returns true if we are connected to a OpenShift cluster. @@ -88,11 +87,11 @@ func GetOpenshiftSecurityContextRestricted(ctx context.Context, client kubernete sc := corev1.SecurityContext{ RunAsUser: uid, - RunAsNonRoot: ptr.To(true), + RunAsNonRoot: new(true), SeccompProfile: &corev1.SeccompProfile{ Type: corev1.SeccompProfileTypeRuntimeDefault, }, - AllowPrivilegeEscalation: ptr.To(false), + AllowPrivilegeEscalation: new(false), Capabilities: &corev1.Capabilities{Drop: []corev1.Capability{"ALL"}}, } diff --git a/pkg/util/patch/patch.go b/pkg/util/patch/patch.go index 611e3e4bbd..0fa84eea53 100644 --- a/pkg/util/patch/patch.go +++ b/pkg/util/patch/patch.go @@ -88,7 +88,7 @@ func ApplyPatch(source runtime.Object) (*unstructured.Unstructured, error) { } func removeNilValues(v reflect.Value, parent reflect.Value) { - for v.Kind() == reflect.Ptr || v.Kind() == reflect.Interface { + for v.Kind() == reflect.Pointer || v.Kind() == reflect.Interface { v = v.Elem() } switch v.Kind() { diff --git a/pkg/util/uri/uri.go b/pkg/util/uri/uri.go index 95370c6cf9..d152d07b0d 100644 --- a/pkg/util/uri/uri.go +++ b/pkg/util/uri/uri.go @@ -80,7 +80,7 @@ func AppendParameters(uri string, params map[string]string) string { sort.Strings(keys) var uriSb81 strings.Builder for _, k := range keys { - uriSb81.WriteString(fmt.Sprintf("%s%s=%s", prefix, url.QueryEscape(k), url.QueryEscape(params[k]))) + fmt.Fprintf(&uriSb81, "%s%s=%s", prefix, url.QueryEscape(k), url.QueryEscape(params[k])) prefix = "&" } uri += uriSb81.String() diff --git a/pkg/util/util.go b/pkg/util/util.go index fd3de0564d..0d228ff138 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -488,8 +488,8 @@ func ConfigTreePropertySplit(property string) []string { if len(cur) > 0 { tmp = append(tmp, cur) } - for i := len(tmp) - 1; i >= 0; i-- { - res = append(res, tmp[i]) + for _, v := range slices.Backward(tmp) { + res = append(res, v) } } diff --git a/script/Makefile b/script/Makefile index 2198a3dfef..719082b395 100644 --- a/script/Makefile +++ b/script/Makefile @@ -40,7 +40,7 @@ LINTER ?= $(LOCALBIN)/golangci-lint DEADCODE ?= $(LOCALBIN)/deadcode GOVULNCHECK ?= $(LOCALBIN)/govulncheck GOIMPORT ?= $(LOCALBIN)/goimports -LINTER_VERSION ?= v2.9.0 +LINTER_VERSION ?= v2.12.2 GOVULNCHECK_VERSION ?= latest LINT_GOGC ?= 20 LINT_DEADLINE ?= 10m