Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.2.x] fix(cmd): cannot load catalog on CLI #5297

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ func (o *runCmdOptions) applyDependencies(cmd *cobra.Command, c client.Client, i
// And the validation only warns potential misusages of Camel components at the CLI level,
// so strictness of catalog version is not necessary here.
var err error
catalog, err = createCamelCatalog(o.Context)
catalog, err = createCamelCatalog()
if err != nil {
return err
}
Expand Down
31 changes: 1 addition & 30 deletions pkg/cmd/run_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ import (
v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
"github.com/apache/camel-k/v2/pkg/client"
"github.com/apache/camel-k/v2/pkg/util/camel"
"github.com/apache/camel-k/v2/pkg/util/defaults"
"github.com/apache/camel-k/v2/pkg/util/kubernetes"
"github.com/apache/camel-k/v2/pkg/util/maven"
"github.com/apache/camel-k/v2/pkg/util/resource"
"github.com/magiconair/properties"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -182,40 +180,13 @@ func validatePropertyFile(fileName string) error {
return nil
}

func createCamelCatalog(ctx context.Context) (*camel.RuntimeCatalog, error) {
func createCamelCatalog() (*camel.RuntimeCatalog, error) {
// Attempt to reuse existing Camel catalog if one is present
catalog, err := camel.DefaultCatalog()
if err != nil {
return nil, err
}

// Generate catalog if one was not found
if catalog == nil {
catalog, err = generateCatalog(ctx)
if err != nil {
return nil, err
}
}

return catalog, nil
}

func generateCatalog(ctx context.Context) (*camel.RuntimeCatalog, error) {
// A Camel catalog is required for this operation
mvn := v1.MavenSpec{
LocalRepository: "",
}
runtime := v1.RuntimeSpec{
Version: defaults.DefaultRuntimeVersion,
Provider: v1.RuntimeProviderQuarkus,
}
var providerDependencies []maven.Dependency
var caCert [][]byte
catalog, err := camel.GenerateCatalogCommon(ctx, nil, nil, caCert, mvn, runtime, providerDependencies)
if err != nil {
return nil, err
}

return catalog, nil
}

Expand Down
Loading