You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2022/04/18 15:05:56 UTC

[camel-k] 01/02: fixed logic for flags: properties, cm and secrets

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

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

commit 03393113d23c846b54032d235147ee96d7ede9a1
Author: gre8t <ak...@gmail.com>
AuthorDate: Sun Apr 17 12:22:48 2022 +0100

    fixed logic for flags: properties, cm and secrets
---
 pkg/cmd/kit_create.go | 41 ++++++++++++++++++++---------------------
 1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/pkg/cmd/kit_create.go b/pkg/cmd/kit_create.go
index 146a96282..4519404d1 100644
--- a/pkg/cmd/kit_create.go
+++ b/pkg/cmd/kit_create.go
@@ -146,28 +146,20 @@ func (command *kitCreateCommandOptions) run(cmd *cobra.Command, args []string) e
 		}
 	}
 
-	for _, item := range command.Properties {
-		kit.Spec.Configuration = append(kit.Spec.Configuration, v1.ConfigurationSpec{
-			Type:  "property",
-			Value: item,
-		})
-	}
-	for _, item := range command.Configmaps {
-		kit.Spec.Configuration = append(kit.Spec.Configuration, v1.ConfigurationSpec{
-			Type:  "configmap",
-			Value: item,
-		})
-	}
-	for _, item := range command.Secrets {
-		kit.Spec.Configuration = append(kit.Spec.Configuration, v1.ConfigurationSpec{
-			Type:  "secret",
-			Value: item,
-		})
-	}
-	if err := command.configureTraits(kit, command.Traits, catalog); err != nil {
-		return err
-	}
+if err := command.parseAndConvertToTrait(command.Properties, "camel.properties"); err != nil {
+	return err
+}
+
+if err := command.parseAndConvertToTrait(command.Configmaps, "mount.config"); err != nil {
+	return err
+}
 
+if err := command.parseAndConvertToTrait(command.Secrets, "mount.config"); err != nil {
+	return err
+}
+if err := command.configureTraits(kit, command.Traits, catalog); err != nil {
+return err
+}
 	existed := false
 	err = c.Create(command.Context, kit)
 	if err != nil && k8serrors.IsAlreadyExists(err) {
@@ -206,3 +198,10 @@ func (*kitCreateCommandOptions) configureTraits(kit *v1.IntegrationKit, options
 
 	return nil
 }
+func (command *kitCreateCommandOptions) parseAndConvertToTrait(params []string, traitParam string, ) error {
+	for _, param := range params {
+		command.Traits = append(command.Traits, convertToTrait(param, traitParam))
+	}
+	
+	return nil
+}
\ No newline at end of file