You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "christophd (via GitHub)" <gi...@apache.org> on 2023/05/23 07:30:18 UTC

[GitHub] [camel-k] christophd commented on a diff in pull request #4402: fix(#4361): Avoid errors when components not available in Camel catalog

christophd commented on code in PR #4402:
URL: https://github.com/apache/camel-k/pull/4402#discussion_r1201680120


##########
pkg/util/camel/camel_dependencies.go:
##########
@@ -49,57 +50,49 @@ func NormalizeDependency(dependency string) string {
 	return newDep
 }
 
-type Output interface {
-	OutOrStdout() io.Writer
-	ErrOrStderr() io.Writer
-}
-
 // ValidateDependencies validates dependencies against Camel catalog.
 // It only shows warning and does not throw error in case the Catalog is just not complete
 // and we don't want to let it stop the process.
-func ValidateDependencies(catalog *RuntimeCatalog, dependencies []string, out Output) {
-	for _, d := range dependencies {
-		ValidateDependency(catalog, d, out)
+func ValidateDependencies(catalog *RuntimeCatalog, dependencies []string, logger log.Logger) {
+	for _, dependency := range dependencies {
+		s := strings.Builder{}
+		ValidateDependency(catalog, dependency, &s)
+
+		if s.Len() > 0 {
+			logger.Info(strings.TrimSpace(s.String()))
+		}
 	}
 }
 
 // ValidateDependency validates a dependency against Camel catalog.
 // It only shows warning and does not throw error in case the Catalog is just not complete
 // and we don't want to let it stop the process.
-func ValidateDependency(catalog *RuntimeCatalog, dependency string, out Output) {
+func ValidateDependency(catalog *RuntimeCatalog, dependency string, out io.Writer) {
+	var artifact string
 	switch {
 	case strings.HasPrefix(dependency, "camel:"):
-		artifact := strings.TrimPrefix(dependency, "camel:")
-		if ok := catalog.IsValidArtifact(artifact); !ok {
-			fmt.Fprintf(out.ErrOrStderr(), "Warning: dependency %s not found in Camel catalog\n", dependency)

Review Comment:
   things are a bit different here. the function that you mention that prints to the stderr has not been used before. instead there was another function in usage that raised the error as part of the integration phase. I have removed this latter function and changed the logic of the unused function to the new logic. In fact we do not have stderr access as this function is run as part of the traits execution. kamel run command is completed already at this point.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org