You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ts...@apache.org on 2022/09/15 23:42:32 UTC
[camel-k] 07/11: feat(controller): log error if a dependency is not valid in catalog
This is an automated email from the ASF dual-hosted git repository.
tsato pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 2da65f2681f67904cfc719deb6573286be8ce92c
Author: Tadayoshi Sato <sa...@gmail.com>
AuthorDate: Wed Sep 14 13:14:34 2022 +0900
feat(controller): log error if a dependency is not valid in catalog
---
pkg/trait/dependencies.go | 4 ++++
pkg/util/camel/camel_dependencies.go | 17 +++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/pkg/trait/dependencies.go b/pkg/trait/dependencies.go
index 5a68c3cef..41f1f3d61 100644
--- a/pkg/trait/dependencies.go
+++ b/pkg/trait/dependencies.go
@@ -26,6 +26,7 @@ import (
traitv1 "github.com/apache/camel-k/pkg/apis/camel/v1/trait"
"github.com/apache/camel-k/pkg/metadata"
"github.com/apache/camel-k/pkg/util"
+ "github.com/apache/camel-k/pkg/util/camel"
"github.com/apache/camel-k/pkg/util/kubernetes"
)
@@ -56,6 +57,9 @@ func (t *dependenciesTrait) Apply(e *Environment) error {
dependencies := strset.New()
if e.Integration.Spec.Dependencies != nil {
+ if err := camel.ValidateDependenciesE(e.CamelCatalog, e.Integration.Spec.Dependencies); err != nil {
+ return err
+ }
dependencies.Add(e.Integration.Spec.Dependencies...)
}
diff --git a/pkg/util/camel/camel_dependencies.go b/pkg/util/camel/camel_dependencies.go
index c8dea7ca9..29db9f83f 100644
--- a/pkg/util/camel/camel_dependencies.go
+++ b/pkg/util/camel/camel_dependencies.go
@@ -78,6 +78,23 @@ func ValidateDependency(catalog *RuntimeCatalog, dependency string, out Output)
}
}
+// ValidateDependenciesE validates dependencies against Camel catalog and throws error
+// if it doesn't exist in the catalog.
+func ValidateDependenciesE(catalog *RuntimeCatalog, dependencies []string) error {
+ for _, dependency := range dependencies {
+ if !strings.HasPrefix(dependency, "camel:") {
+ continue
+ }
+
+ artifact := strings.TrimPrefix(dependency, "camel:")
+ if ok := catalog.HasArtifact(artifact); !ok {
+ return fmt.Errorf("dependency %s not found in Camel catalog", dependency)
+ }
+ }
+
+ return nil
+}
+
// ManageIntegrationDependencies sets up all the required dependencies for the given Maven project.
func ManageIntegrationDependencies(project *maven.Project, dependencies []string, catalog *RuntimeCatalog) error {
// Add dependencies from build