This is an automated email from the ASF dual-hosted git repository. nferraro pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 539d069e2c3cb369ad297557c5afea5ab058dff2 Author: Doru Bercea <gheorghe-teod.ber...@ibm.com> AuthorDate: Mon Oct 12 15:09:29 2020 -0400 Re-use existing Camel catalog if one is present. --- pkg/cmd/inspect.go | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/pkg/cmd/inspect.go b/pkg/cmd/inspect.go index 7a92d02..c26cbb6 100644 --- a/pkg/cmd/inspect.go +++ b/pkg/cmd/inspect.go @@ -111,21 +111,20 @@ func (command *inspectCmdOptions) validate(args []string) error { } func (command *inspectCmdOptions) run(args []string) error { - // A Camel catalog is requiref for this operatio. - settings := "" - mvn := v1.MavenSpec{ - LocalRepository: "", - } - runtime := v1.RuntimeSpec{ - Version: "1.3.0", - Provider: v1.RuntimeProviderMain, - } - providerDependencies := []maven.Dependency{} - catalog, err := camel.GenerateLocalCatalog(settings, mvn, runtime, providerDependencies) + // Attempt to reuse existing Camel catalog if one is present. + catalog, err := camel.MainCatalog() if err != nil { return err } + // Generate catalog if one was not found. + if catalog == nil { + catalog, err = generateCatalog() + if err != nil { + return err + } + } + // TODO: compression not supported for this command for now. compression := false @@ -157,3 +156,22 @@ func (command *inspectCmdOptions) run(args []string) error { return nil } + +func generateCatalog() (*camel.RuntimeCatalog, error) { + // A Camel catalog is requiref for this operatio. + settings := "" + mvn := v1.MavenSpec{ + LocalRepository: "", + } + runtime := v1.RuntimeSpec{ + Version: "1.3.0", + Provider: v1.RuntimeProviderMain, + } + providerDependencies := []maven.Dependency{} + catalog, err := camel.GenerateLocalCatalog(settings, mvn, runtime, providerDependencies) + if err != nil { + return nil, err + } + + return catalog, nil +}