git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GitHub] nicolaferraro commented on a change in pull request #235: Support for multiple integration definitions


nicolaferraro commented on a change in pull request #235: Support for multiple integration definitions
URL: https://github.com/apache/camel-k/pull/235#discussion_r235682388
 
 

 ##########
 File path: pkg/client/cmd/run.go
 ##########
 @@ -215,54 +220,49 @@ func (o *runCmdOptions) waitForIntegrationReady(integration *v1alpha1.Integratio
 	return watch.HandleStateChanges(o.Context, integration, handler)
 }
 
-func (o *runCmdOptions) syncIntegration(file string) error {
-	changes, err := sync.File(o.Context, file)
-	if err != nil {
-		return err
-	}
-	go func() {
-		for {
-			select {
-			case <-o.Context.Done():
-				return
-			case <-changes:
-				_, err := o.updateIntegrationCode(file)
-				if err != nil {
-					logrus.Error("Unable to sync integration: ", err)
+func (o *runCmdOptions) syncIntegration(sources []string) error {
+	for _, s := range sources {
+		changes, err := sync.File(o.Context, s)
+		if err != nil {
+			return err
+		}
+		go func() {
+			for {
+				select {
+				case <-o.Context.Done():
+					return
+				case <-changes:
+					_, err := o.updateIntegrationCode(sources)
+					if err != nil {
+						logrus.Error("Unable to sync integration: ", err)
+					}
 				}
 			}
-		}
-	}()
+		}()
+	}
+
 	return nil
 }
 
 func (o *runCmdOptions) createIntegration(cmd *cobra.Command, args []string) (*v1alpha1.Integration, error) {
-	return o.updateIntegrationCode(args[0])
+	return o.updateIntegrationCode(args)
 }
 
-func (o *runCmdOptions) updateIntegrationCode(filename string) (*v1alpha1.Integration, error) {
-	code, err := o.loadCode(filename)
-	if err != nil {
-		return nil, err
-	}
+func (o *runCmdOptions) updateIntegrationCode(sources []string) (*v1alpha1.Integration, error) {
 
 	namespace := o.Namespace
 
 	name := ""
 	if o.IntegrationName != "" {
 		name = o.IntegrationName
 		name = kubernetes.SanitizeName(name)
-	} else {
-		name = kubernetes.SanitizeName(filename)
+	} else if len(sources) == 1 {
+		name = kubernetes.SanitizeName(sources[0])
 		if name == "" {
 			name = "integration"
 		}
-	}
-
-	codeName := filename
-
-	if idx := strings.LastIndexByte(filename, os.PathSeparator); idx > -1 {
-		codeName = codeName[idx+1:]
+	} else {
 
 Review comment:
   Maybe we should print a better message saying that if you use multiple sources, the name becomes mandatory. Also, it's dangerous to call the integration "integration" (the old way) when there's no other info, because new integrations override old ones..

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@xxxxxxxxxxxxxxxx


With regards,
Apache Git Services