You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2021/06/07 06:50:52 UTC

[camel-k] branch alignment-camel-main created (now 417334a)

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

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


      at 417334a  Updated CHANGELOG.md

This branch includes the following new commits:

     new 1996c52  feat(cli): add sub command kamel kamelet for get and delete #2312
     new 149dcfc  Updated CHANGELOG.md
     new ad97cfa  Related to #2165: account for annotations when checking if integration is changed
     new 64edc38  Update README to reflect where Sample.java is
     new 417334a  Updated CHANGELOG.md

The 5 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.


[camel-k] 01/05: feat(cli): add sub command kamel kamelet for get and delete #2312

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

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

commit 1996c52c5ed5dd98243856aed451777892cc5f39
Author: Tadayoshi Sato <sa...@gmail.com>
AuthorDate: Thu Jun 3 17:36:56 2021 +0900

    feat(cli): add sub command kamel kamelet for get and delete #2312
---
 pkg/apis/camel/v1alpha1/kamelet_types.go     |  10 +-
 pkg/cmd/kamelet.go                           |  35 +++++++
 pkg/cmd/{kit_delete.go => kamelet_delete.go} | 101 +++++++++----------
 pkg/cmd/kamelet_get.go                       | 139 +++++++++++++++++++++++++++
 pkg/cmd/kit_delete.go                        |   2 +-
 pkg/cmd/root.go                              |   1 +
 pkg/install/kamelets.go                      |   6 +-
 7 files changed, 234 insertions(+), 60 deletions(-)

diff --git a/pkg/apis/camel/v1alpha1/kamelet_types.go b/pkg/apis/camel/v1alpha1/kamelet_types.go
index fd10387..5a6def7 100644
--- a/pkg/apis/camel/v1alpha1/kamelet_types.go
+++ b/pkg/apis/camel/v1alpha1/kamelet_types.go
@@ -25,7 +25,15 @@ import (
 )
 
 const (
-	AnnotationIcon = "camel.apache.org/kamelet.icon"
+	AnnotationIcon       = "camel.apache.org/kamelet.icon"
+	KameletBundledLabel  = "camel.apache.org/kamelet.bundled"
+	KameletReadOnlyLabel = "camel.apache.org/kamelet.readonly"
+	KameletTypeLabel     = "camel.apache.org/kamelet.type"
+	KameletGroupLabel    = "camel.apache.org/kamelet.group"
+
+	KameletTypeSink   = "sink"
+	KameletTypeSource = "source"
+	KameletTypeAction = "action"
 )
 
 var (
diff --git a/pkg/cmd/kamelet.go b/pkg/cmd/kamelet.go
new file mode 100644
index 0000000..89a0906
--- /dev/null
+++ b/pkg/cmd/kamelet.go
@@ -0,0 +1,35 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package cmd
+
+import (
+	"github.com/spf13/cobra"
+)
+
+func newCmdKamelet(rootCmdOptions *RootCmdOptions) *cobra.Command {
+	cmd := cobra.Command{
+		Use:   "kamelet",
+		Short: "Configure a Kamelet",
+		Long:  `Configure a Kamelet.`,
+	}
+
+	cmd.AddCommand(cmdOnly(newKameletGetCmd(rootCmdOptions)))
+	cmd.AddCommand(cmdOnly(newKameletDeleteCmd(rootCmdOptions)))
+
+	return &cmd
+}
diff --git a/pkg/cmd/kit_delete.go b/pkg/cmd/kamelet_delete.go
similarity index 50%
copy from pkg/cmd/kit_delete.go
copy to pkg/cmd/kamelet_delete.go
index 53dec61..7f6ed67 100644
--- a/pkg/cmd/kit_delete.go
+++ b/pkg/cmd/kamelet_delete.go
@@ -21,25 +21,25 @@ import (
 	"errors"
 	"fmt"
 
-	k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
-
-	v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
 	"github.com/spf13/cobra"
-
 	k8errors "k8s.io/apimachinery/pkg/api/errors"
+
+	k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
+
+	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
 )
 
-func newKitDeleteCmd(rootCmdOptions *RootCmdOptions) (*cobra.Command, *kitDeleteCommandOptions) {
-	options := kitDeleteCommandOptions{
+func newKameletDeleteCmd(rootCmdOptions *RootCmdOptions) (*cobra.Command, *kameletDeleteCommandOptions) {
+	options := kameletDeleteCommandOptions{
 		RootCmdOptions: rootCmdOptions,
 	}
 
 	cmd := cobra.Command{
-		Use:     "delete",
-		Short:   "Delete an Integration Kit",
-		Long:    `Delete an Integration Kit.`,
+		Use:     "delete <name>",
+		Short:   "Delete a Kamelet",
+		Long:    `Delete a Kamelet.`,
 		PreRunE: decode(&options),
-		RunE: func(_ *cobra.Command, args []string) error {
+		RunE: func(cmd *cobra.Command, args []string) error {
 			if err := options.validate(args); err != nil {
 				return err
 			}
@@ -51,28 +51,28 @@ func newKitDeleteCmd(rootCmdOptions *RootCmdOptions) (*cobra.Command, *kitDelete
 		},
 	}
 
-	cmd.Flags().Bool("all", false, "Delete all integration Kits")
+	cmd.Flags().Bool("all", false, "Delete all Kamelets")
 
 	return &cmd, &options
 }
 
-type kitDeleteCommandOptions struct {
+type kameletDeleteCommandOptions struct {
 	*RootCmdOptions
 	All bool `mapstructure:"all"`
 }
 
-func (command *kitDeleteCommandOptions) validate(args []string) error {
+func (command *kameletDeleteCommandOptions) validate(args []string) error {
 	if command.All && len(args) > 0 {
-		return errors.New("invalid combination: both all flag and named Kits are set")
+		return errors.New("invalid combination: both all flag and named kamelets are set")
 	}
 	if !command.All && len(args) == 0 {
-		return errors.New("invalid combination: neither all flag nor named Kits are set")
+		return errors.New("invalid combination: neither all flag nor named kamelets are set")
 	}
 
 	return nil
 }
 
-func (command *kitDeleteCommandOptions) run(args []string) error {
+func (command *kameletDeleteCommandOptions) run(args []string) error {
 	names := args
 
 	c, err := command.GetCmdClient()
@@ -81,16 +81,15 @@ func (command *kitDeleteCommandOptions) run(args []string) error {
 	}
 
 	if command.All {
-		kitList := v1.NewIntegrationKitList()
-		if err := c.List(command.Context, &kitList, k8sclient.InNamespace(command.Namespace)); err != nil {
+		klList := v1alpha1.NewKameletList()
+		if err := c.List(command.Context, &klList, k8sclient.InNamespace(command.Namespace)); err != nil {
 			return err
 		}
-
-		names = make([]string, 0, len(kitList.Items))
-		for _, item := range kitList.Items {
-			// only include non platform Kits
-			if item.Labels["camel.apache.org/kit.type"] != v1.IntegrationKitTypePlatform {
-				names = append(names, item.Name)
+		names = make([]string, 0, len(klList.Items))
+		for _, kl := range klList.Items {
+			// only include non-bundled, non-readonly kamelets
+			if kl.Labels[v1alpha1.KameletBundledLabel] != "true" && kl.Labels[v1alpha1.KameletReadOnlyLabel] != "true" {
+				names = append(names, kl.Name)
 			}
 		}
 	}
@@ -104,50 +103,44 @@ func (command *kitDeleteCommandOptions) run(args []string) error {
 	return nil
 }
 
-func (command *kitDeleteCommandOptions) delete(name string) error {
-	ctx := v1.NewIntegrationKit(command.Namespace, name)
-	key := k8sclient.ObjectKey{
-		Namespace: command.Namespace,
-		Name:      name,
-	}
+func (command *kameletDeleteCommandOptions) delete(name string) error {
 	c, err := command.GetCmdClient()
 	if err != nil {
 		return err
 	}
 
-	err = c.Get(command.Context, key, &ctx)
-
-	// pass through if the kit is not found
-	if err != nil && k8errors.IsNotFound(err) {
-		return fmt.Errorf("no integration kit found with name \"%s\"", ctx.Name)
+	kl := v1alpha1.NewKamelet(command.Namespace, name)
+	key := k8sclient.ObjectKey{
+		Namespace: command.Namespace,
+		Name:      name,
 	}
-
-	// fail otherwise
+	err = c.Get(command.Context, key, &kl)
 	if err != nil {
-		return err
+		if k8errors.IsNotFound(err) {
+			return fmt.Errorf("no kamelet found with name \"%s\"", name)
+		} else {
+			return err
+		}
 	}
 
-	// check that it is not a platform one which is supposed to be "read only"
+	// check that it is not a bundled nor read-only one which is supposed to belong to platform
 	// thus not managed by the end user
-	if ctx.Labels["camel.apache.org/kit.type"] == v1.IntegrationKitTypePlatform {
-		// skip platform Kits while deleting all Kits
+	if kl.Labels[v1alpha1.KameletBundledLabel] == "true" || kl.Labels[v1alpha1.KameletReadOnlyLabel] == "true" {
+		// skip platform Kamelets while deleting all Kamelets
 		if command.All {
 			return nil
 		}
-
-		return fmt.Errorf("integration kit \"%s\" is not editable", ctx.Name)
+		return fmt.Errorf("kamelet \"%s\" is not editable", name)
 	}
 
-	err = c.Delete(command.Context, &ctx)
-
-	if err != nil && !k8errors.IsNotFound(err) {
-		return fmt.Errorf("error deleting integration kit \"%s\", %s", ctx.Name, err)
-	}
-	if err != nil && k8errors.IsNotFound(err) {
-		return fmt.Errorf("no integration kit found with name \"%s\"", ctx.Name)
+	err = c.Delete(command.Context, &kl)
+	if err != nil {
+		if k8errors.IsNotFound(err) {
+			return fmt.Errorf("no kamelet found with name \"%s\"", name)
+		} else {
+			return fmt.Errorf("error deleting kamelet \"%s\", %s", name, err)
+		}
 	}
-
-	fmt.Printf("integration kit \"%s\" has been deleted\n", ctx.Name)
-
-	return err
+	fmt.Printf("kamelet \"%s\" has been deleted\n", name)
+	return nil
 }
diff --git a/pkg/cmd/kamelet_get.go b/pkg/cmd/kamelet_get.go
new file mode 100644
index 0000000..b9e5cd4
--- /dev/null
+++ b/pkg/cmd/kamelet_get.go
@@ -0,0 +1,139 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package cmd
+
+import (
+	"errors"
+	"fmt"
+	"strings"
+	"text/tabwriter"
+
+	"github.com/spf13/cobra"
+
+	k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
+
+	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
+)
+
+func newKameletGetCmd(rootCmdOptions *RootCmdOptions) (*cobra.Command, *kameletGetCommandOptions) {
+	options := kameletGetCommandOptions{
+		RootCmdOptions: rootCmdOptions,
+	}
+
+	cmd := cobra.Command{
+		Use:     "get",
+		Short:   "Get defined Kamelet",
+		Long:    `Get defined Kamelet.`,
+		PreRunE: decode(&options),
+		RunE: func(cmd *cobra.Command, args []string) error {
+			if err := options.validate(cmd, args); err != nil {
+				return err
+			}
+			if err := options.run(cmd); err != nil {
+				fmt.Println(err.Error())
+			}
+
+			return nil
+		},
+	}
+
+	cmd.Flags().Bool("sink", false, "Show only sink Kamelets")
+	cmd.Flags().Bool("source", false, "Show only source Kamelets")
+	cmd.Flags().Bool("action", false, "Show only action Kamelets")
+	cmd.Flags().String("group", "", "Filters Kamelets by group")
+	cmd.Flags().Bool("bundled", true, "Includes bundled Kamelets")
+	cmd.Flags().Bool("read-only", true, "Includes read-only Kamelets")
+
+	return &cmd, &options
+}
+
+type kameletGetCommandOptions struct {
+	*RootCmdOptions
+	Sink     bool   `mapstructure:"sink"`
+	Source   bool   `mapstructure:"source"`
+	Action   bool   `mapstructure:"action"`
+	Group    string `mapstructure:"group"`
+	Bundled  bool   `mapstructure:"bundled"`
+	ReadOnly bool   `mapstructure:"read-only"`
+}
+
+func (command *kameletGetCommandOptions) validate(cmd *cobra.Command, args []string) error {
+	count := 0
+	for _, b := range []bool{command.Sink, command.Source, command.Action} {
+		if b {
+			count++
+		}
+	}
+
+	if count > 1 {
+		return errors.New("invalid combination: flags --sink, --source, and --action are mutually exclusive")
+	}
+	return nil
+}
+
+func (command *kameletGetCommandOptions) run(cmd *cobra.Command) error {
+	c, err := command.GetCmdClient()
+	if err != nil {
+		return err
+	}
+
+	klList := v1alpha1.NewKameletList()
+	if err := c.List(command.Context, &klList, k8sclient.InNamespace(command.Namespace)); err != nil {
+		return err
+	}
+
+	w := tabwriter.NewWriter(cmd.OutOrStdout(), 0, 8, 1, '\t', 0)
+	fmt.Fprintln(w, "NAME\tPHASE\tTYPE\tGROUP\tBUNDLED\tREAD ONLY\tTITLE")
+	for _, kl := range klList.Items {
+		klType := kl.Labels[v1alpha1.KameletTypeLabel]
+		group := kl.Annotations[v1alpha1.KameletGroupLabel]
+		bundled := kl.Labels[v1alpha1.KameletBundledLabel]
+		readOnly := kl.Labels[v1alpha1.KameletReadOnlyLabel]
+
+		if command.Sink && klType != v1alpha1.KameletTypeSink {
+			continue
+		}
+		if command.Source && klType != v1alpha1.KameletTypeSource {
+			continue
+		}
+		if command.Action && klType != v1alpha1.KameletTypeAction {
+			continue
+		}
+		if command.Group != "" && !strings.EqualFold(command.Group, group) {
+			continue
+		}
+		if !command.Bundled && bundled == "true" {
+			continue
+		}
+		if !command.ReadOnly && readOnly == "true" {
+			continue
+		}
+
+		fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s\n",
+			kl.Name,
+			string(kl.Status.Phase),
+			klType,
+			group,
+			bundled,
+			readOnly,
+			kl.Spec.Definition.Title)
+	}
+	w.Flush()
+
+	return nil
+}
diff --git a/pkg/cmd/kit_delete.go b/pkg/cmd/kit_delete.go
index 53dec61..0a0428d 100644
--- a/pkg/cmd/kit_delete.go
+++ b/pkg/cmd/kit_delete.go
@@ -35,7 +35,7 @@ func newKitDeleteCmd(rootCmdOptions *RootCmdOptions) (*cobra.Command, *kitDelete
 	}
 
 	cmd := cobra.Command{
-		Use:     "delete",
+		Use:     "delete <name>",
 		Short:   "Delete an Integration Kit",
 		Long:    `Delete an Integration Kit.`,
 		PreRunE: decode(&options),
diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go
index 0e2ff77..b982286 100644
--- a/pkg/cmd/root.go
+++ b/pkg/cmd/root.go
@@ -148,6 +148,7 @@ func addKamelSubcommands(cmd *cobra.Command, options *RootCmdOptions) {
 	cmd.AddCommand(cmdOnly(newCmdDump(options)))
 	cmd.AddCommand(newCmdLocal(options))
 	cmd.AddCommand(cmdOnly(newCmdBind(options)))
+	cmd.AddCommand(newCmdKamelet(options))
 }
 
 func addHelpSubCommands(cmd *cobra.Command, options *RootCmdOptions) error {
diff --git a/pkg/install/kamelets.go b/pkg/install/kamelets.go
index 6d92b9d..939c6a9 100644
--- a/pkg/install/kamelets.go
+++ b/pkg/install/kamelets.go
@@ -37,8 +37,6 @@ import (
 
 const kameletDirEnv = "KAMELET_CATALOG_DIR"
 const defaultKameletDir = "/kamelets/"
-const kameletBundledLabel = "camel.apache.org/kamelet.bundled"
-const kameletReadOnlyLabel = "camel.apache.org/kamelet.readonly"
 
 // KameletCatalog installs the bundled KameletCatalog into one namespace
 func KameletCatalog(ctx context.Context, c client.Client, namespace string) error {
@@ -93,8 +91,8 @@ func KameletCatalog(ctx context.Context, c client.Client, namespace string) erro
 				if k.GetLabels() == nil {
 					k.SetLabels(make(map[string]string))
 				}
-				k.GetLabels()[kameletBundledLabel] = "true"
-				k.GetLabels()[kameletReadOnlyLabel] = "true"
+				k.GetLabels()[v1alpha1.KameletBundledLabel] = "true"
+				k.GetLabels()[v1alpha1.KameletReadOnlyLabel] = "true"
 
 				err := ObjectOrCollect(ctx, c, namespace, nil, true, k)
 

[camel-k] 05/05: Updated CHANGELOG.md

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

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

commit 417334acb83fd4eba0d774535d61c9f631a5ec43
Author: github-actions[bot] <41...@users.noreply.github.com>
AuthorDate: Sat Jun 5 04:19:36 2021 +0000

    Updated CHANGELOG.md
---
 CHANGELOG.md | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 329f7e3..ecdaeed 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,7 +6,9 @@
 
 **Closed issues:**
 
+- Maven logs are no longer shown [\#2357](https://github.com/apache/camel-k/issues/2357)
 - kamelets: add condition to report when an integration is stuck waiting for them  [\#2331](https://github.com/apache/camel-k/issues/2331)
+- Property in cron trait to set `startingDeadlineSeconds` [\#2330](https://github.com/apache/camel-k/issues/2330)
 - maven-repository flag is not honored in the run command  [\#2327](https://github.com/apache/camel-k/issues/2327)
 - Timeout when debugging the operator locally [\#2315](https://github.com/apache/camel-k/issues/2315)
 - Creating an IntegrationPlatform with the route Trait Crashes the Operator [\#2313](https://github.com/apache/camel-k/issues/2313)
@@ -43,12 +45,15 @@
 
 **Merged pull requests:**
 
+- Update README to reflect where Sample.java is [\#2359](https://github.com/apache/camel-k/pull/2359) ([bentito](https://github.com/bentito))
+- Related to \#2165: account for annotations when checking if integratio… [\#2352](https://github.com/apache/camel-k/pull/2352) ([nicolaferraro](https://github.com/nicolaferraro))
 - feat\(cli\): add sub command kamel kamelet for get and delete \#2312 [\#2351](https://github.com/apache/camel-k/pull/2351) ([tadayosi](https://github.com/tadayosi))
 - fix\(cli\): stop printing \<nil\> at the end of kamel describe output [\#2350](https://github.com/apache/camel-k/pull/2350) ([tadayosi](https://github.com/tadayosi))
 - chore\(build\): Cancellable Maven operations [\#2348](https://github.com/apache/camel-k/pull/2348) ([astefanutti](https://github.com/astefanutti))
 - feat\(cli\): support k8s api shortnames for kit & platform with kamel describe [\#2346](https://github.com/apache/camel-k/pull/2346) ([tadayosi](https://github.com/tadayosi))
 - feat\(cli\): initial support for describing Kamelets with kamel describe \#2312 [\#2345](https://github.com/apache/camel-k/pull/2345) ([tadayosi](https://github.com/tadayosi))
 - chore\(api\): Encapsulate Maven properties [\#2344](https://github.com/apache/camel-k/pull/2344) ([astefanutti](https://github.com/astefanutti))
+- Starting deadline seconds [\#2342](https://github.com/apache/camel-k/pull/2342) ([zach-robinson](https://github.com/zach-robinson))
 - Add link to the github repo [\#2340](https://github.com/apache/camel-k/pull/2340) ([davidlanouette](https://github.com/davidlanouette))
 - feat\(cmd/run\): --config option flag [\#2339](https://github.com/apache/camel-k/pull/2339) ([squakez](https://github.com/squakez))
 - Fix \#2165: allow configuring traits via annotations [\#2338](https://github.com/apache/camel-k/pull/2338) ([nicolaferraro](https://github.com/nicolaferraro))

[camel-k] 04/05: Update README to reflect where Sample.java is

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

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

commit 64edc38045aae147c7733e31470295b783e41268
Author: Brett Tofel <bt...@redhat.com>
AuthorDate: Fri Jun 4 08:32:48 2021 -0400

    Update README to reflect where Sample.java is
    
    Seems like the sample code got moved into a sub directory.
---
 README.adoc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.adoc b/README.adoc
index 0d57b3d..c34725e 100644
--- a/README.adoc
+++ b/README.adoc
@@ -62,7 +62,7 @@ For Minishift, this means executing `oc login -u system:admin` then `kamel insta
 After the initial setup, you can run a Camel integration on the cluster by executing:
 
 ```
-kamel run examples/Sample.java
+kamel run examples/languages/Sample.java
 ```
 
 During your first run you may see your console stuck with the following message:

[camel-k] 02/05: Updated CHANGELOG.md

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

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

commit 149dcfc1226ca3c73cfa376746d91e653733059b
Author: github-actions[bot] <41...@users.noreply.github.com>
AuthorDate: Fri Jun 4 04:45:01 2021 +0000

    Updated CHANGELOG.md
---
 CHANGELOG.md | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9d90b94..329f7e3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,8 +10,10 @@
 - maven-repository flag is not honored in the run command  [\#2327](https://github.com/apache/camel-k/issues/2327)
 - Timeout when debugging the operator locally [\#2315](https://github.com/apache/camel-k/issues/2315)
 - Creating an IntegrationPlatform with the route Trait Crashes the Operator [\#2313](https://github.com/apache/camel-k/issues/2313)
+- Kamel Kamelets subcommand [\#2312](https://github.com/apache/camel-k/issues/2312)
 - Integration container build errors are absent from the log messages [\#2306](https://github.com/apache/camel-k/issues/2306)
 - Kamel delete should consider KameletBindings [\#2305](https://github.com/apache/camel-k/issues/2305)
+- Log parsing errors [\#2299](https://github.com/apache/camel-k/issues/2299)
 - Structured logs: remaining bits [\#2286](https://github.com/apache/camel-k/issues/2286)
 - \[Docs\] Broken links on autogenerated API [\#2280](https://github.com/apache/camel-k/issues/2280)
 - Normalize Spectrum build logs [\#2276](https://github.com/apache/camel-k/issues/2276)
@@ -41,11 +43,14 @@
 
 **Merged pull requests:**
 
+- feat\(cli\): add sub command kamel kamelet for get and delete \#2312 [\#2351](https://github.com/apache/camel-k/pull/2351) ([tadayosi](https://github.com/tadayosi))
+- fix\(cli\): stop printing \<nil\> at the end of kamel describe output [\#2350](https://github.com/apache/camel-k/pull/2350) ([tadayosi](https://github.com/tadayosi))
 - chore\(build\): Cancellable Maven operations [\#2348](https://github.com/apache/camel-k/pull/2348) ([astefanutti](https://github.com/astefanutti))
 - feat\(cli\): support k8s api shortnames for kit & platform with kamel describe [\#2346](https://github.com/apache/camel-k/pull/2346) ([tadayosi](https://github.com/tadayosi))
 - feat\(cli\): initial support for describing Kamelets with kamel describe \#2312 [\#2345](https://github.com/apache/camel-k/pull/2345) ([tadayosi](https://github.com/tadayosi))
 - chore\(api\): Encapsulate Maven properties [\#2344](https://github.com/apache/camel-k/pull/2344) ([astefanutti](https://github.com/astefanutti))
 - Add link to the github repo [\#2340](https://github.com/apache/camel-k/pull/2340) ([davidlanouette](https://github.com/davidlanouette))
+- feat\(cmd/run\): --config option flag [\#2339](https://github.com/apache/camel-k/pull/2339) ([squakez](https://github.com/squakez))
 - Fix \#2165: allow configuring traits via annotations [\#2338](https://github.com/apache/camel-k/pull/2338) ([nicolaferraro](https://github.com/nicolaferraro))
 - kamelets: add condition to report when an integration is stuck waiting for them [\#2337](https://github.com/apache/camel-k/pull/2337) ([lburgazzoli](https://github.com/lburgazzoli))
 - doc\(dev\): add instruction for deploying custom images to remote clusters [\#2336](https://github.com/apache/camel-k/pull/2336) ([tadayosi](https://github.com/tadayosi))

[camel-k] 03/05: Related to #2165: account for annotations when checking if integration is changed

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

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

commit ad97cfad1745d649b4148a175cf3f71a8fb49398
Author: nicolaferraro <ni...@gmail.com>
AuthorDate: Thu Jun 3 11:00:14 2021 +0200

    Related to #2165: account for annotations when checking if integration is changed
---
 pkg/util/digest/digest.go      | 19 +++++++++++++++++
 pkg/util/digest/digest_test.go | 46 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+)

diff --git a/pkg/util/digest/digest.go b/pkg/util/digest/digest.go
index c63259c..e3baad4 100644
--- a/pkg/util/digest/digest.go
+++ b/pkg/util/digest/digest.go
@@ -29,6 +29,7 @@ import (
 	"path"
 	"sort"
 	"strconv"
+	"strings"
 
 	v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
 	"github.com/apache/camel-k/pkg/util"
@@ -120,6 +121,13 @@ func ComputeForIntegration(integration *v1.Integration) (string, error) {
 			return "", err
 		}
 	}
+	// Integration traits as annotations
+	for _, k := range sortedTraitAnnotationsKeys(integration) {
+		v := integration.Annotations[k]
+		if _, err := hash.Write([]byte(fmt.Sprintf("%s=%v,", k, v))); err != nil {
+			return "", err
+		}
+	}
 
 	// Add a letter at the beginning and use URL safe encoding
 	digest := "v" + base64.RawURLEncoding.EncodeToString(hash.Sum(nil))
@@ -241,6 +249,17 @@ func sortedTraitSpecMapKeys(m map[string]v1.TraitSpec) []string {
 	return res
 }
 
+func sortedTraitAnnotationsKeys(it *v1.Integration) []string {
+	res := make([]string, 0, len(it.Annotations))
+	for k := range it.Annotations {
+		if strings.HasPrefix(k, v1.TraitAnnotationPrefix) {
+			res = append(res, k)
+		}
+	}
+	sort.Strings(res)
+	return res
+}
+
 func ComputeSHA1(elem ...string) (string, error) {
 	file := path.Join(elem...)
 
diff --git a/pkg/util/digest/digest_test.go b/pkg/util/digest/digest_test.go
new file mode 100644
index 0000000..096146f
--- /dev/null
+++ b/pkg/util/digest/digest_test.go
@@ -0,0 +1,46 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package digest
+
+import (
+	"testing"
+
+	v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+	"github.com/stretchr/testify/assert"
+)
+
+func TestDigestUsesAnnotations(t *testing.T) {
+	it := v1.Integration{}
+	digest1, err := ComputeForIntegration(&it)
+	assert.NoError(t, err)
+
+	it.Annotations = map[string]string{
+		"another.annotation": "hello",
+	}
+	digest2, err := ComputeForIntegration(&it)
+	assert.NoError(t, err)
+	assert.Equal(t, digest1, digest2)
+
+	it.Annotations = map[string]string{
+		"another.annotation":                   "hello",
+		"trait.camel.apache.org/cron.fallback": "true",
+	}
+	digest3, err := ComputeForIntegration(&it)
+	assert.NoError(t, err)
+	assert.NotEqual(t, digest1, digest3)
+}