You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gf...@apache.org on 2024/07/31 07:57:25 UTC

(camel-k) branch main updated (1ea28eb00 -> 8f5cdd07e)

This is an automated email from the ASF dual-hosted git repository.

gfournier pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git


    from 1ea28eb00 chore(deps): bump github.com/container-tools/spectrum
     new a4bf2a974 chore(ci): Upgrade golang to 1.22
     new 8f5cdd07e chore(lint): Fix golang 1.22 lint

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 build/Dockerfile                                     |  2 +-
 docs/modules/ROOT/pages/contributing/developers.adoc |  2 +-
 go.mod                                               |  2 +-
 pkg/apis/camel/v1/knative/types_support.go           |  2 --
 pkg/builder/steps.go                                 |  2 +-
 pkg/cmd/delete.go                                    |  4 ++--
 pkg/cmd/kamelet_add_repo.go                          |  4 ++--
 pkg/cmd/uninstall.go                                 |  2 +-
 pkg/cmd/util.go                                      |  2 +-
 pkg/cmd/util_config.go                               |  2 +-
 pkg/controller/integration/build_kit.go              |  5 ++---
 pkg/install/operator.go                              |  4 ++--
 pkg/platform/platform.go                             |  4 ++--
 pkg/trait/util.go                                    |  6 ------
 pkg/util/camel/camel_dependencies.go                 |  2 +-
 pkg/util/camel/camel_runtime_catalog.go              |  3 ---
 pkg/util/envvar/envvar.go                            |  2 +-
 pkg/util/kubernetes/resolver.go                      |  2 +-
 pkg/util/patch/patch.go                              |  2 +-
 pkg/util/util.go                                     | 10 +++++-----
 20 files changed, 26 insertions(+), 38 deletions(-)


(camel-k) 01/02: chore(ci): Upgrade golang to 1.22

Posted by gf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gfournier pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit a4bf2a9741145af36ddccc3a4a3db00dabbf24db
Author: Gaelle Fournier <ga...@gmail.com>
AuthorDate: Tue Jul 30 18:37:57 2024 +0200

    chore(ci): Upgrade golang to 1.22
---
 build/Dockerfile                                     | 2 +-
 docs/modules/ROOT/pages/contributing/developers.adoc | 2 +-
 go.mod                                               | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/build/Dockerfile b/build/Dockerfile
index f5b6eee9c..78ff6a3cd 100644
--- a/build/Dockerfile
+++ b/build/Dockerfile
@@ -65,7 +65,7 @@ USER 1001:0
 
 ADD build/_output/bin/kamel-${IMAGE_ARCH} /usr/local/bin/kamel
 
-FROM golang:1.21 AS go
+FROM golang:1.22 AS go
 
 RUN go install github.com/go-delve/delve/cmd/dlv@latest
 
diff --git a/docs/modules/ROOT/pages/contributing/developers.adoc b/docs/modules/ROOT/pages/contributing/developers.adoc
index 98a905b68..e968e5d50 100644
--- a/docs/modules/ROOT/pages/contributing/developers.adoc
+++ b/docs/modules/ROOT/pages/contributing/developers.adoc
@@ -22,7 +22,7 @@ There are many ways you can contribute to Camel K, not only software development
 
 In order to build the project, you need to comply with the following requirements:
 
-* **Go version 1.21+**: needed to compile and test the project. Refer to the https://golang.org/[Go website] for the installation.
+* **Go version 1.22+**: needed to compile and test the project. Refer to the https://golang.org/[Go website] for the installation.
 * **GNU Make**: used to define composite build actions. This should be already installed or available as a package if you have a good OS (https://www.gnu.org/software/make/).
 * **JDK version 17+**: the build requires JDK version 17 or above. This corresponds to the JDK version of the integration base image.
 * **Maven version 3.8+**: the build requires Maven 3.8 or above. This corresponds to the version defined in the `build/Dockerfile`.
diff --git a/go.mod b/go.mod
index da1f00f49..791c0ba5e 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
 module github.com/apache/camel-k/v2
 
-go 1.21
+go 1.22
 
 require (
 	github.com/Masterminds/semver v1.5.0


(camel-k) 02/02: chore(lint): Fix golang 1.22 lint

Posted by gf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gfournier pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 8f5cdd07e7d6c72f5754f0ece151b313891ef417
Author: Gaelle Fournier <ga...@gmail.com>
AuthorDate: Tue Jul 30 19:26:01 2024 +0200

    chore(lint): Fix golang 1.22 lint
---
 pkg/apis/camel/v1/knative/types_support.go |  2 --
 pkg/builder/steps.go                       |  2 +-
 pkg/cmd/delete.go                          |  4 ++--
 pkg/cmd/kamelet_add_repo.go                |  4 ++--
 pkg/cmd/uninstall.go                       |  2 +-
 pkg/cmd/util.go                            |  2 +-
 pkg/cmd/util_config.go                     |  2 +-
 pkg/controller/integration/build_kit.go    |  5 ++---
 pkg/install/operator.go                    |  4 ++--
 pkg/platform/platform.go                   |  4 ++--
 pkg/trait/util.go                          |  6 ------
 pkg/util/camel/camel_dependencies.go       |  2 +-
 pkg/util/camel/camel_runtime_catalog.go    |  3 ---
 pkg/util/envvar/envvar.go                  |  2 +-
 pkg/util/kubernetes/resolver.go            |  2 +-
 pkg/util/patch/patch.go                    |  2 +-
 pkg/util/util.go                           | 10 +++++-----
 17 files changed, 23 insertions(+), 35 deletions(-)

diff --git a/pkg/apis/camel/v1/knative/types_support.go b/pkg/apis/camel/v1/knative/types_support.go
index d4ebf4b39..8ae5b87f2 100644
--- a/pkg/apis/camel/v1/knative/types_support.go
+++ b/pkg/apis/camel/v1/knative/types_support.go
@@ -45,7 +45,6 @@ func BuildCamelServiceDefinition(name string, endpointKind CamelEndpointKind, se
 // SetSinkBinding marks one of the service as SinkBinding.
 func (env *CamelEnvironment) SetSinkBinding(name string, endpointKind CamelEndpointKind, serviceType CamelServiceType, apiVersion, kind string) {
 	for i, svc := range env.Services {
-		svc := svc
 		if svc.Name == name &&
 			svc.Metadata[CamelMetaEndpointKind] == string(endpointKind) &&
 			svc.ServiceType == serviceType &&
@@ -107,7 +106,6 @@ func (env *CamelEnvironment) ContainsService(name string, endpointKind CamelEndp
 // FindService -- .
 func (env *CamelEnvironment) FindService(name string, endpointKind CamelEndpointKind, serviceType CamelServiceType, apiVersion, kind string) *CamelServiceDefinition {
 	for _, svc := range env.Services {
-		svc := svc
 		if svc.Name == name &&
 			svc.Metadata[CamelMetaEndpointKind] == string(endpointKind) &&
 			svc.ServiceType == serviceType &&
diff --git a/pkg/builder/steps.go b/pkg/builder/steps.go
index 245a389c2..a51820526 100644
--- a/pkg/builder/steps.go
+++ b/pkg/builder/steps.go
@@ -81,7 +81,7 @@ func registerSteps(steps interface{}) {
 	v := reflect.ValueOf(steps)
 	t := reflect.TypeOf(steps)
 
-	for i := 0; i < v.NumField(); i++ {
+	for i := range v.NumField() {
 		field := t.Field(i)
 		if step, ok := v.Field(i).Interface().(Step); ok {
 			id := t.PkgPath() + "/" + field.Name
diff --git a/pkg/cmd/delete.go b/pkg/cmd/delete.go
index acf480b36..326fab4b3 100644
--- a/pkg/cmd/delete.go
+++ b/pkg/cmd/delete.go
@@ -107,8 +107,8 @@ func (command *deleteCmdOptions) run(cmd *cobra.Command, args []string) error {
 		if err != nil {
 			return err
 		}
-		for _, integration := range integrationList.Items {
-			integration := integration // pin
+		for i := range integrationList.Items {
+			integration := integrationList.Items[i]
 			err := deleteIntegration(command.Context, cmd, c, &integration)
 			if err != nil {
 				return err
diff --git a/pkg/cmd/kamelet_add_repo.go b/pkg/cmd/kamelet_add_repo.go
index ceeb4baa8..f217b01a8 100644
--- a/pkg/cmd/kamelet_add_repo.go
+++ b/pkg/cmd/kamelet_add_repo.go
@@ -125,8 +125,8 @@ func (o *kameletUpdateRepoCommandOptions) findIntegrationPlatform(cmd *cobra.Com
 	if err != nil {
 		return nil, err
 	}
-	for _, p := range platforms.Items {
-		p := p // pin
+	for i := range platforms.Items {
+		p := platforms.Items[i]
 		if platformutil.IsActive(&p) {
 			return &p, nil
 		}
diff --git a/pkg/cmd/uninstall.go b/pkg/cmd/uninstall.go
index 736b13598..531738be8 100644
--- a/pkg/cmd/uninstall.go
+++ b/pkg/cmd/uninstall.go
@@ -230,7 +230,7 @@ func (o *uninstallCmdOptions) uninstallClusterWideResources(ctx context.Context,
 		if k8serrors.IsForbidden(err) {
 			// Let's print a warning message and continue
 			fmt.Fprintln(cmd.ErrOrStderr(), "Current user is not authorized to remove the operator ServiceAccount from the cluster role bindings")
-		} else if err != nil {
+		} else {
 			return err
 		}
 	}
diff --git a/pkg/cmd/util.go b/pkg/cmd/util.go
index 9afc86c1e..a30e2c0b8 100644
--- a/pkg/cmd/util.go
+++ b/pkg/cmd/util.go
@@ -219,7 +219,7 @@ func clone(dst interface{}, src interface{}) error {
 func fieldByMapstructureTagName(target reflect.Value, tagName string) (reflect.StructField, bool) {
 	pl := p.NewClient()
 
-	for i := 0; i < target.Type().NumField(); i++ {
+	for i := range target.Type().NumField() {
 		f := target.Type().Field(i)
 
 		tag, ok := f.Tag.Lookup(MapstructureTagName)
diff --git a/pkg/cmd/util_config.go b/pkg/cmd/util_config.go
index ce4a5d52f..fd40eaf99 100644
--- a/pkg/cmd/util_config.go
+++ b/pkg/cmd/util_config.go
@@ -98,7 +98,7 @@ func (cfg *Config) Update(cmd *cobra.Command, nodeID string, data interface{}, c
 	pl := p.NewClient()
 	val := reflect.ValueOf(data).Elem()
 
-	for i := 0; i < val.NumField(); i++ {
+	for i := range val.NumField() {
 		field := val.Type().Field(i)
 		if !field.Anonymous {
 			if ktag, ok := field.Tag.Lookup(KamelTagName); ok {
diff --git a/pkg/controller/integration/build_kit.go b/pkg/controller/integration/build_kit.go
index af2d164ae..1ec95bac6 100644
--- a/pkg/controller/integration/build_kit.go
+++ b/pkg/controller/integration/build_kit.go
@@ -92,9 +92,8 @@ func (action *buildKitAction) Handle(ctx context.Context, integration *v1.Integr
 		integration.Name, "namespace", integration.Namespace)
 	var integrationKit *v1.IntegrationKit
 kits:
-	for _, kit := range env.IntegrationKits {
-		kit := kit
-
+	for j := range env.IntegrationKits {
+		kit := env.IntegrationKits[j]
 		for i := range existingKits {
 			k := &existingKits[i]
 
diff --git a/pkg/install/operator.go b/pkg/install/operator.go
index f6075bdae..6f0ebd8ac 100644
--- a/pkg/install/operator.go
+++ b/pkg/install/operator.go
@@ -131,7 +131,7 @@ func OperatorOrCollect(ctx context.Context, cmd *cobra.Command, c client.Client,
 					if err != nil {
 						fmt.Fprintln(cmd.ErrOrStderr(), "Warning: could not parse the configured resources requests!")
 					}
-					for i := 0; i < len(d.Spec.Template.Spec.Containers); i++ {
+					for i := range len(d.Spec.Template.Spec.Containers) {
 						d.Spec.Template.Spec.Containers[i].Resources = resourceReq
 					}
 				}
@@ -145,7 +145,7 @@ func OperatorOrCollect(ctx context.Context, cmd *cobra.Command, c client.Client,
 					if err != nil {
 						fmt.Fprintln(cmd.ErrOrStderr(), "Warning: could not parse environment variables!")
 					}
-					for i := 0; i < len(d.Spec.Template.Spec.Containers); i++ {
+					for i := range len(d.Spec.Template.Spec.Containers) {
 						for _, envVar := range envVars {
 							envvar.SetVar(&d.Spec.Template.Spec.Containers[i].Env, envVar)
 						}
diff --git a/pkg/platform/platform.go b/pkg/platform/platform.go
index 470e2aec3..3f9b8ba55 100644
--- a/pkg/platform/platform.go
+++ b/pkg/platform/platform.go
@@ -154,8 +154,8 @@ func findLocal(ctx context.Context, c k8sclient.Reader, namespace string) (*v1.I
 	}
 
 	var fallback *v1.IntegrationPlatform
-	for _, platform := range lst.Items {
-		platform := platform // pin
+	for i := range lst.Items {
+		platform := lst.Items[i]
 		if IsActive(&platform) {
 			log.Debugf("Found active integration platform %s in namespace %s", platform.Name, namespace)
 			return &platform, nil
diff --git a/pkg/trait/util.go b/pkg/trait/util.go
index 94581dad4..f81dfa5ed 100644
--- a/pkg/trait/util.go
+++ b/pkg/trait/util.go
@@ -79,8 +79,6 @@ func collectConfigurationValues(configurationType string, configurable ...v1.Con
 	result := sets.NewSet()
 
 	for _, c := range configurable {
-		c := c
-
 		if c == nil || reflect.ValueOf(c).IsNil() {
 			continue
 		}
@@ -106,8 +104,6 @@ func collectConfigurations(configurationType string, configurable ...v1.Configur
 	var result []map[string]string
 
 	for _, c := range configurable {
-		c := c
-
 		if c == nil || reflect.ValueOf(c).IsNil() {
 			continue
 		}
@@ -133,8 +129,6 @@ func collectConfigurationPairs(configurationType string, configurable ...v1.Conf
 	result := make([]variable, 0)
 
 	for _, c := range configurable {
-		c := c
-
 		if c == nil || reflect.ValueOf(c).IsNil() {
 			continue
 		}
diff --git a/pkg/util/camel/camel_dependencies.go b/pkg/util/camel/camel_dependencies.go
index b979335b8..e1501fd18 100644
--- a/pkg/util/camel/camel_dependencies.go
+++ b/pkg/util/camel/camel_dependencies.go
@@ -345,7 +345,7 @@ func postProcessDependencies(project *maven.Project, catalog *RuntimeCatalog) {
 
 // SanitizeIntegrationDependencies --.
 func SanitizeIntegrationDependencies(dependencies []maven.Dependency) error {
-	for i := 0; i < len(dependencies); i++ {
+	for i := range len(dependencies) {
 		dep := dependencies[i]
 
 		// It may be externalized into runtime provider specific steps
diff --git a/pkg/util/camel/camel_runtime_catalog.go b/pkg/util/camel/camel_runtime_catalog.go
index 2681e4918..b98103fcc 100644
--- a/pkg/util/camel/camel_runtime_catalog.go
+++ b/pkg/util/camel/camel_runtime_catalog.go
@@ -37,8 +37,6 @@ func NewRuntimeCatalog(cat v1.CamelCatalog) *RuntimeCatalog {
 
 	for id, artifact := range catalog.Artifacts {
 		for _, scheme := range artifact.Schemes {
-			scheme := scheme
-
 			// 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 {
@@ -51,7 +49,6 @@ func NewRuntimeCatalog(cat v1.CamelCatalog) *RuntimeCatalog {
 			catalog.schemesByID[scheme.ID] = scheme
 		}
 		for _, dataFormat := range artifact.DataFormats {
-			dataFormat := dataFormat
 			catalog.artifactByDataFormat[dataFormat] = id
 		}
 		for _, language := range artifact.Languages {
diff --git a/pkg/util/envvar/envvar.go b/pkg/util/envvar/envvar.go
index f22cee807..0d017d391 100644
--- a/pkg/util/envvar/envvar.go
+++ b/pkg/util/envvar/envvar.go
@@ -21,7 +21,7 @@ import corev1 "k8s.io/api/core/v1"
 
 // Get --.
 func Get(vars []corev1.EnvVar, name string) *corev1.EnvVar {
-	for i := 0; i < len(vars); i++ {
+	for i := range len(vars) {
 		if vars[i].Name == name {
 			return &vars[i]
 		}
diff --git a/pkg/util/kubernetes/resolver.go b/pkg/util/kubernetes/resolver.go
index e86d24db1..8c61849c1 100644
--- a/pkg/util/kubernetes/resolver.go
+++ b/pkg/util/kubernetes/resolver.go
@@ -30,7 +30,7 @@ import (
 
 // ResolveSources --.
 func ResolveSources(elements []v1.SourceSpec, mapLookup func(string) (*corev1.ConfigMap, error)) ([]v1.SourceSpec, error) {
-	for i := 0; i < len(elements); i++ {
+	for i := range len(elements) {
 		r := &elements[i]
 
 		if err := Resolve(&r.DataSpec, mapLookup); err != nil {
diff --git a/pkg/util/patch/patch.go b/pkg/util/patch/patch.go
index b7ad290a5..cab3ec7fe 100644
--- a/pkg/util/patch/patch.go
+++ b/pkg/util/patch/patch.go
@@ -92,7 +92,7 @@ func removeNilValues(v reflect.Value, parent reflect.Value) {
 	}
 	switch v.Kind() {
 	case reflect.Array, reflect.Slice:
-		for i := 0; i < v.Len(); i++ {
+		for i := range v.Len() {
 			removeNilValues(v.Index(i), v)
 		}
 	case reflect.Map:
diff --git a/pkg/util/util.go b/pkg/util/util.go
index 2d72de0d1..4842fbcec 100644
--- a/pkg/util/util.go
+++ b/pkg/util/util.go
@@ -117,7 +117,7 @@ func StringSliceJoin(slices ...[]string) []string {
 }
 
 func StringSliceContains(slice []string, items []string) bool {
-	for i := 0; i < len(items); i++ {
+	for i := range len(items) {
 		if !StringSliceExists(slice, items[i]) {
 			return false
 		}
@@ -127,7 +127,7 @@ func StringSliceContains(slice []string, items []string) bool {
 }
 
 func StringSliceExists(slice []string, item string) bool {
-	for i := 0; i < len(slice); i++ {
+	for i := range len(slice) {
 		if slice[i] == item {
 			return true
 		}
@@ -137,7 +137,7 @@ func StringSliceExists(slice []string, item string) bool {
 }
 
 func StringContainsPrefix(slice []string, prefix string) bool {
-	for i := 0; i < len(slice); i++ {
+	for i := range len(slice) {
 		if strings.HasPrefix(slice[i], prefix) {
 			return true
 		}
@@ -147,8 +147,8 @@ func StringContainsPrefix(slice []string, prefix string) bool {
 }
 
 func StringSliceContainsAnyOf(slice []string, items ...string) bool {
-	for i := 0; i < len(slice); i++ {
-		for j := 0; j < len(items); j++ {
+	for i := range len(slice) {
+		for j := range len(items) {
 			if strings.Contains(slice[i], items[j]) {
 				return true
 			}