[camel-k] branch master updated (279e673 -> 6cb3dd5)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[camel-k] branch master updated (279e673 -> 6cb3dd5)

lburgazzoli-2
This is an automated email from the ASF dual-hosted git repository.

lburgazzoli pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git.


    from 279e673  remove integration delete action and finalizer #995
     new 59bebae  Include camel-k-runtime version in camel-catalog #959
     new 8a577b3  chore: upgrade and tune lint, fix findings
     new 6cb3dd5  chore: remove go version from go.mod

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .golangci.yml                                      |   5 +
 .travis.yml                                        |   2 +-
 assets/json-schema/CamelCatalog.json               |   4 +
 assets/json-schema/IntegrationKit.json             |   2 +-
 build/maven/pom-catalog.xml                        |   8 +-
 deploy/crd-camel-catalog.yaml                      |   8 +-
 deploy/resources.go                                |   8 +-
 pkg/apis/camel/v1alpha1/camelcatalog_types.go      |   5 +-
 .../v1alpha1/integrationplatform_types_support.go  |   1 -
 pkg/builder/builder.go                             |   2 +-
 pkg/builder/builder_steps.go                       |   4 +-
 pkg/builder/builder_steps_test.go                  |  84 ++++--------
 pkg/builder/builder_test.go                        |   3 +-
 pkg/builder/builder_utils.go                       |   4 +-
 pkg/builder/builder_utils_test.go                  |   5 +-
 pkg/cmd/describe_kit.go                            |   1 -
 pkg/cmd/kit_get.go                                 |   1 -
 pkg/controller/integrationplatform/initialize.go   |   3 +-
 .../integrationplatform_controller.go              |   1 -
 pkg/controller/integrationplatform/warm.go         |   3 -
 pkg/install/operator.go                            |   1 -
 pkg/trait/camel.go                                 |  31 +++--
 pkg/trait/camel_test.go                            |   2 +-
 pkg/trait/gc_test.go                               |   4 -
 pkg/trait/ingress_test.go                          |  11 --
 pkg/trait/trait_types.go                           |   1 -
 pkg/util/camel/camel.go                            |  42 ------
 pkg/util/camel/camel_runtime.go                    |  30 +----
 pkg/util/camel/camel_types.go                      |  58 ++++++++
 pkg/util/camel/camel_util.go                       |  90 +++++++------
 pkg/util/camel/camel_util_test.go                  | 147 ++++++++++++++++-----
 pkg/util/defaults/defaults.go                      |  10 +-
 pkg/util/envvar/envvar.go                          |   1 -
 pkg/util/kubernetes/log/annotation_scraper.go      |   1 -
 pkg/util/kubernetes/log/pod_scraper.go             |   2 -
 pkg/util/openshift/register.go                     |   1 -
 pkg/util/test/catalog.go                           |   2 +-
 pkg/util/test/catalog_test.go                      |   4 +-
 pkg/util/test/client.go                            |   1 -
 script/Makefile                                    |  11 +-
 script/build_catalog.sh                            |   1 -
 41 files changed, 331 insertions(+), 274 deletions(-)
 delete mode 100644 pkg/util/camel/camel.go
 create mode 100644 pkg/util/camel/camel_types.go

Reply | Threaded
Open this post in threaded view
|

[camel-k] 01/03: Include camel-k-runtime version in camel-catalog #959

lburgazzoli-2
This is an automated email from the ASF dual-hosted git repository.

lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 59bebae1d9f9d2414979a2c18f9e8ab581c42977
Author: lburgazzoli <[hidden email]>
AuthorDate: Tue Oct 8 16:27:44 2019 +0200

    Include camel-k-runtime version in camel-catalog #959
---
 assets/json-schema/CamelCatalog.json             |   4 +
 assets/json-schema/IntegrationKit.json           |   2 +-
 build/maven/pom-catalog.xml                      |   8 +-
 deploy/crd-camel-catalog.yaml                    |   8 +-
 deploy/resources.go                              |   8 +-
 go.mod                                           |   2 +
 pkg/apis/camel/v1alpha1/camelcatalog_types.go    |   5 +-
 pkg/builder/builder.go                           |   2 +-
 pkg/builder/builder_steps.go                     |   4 +-
 pkg/builder/builder_steps_test.go                |  35 +++---
 pkg/builder/builder_test.go                      |   3 +-
 pkg/builder/builder_utils.go                     |   4 +-
 pkg/builder/builder_utils_test.go                |   5 +-
 pkg/controller/integrationplatform/initialize.go |   2 +-
 pkg/trait/camel.go                               |  31 +++--
 pkg/trait/camel_test.go                          |   2 +-
 pkg/util/camel/camel.go                          |  42 -------
 pkg/util/camel/camel_runtime.go                  |  30 ++---
 pkg/util/camel/camel_types.go                    |  58 +++++++++
 pkg/util/camel/camel_util.go                     |  90 +++++++-------
 pkg/util/camel/camel_util_test.go                | 147 +++++++++++++++++------
 pkg/util/defaults/defaults.go                    |  10 +-
 pkg/util/test/catalog.go                         |   2 +-
 pkg/util/test/catalog_test.go                    |   4 +-
 script/Makefile                                  |  11 +-
 script/build_catalog.sh                          |   1 -
 26 files changed, 319 insertions(+), 201 deletions(-)

diff --git a/assets/json-schema/CamelCatalog.json b/assets/json-schema/CamelCatalog.json
index 1266aa1..b8e37a6 100644
--- a/assets/json-schema/CamelCatalog.json
+++ b/assets/json-schema/CamelCatalog.json
@@ -159,6 +159,7 @@
     "CamelCatalogSpec": {
       "required": [
         "version",
+        "runtimeVersion",
         "artifacts"
       ],
       "properties": {
@@ -171,6 +172,9 @@
           },
           "type": "object"
         },
+        "runtimeVersion": {
+          "type": "string"
+        },
         "version": {
           "type": "string"
         }
diff --git a/assets/json-schema/IntegrationKit.json b/assets/json-schema/IntegrationKit.json
index 94c94f1..0815ea8 100644
--- a/assets/json-schema/IntegrationKit.json
+++ b/assets/json-schema/IntegrationKit.json
@@ -441,4 +441,4 @@
       "type": "object"
     }
   }
-}
+}
\ No newline at end of file
diff --git a/build/maven/pom-catalog.xml b/build/maven/pom-catalog.xml
index db52c6d..acef746 100644
--- a/build/maven/pom-catalog.xml
+++ b/build/maven/pom-catalog.xml
@@ -46,7 +46,7 @@
                     <dependency>
                         <groupId>org.apache.camel</groupId>
                         <artifactId>camel-catalog</artifactId>
-                        <version>${catalog.version}</version>
+                        <version>${camel.version}</version>
                     </dependency>
                 </dependencies>
             </plugin>
@@ -56,7 +56,6 @@
     <repositories>
         <repository>
             <id>apache.snapshots</id>
-            <name>Apache Development Snapshot Repository</name>
             <url>https://repository.apache.org/content/repositories/snapshots/</url>
             <releases>
                 <enabled>false</enabled>
@@ -80,7 +79,6 @@
     <pluginRepositories>
         <pluginRepository>
             <id>apache.snapshots</id>
-            <name>Apache Development Snapshot Repository</name>
             <url>https://repository.apache.org/content/repositories/snapshots/</url>
             <releases>
                 <enabled>false</enabled>
@@ -101,4 +99,8 @@
         </pluginRepository>
     </pluginRepositories>
 
+
+
+
+
 </project>
diff --git a/deploy/crd-camel-catalog.yaml b/deploy/crd-camel-catalog.yaml
index 858bd0f..b57a08f 100644
--- a/deploy/crd-camel-catalog.yaml
+++ b/deploy/crd-camel-catalog.yaml
@@ -35,8 +35,12 @@ spec:
   subresources:
     status: {}
   additionalPrinterColumns:
-    - name: Version
+    - name: Camel Version
       type: string
-      description: The Catalog version
+      description: The Camel version
       JSONPath: .spec.version
+    - name: Runtime Version
+      type: string
+      description: The Camel K Runtime version
+      JSONPath: .spec.runtimeVersion
 
diff --git a/deploy/resources.go b/deploy/resources.go
index 2a59ae0..5b7c171 100644
--- a/deploy/resources.go
+++ b/deploy/resources.go
@@ -2531,10 +2531,14 @@ spec:
   subresources:
     status: {}
   additionalPrinterColumns:
-    - name: Version
+    - name: Camel Version
       type: string
-      description: The Catalog version
+      description: The Camel version
       JSONPath: .spec.version
+    - name: Runtime Version
+      type: string
+      description: The Camel K Runtime version
+      JSONPath: .spec.runtimeVersion
 
 
 `
diff --git a/go.mod b/go.mod
index bedbd73..583473d 100644
--- a/go.mod
+++ b/go.mod
@@ -51,3 +51,5 @@ replace (
 )
 
 replace git.apache.org/thrift.git => github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999
+
+go 1.13
diff --git a/pkg/apis/camel/v1alpha1/camelcatalog_types.go b/pkg/apis/camel/v1alpha1/camelcatalog_types.go
index e91210d..d778fb5 100644
--- a/pkg/apis/camel/v1alpha1/camelcatalog_types.go
+++ b/pkg/apis/camel/v1alpha1/camelcatalog_types.go
@@ -53,8 +53,9 @@ type CamelArtifact struct {
 
 // CamelCatalogSpec defines the desired state of CamelCatalog
 type CamelCatalogSpec struct {
- Version   string                   `json:"version" yaml:"version"`
- Artifacts map[string]CamelArtifact `json:"artifacts" yaml:"artifacts"`
+ Version        string                   `json:"version" yaml:"version"`
+ RuntimeVersion string                   `json:"runtimeVersion" yaml:"runtimeVersion"`
+ Artifacts      map[string]CamelArtifact `json:"artifacts" yaml:"artifacts"`
 }
 
 // CamelCatalogStatus defines the observed state of CamelCatalog
diff --git a/pkg/builder/builder.go b/pkg/builder/builder.go
index 7327d97..872c3df 100644
--- a/pkg/builder/builder.go
+++ b/pkg/builder/builder.go
@@ -71,7 +71,7 @@ func (b *defaultBuilder) Build(build v1alpha1.BuildSpec) v1alpha1.BuildStatus {
 
  defer os.RemoveAll(builderPath)
 
- catalog, err := camel.Catalog(b.ctx, b.client, build.Meta.Namespace, build.CamelVersion)
+ catalog, err := camel.LoadCatalog(b.ctx, b.client, build.Meta.Namespace, build.CamelVersion, build.RuntimeVersion)
  if err != nil {
  log.Error(err, "Error while loading Camel catalog")
 
diff --git a/pkg/builder/builder_steps.go b/pkg/builder/builder_steps.go
index 81cd13a..cb886f0 100644
--- a/pkg/builder/builder_steps.go
+++ b/pkg/builder/builder_steps.go
@@ -248,7 +248,7 @@ func computeDependencies(ctx *Context) error {
  mc.SettingsContent = ctx.Maven.SettingsData
  mc.LocalRepository = ctx.Build.Platform.Build.LocalRepository
  mc.Timeout = ctx.Build.Platform.Build.Maven.Timeout.Duration
- mc.AddArgumentf("org.apache.camel.k:camel-k-maven-plugin:%s:generate-dependency-list", ctx.Build.RuntimeVersion)
+ mc.AddArgumentf("org.apache.camel.k:camel-k-maven-plugin:%s:generate-dependency-list", ctx.Catalog.RuntimeVersion)
 
  if err := maven.Run(mc); err != nil {
  return errors.Wrap(err, "failure while determining classpath")
@@ -390,7 +390,7 @@ func listPublishedImages(context *Context) ([]publishedImage, error) {
  if kit.Status.CamelVersion != context.Catalog.Version {
  continue
  }
- if kit.Status.RuntimeVersion != context.Build.RuntimeVersion {
+ if kit.Status.RuntimeVersion != context.Catalog.RuntimeVersion {
  continue
  }
  if kit.Status.Phase != v1alpha1.IntegrationKitPhaseReady || kit.Labels == nil {
diff --git a/pkg/builder/builder_steps_test.go b/pkg/builder/builder_steps_test.go
index 3210dfa..e7da61a 100644
--- a/pkg/builder/builder_steps_test.go
+++ b/pkg/builder/builder_steps_test.go
@@ -25,7 +25,6 @@ import (
 
  "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
  "github.com/apache/camel-k/pkg/util/cancellable"
- "github.com/apache/camel-k/pkg/util/defaults"
  "github.com/apache/camel-k/pkg/util/maven"
  "github.com/apache/camel-k/pkg/util/test"
 
@@ -58,7 +57,7 @@ func TestGenerateJvmProject(t *testing.T) {
  ctx := Context{
  Catalog: catalog,
  Build: v1alpha1.BuildSpec{
- RuntimeVersion: defaults.RuntimeVersion,
+ RuntimeVersion: catalog.RuntimeVersion,
  Platform: v1alpha1.IntegrationPlatformSpec{
  Build: v1alpha1.IntegrationPlatformBuildSpec{
  CamelVersion: catalog.Version,
@@ -89,7 +88,7 @@ func TestGenerateJvmProject(t *testing.T) {
  {
  GroupID:    "org.apache.camel.k",
  ArtifactID: "camel-k-runtime-bom",
- Version:    defaults.RuntimeVersion,
+ Version:    catalog.RuntimeVersion,
  Type:       "pom",
  Scope:      "import",
  },
@@ -147,7 +146,7 @@ func TestMavenSettingsFromConfigMap(t *testing.T) {
  Client:    c,
  Namespace: "ns",
  Build: v1alpha1.BuildSpec{
- RuntimeVersion: defaults.RuntimeVersion,
+ RuntimeVersion: catalog.RuntimeVersion,
  Platform: v1alpha1.IntegrationPlatformSpec{
  Build: v1alpha1.IntegrationPlatformBuildSpec{
  CamelVersion: catalog.Version,
@@ -199,7 +198,7 @@ func TestMavenSettingsFromSecret(t *testing.T) {
  Client:    c,
  Namespace: "ns",
  Build: v1alpha1.BuildSpec{
- RuntimeVersion: defaults.RuntimeVersion,
+ RuntimeVersion: catalog.RuntimeVersion,
  Platform: v1alpha1.IntegrationPlatformSpec{
  Build: v1alpha1.IntegrationPlatformBuildSpec{
  CamelVersion: catalog.Version,
@@ -231,7 +230,7 @@ func TestGenerateGroovyProject(t *testing.T) {
  ctx := Context{
  Catalog: catalog,
  Build: v1alpha1.BuildSpec{
- RuntimeVersion: defaults.RuntimeVersion,
+ RuntimeVersion: catalog.RuntimeVersion,
  Platform: v1alpha1.IntegrationPlatformSpec{
  Build: v1alpha1.IntegrationPlatformBuildSpec{
  CamelVersion: catalog.Version,
@@ -263,7 +262,7 @@ func TestGenerateGroovyProject(t *testing.T) {
  {
  GroupID:    "org.apache.camel.k",
  ArtifactID: "camel-k-runtime-bom",
- Version:    defaults.RuntimeVersion,
+ Version:    catalog.RuntimeVersion,
  Type:       "pom",
  Scope:      "import",
  },
@@ -292,15 +291,15 @@ func TestGenerateGroovyProject(t *testing.T) {
  },
  {
  GroupID:    "org.apache.camel",
- ArtifactID: "camel-properties",
+ ArtifactID: "camel-groovy",
  },
  {
  GroupID:    "org.apache.camel",
- ArtifactID: "camel-endpointdsl",
+ ArtifactID: "camel-properties",
  },
  {
  GroupID:    "org.apache.camel",
- ArtifactID: "camel-groovy",
+ ArtifactID: "camel-endpointdsl",
  },
  },
  )
@@ -313,7 +312,7 @@ func TestSanitizeDependencies(t *testing.T) {
  ctx := Context{
  Catalog: catalog,
  Build: v1alpha1.BuildSpec{
- RuntimeVersion: defaults.RuntimeVersion,
+ RuntimeVersion: catalog.RuntimeVersion,
  Platform: v1alpha1.IntegrationPlatformSpec{
  Build: v1alpha1.IntegrationPlatformBuildSpec{
  CamelVersion: catalog.Version,
@@ -372,9 +371,10 @@ func TestListPublishedImages(t *testing.T) {
  },
  },
  Status: v1alpha1.IntegrationKitStatus{
- Phase:        v1alpha1.IntegrationKitPhaseError,
- Image:        "image-1",
- CamelVersion: catalog.Version,
+ Phase:          v1alpha1.IntegrationKitPhaseError,
+ Image:          "image-1",
+ CamelVersion:   catalog.Version,
+ RuntimeVersion: catalog.RuntimeVersion,
  },
  },
  &v1alpha1.IntegrationKit{
@@ -390,9 +390,10 @@ func TestListPublishedImages(t *testing.T) {
  },
  },
  Status: v1alpha1.IntegrationKitStatus{
- Phase:        v1alpha1.IntegrationKitPhaseReady,
- Image:        "image-2",
- CamelVersion: catalog.Version,
+ Phase:          v1alpha1.IntegrationKitPhaseReady,
+ Image:          "image-2",
+ CamelVersion:   catalog.Version,
+ RuntimeVersion: catalog.RuntimeVersion,
  },
  },
  )
diff --git a/pkg/builder/builder_test.go b/pkg/builder/builder_test.go
index 97ce186..ca899ae 100644
--- a/pkg/builder/builder_test.go
+++ b/pkg/builder/builder_test.go
@@ -22,7 +22,6 @@ import (
  "testing"
 
  "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
- "github.com/apache/camel-k/pkg/util/defaults"
  "github.com/apache/camel-k/pkg/util/test"
 
  "github.com/stretchr/testify/assert"
@@ -58,7 +57,7 @@ func TestFailure(t *testing.T) {
  steps.Step1,
  steps.Step2,
  ),
- RuntimeVersion: defaults.RuntimeVersion,
+ RuntimeVersion: catalog.RuntimeVersion,
  Platform: v1alpha1.IntegrationPlatformSpec{
  Build: v1alpha1.IntegrationPlatformBuildSpec{
  CamelVersion: catalog.Version,
diff --git a/pkg/builder/builder_utils.go b/pkg/builder/builder_utils.go
index 6d236a4..e6516dd 100644
--- a/pkg/builder/builder_utils.go
+++ b/pkg/builder/builder_utils.go
@@ -51,7 +51,7 @@ func NewMavenProject(ctx *Context) (maven.Project, error) {
  // Catalog
  //
  if ctx.Catalog == nil {
- c, err := camel.Catalog(ctx.C, ctx.Client, ctx.Namespace, ctx.Build.Platform.Build.CamelVersion)
+ c, err := camel.LoadCatalog(ctx.C, ctx.Client, ctx.Namespace, ctx.Build.Platform.Build.CamelVersion, ctx.Build.Platform.Build.RuntimeVersion)
  if err != nil {
  return maven.Project{}, err
  }
@@ -77,7 +77,7 @@ func NewMavenProject(ctx *Context) (maven.Project, error) {
  p.DependencyManagement.Dependencies = append(p.DependencyManagement.Dependencies, maven.Dependency{
  GroupID:    "org.apache.camel.k",
  ArtifactID: "camel-k-runtime-bom",
- Version:    ctx.Build.RuntimeVersion,
+ Version:    ctx.Catalog.RuntimeVersion,
  Type:       "pom",
  Scope:      "import",
  })
diff --git a/pkg/builder/builder_utils_test.go b/pkg/builder/builder_utils_test.go
index 0fc39d1..951d035 100644
--- a/pkg/builder/builder_utils_test.go
+++ b/pkg/builder/builder_utils_test.go
@@ -21,7 +21,6 @@ import (
  "testing"
 
  "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
- "github.com/apache/camel-k/pkg/util/defaults"
  "github.com/apache/camel-k/pkg/util/maven"
  "github.com/apache/camel-k/pkg/util/test"
 
@@ -35,7 +34,7 @@ func TestNewProject(t *testing.T) {
  ctx := Context{
  Catalog: catalog,
  Build: v1alpha1.BuildSpec{
- RuntimeVersion: defaults.RuntimeVersion,
+ RuntimeVersion: catalog.RuntimeVersion,
  Platform: v1alpha1.IntegrationPlatformSpec{
  Build: v1alpha1.IntegrationPlatformBuildSpec{
  CamelVersion: catalog.Version,
@@ -65,7 +64,7 @@ func TestNewProject(t *testing.T) {
  {
  GroupID:    "org.apache.camel.k",
  ArtifactID: "camel-k-runtime-bom",
- Version:    defaults.RuntimeVersion,
+ Version:    catalog.RuntimeVersion,
  Type:       "pom",
  Scope:      "import",
  },
diff --git a/pkg/controller/integrationplatform/initialize.go b/pkg/controller/integrationplatform/initialize.go
index c76c5a2..a2e4178 100644
--- a/pkg/controller/integrationplatform/initialize.go
+++ b/pkg/controller/integrationplatform/initialize.go
@@ -181,7 +181,7 @@ func (action *initializeAction) setDefaults(ctx context.Context, platform *v1alp
  platform.Spec.Build.CamelVersion = defaults.CamelVersionConstraint
  }
  if platform.Spec.Build.RuntimeVersion == "" {
- platform.Spec.Build.RuntimeVersion = defaults.RuntimeVersion
+ platform.Spec.Build.RuntimeVersion = defaults.RuntimeVersionConstraint
  }
  if platform.Spec.Build.BaseImage == "" {
  platform.Spec.Build.BaseImage = defaults.BaseImage
diff --git a/pkg/trait/camel.go b/pkg/trait/camel.go
index 7cfbc9d..b776d9c 100644
--- a/pkg/trait/camel.go
+++ b/pkg/trait/camel.go
@@ -73,31 +73,38 @@ func (t *camelTrait) Apply(e *Environment) error {
  }
 
  if e.CamelCatalog == nil {
- c, err := camel.Catalog(e.C, e.Client, ns, cv)
+ c, err := camel.LoadCatalog(e.C, e.Client, ns, cv, rv)
  if err != nil {
  return err
  }
  if c == nil {
- // if the catalog is not found in the cluster, try to create it if the
- // required version is not set using semver constraints
- matched, err := regexp.MatchString(`^(\d+)\.(\d+)\.([\w-\.]+)$`, cv)
+ // if the catalog is not found in the cluster, try to create it if
+ // the required versions (camel and runtime) are not expressed as
+ // semver constraints
+ cvHasFixedVersion, err := regexp.MatchString(`^(\d+)\.(\d+)\.([\w-\.]+)$`, cv)
  if err != nil {
  return err
  }
- if matched {
- c, err = t.GenerateCatalog(e, cv)
+ rvHasFixedVersion, err := regexp.MatchString(`^(\d+)\.(\d+)\.([\w-\.]+)$`, rv)
+ if err != nil {
+ return err
+ }
+
+ if cvHasFixedVersion && rvHasFixedVersion {
+ c, err = t.GenerateCatalog(e, cv, rv)
  if err != nil {
  return err
  }
 
  // sanitize catalog name
- catalogName := "camel-catalog-" + strings.ToLower(cv)
+ catalogName := "camel-catalog-" + strings.ToLower(cv+"-"+rv)
 
  cx := v1alpha1.NewCamelCatalogWithSpecs(ns, catalogName, c.CamelCatalogSpec)
  cx.Labels = make(map[string]string)
  cx.Labels["app"] = "camel-k"
  cx.Labels["camel.apache.org/catalog.version"] = cv
  cx.Labels["camel.apache.org/catalog.loader.version"] = cv
+ cx.Labels["camel.apache.org/runtime.version"] = rv
  cx.Labels["camel.apache.org/catalog.generated"] = True
 
  err = e.Client.Create(e.C, &cx)
@@ -129,7 +136,7 @@ func (t *camelTrait) Apply(e *Environment) error {
 }
 
 // GenerateCatalog --
-func (t *camelTrait) GenerateCatalog(e *Environment, version string) (*camel.RuntimeCatalog, error) {
+func (t *camelTrait) GenerateCatalog(e *Environment, camelVersion string, runtimeVersion string) (*camel.RuntimeCatalog, error) {
  root := os.TempDir()
  tmpDir, err := ioutil.TempDir(root, "camel-catalog")
  if err != nil {
@@ -142,7 +149,7 @@ func (t *camelTrait) GenerateCatalog(e *Environment, version string) (*camel.Run
  return nil, err
  }
 
- project, err := t.GenerateMavenProject(version)
+ project, err := t.GenerateMavenProject(camelVersion, runtimeVersion)
  if err != nil {
  return nil, err
  }
@@ -185,7 +192,7 @@ func (t *camelTrait) GenerateCatalog(e *Environment, version string) (*camel.Run
 }
 
 // GenerateCatalogMavenProject --
-func (t *camelTrait) GenerateMavenProject(version string) (maven.Project, error) {
+func (t *camelTrait) GenerateMavenProject(camelVersion string, runtimeVersion string) (maven.Project, error) {
  p := maven.NewProjectWithGAV("org.apache.camel.k.integration", "camel-k-catalog-generator", defaults.Version)
  p.Build = &maven.Build{
  DefaultGoal: "generate-resources",
@@ -193,7 +200,7 @@ func (t *camelTrait) GenerateMavenProject(version string) (maven.Project, error)
  {
  GroupID:    "org.apache.camel.k",
  ArtifactID: "camel-k-maven-plugin",
- Version:    defaults.RuntimeVersion,
+ Version:    runtimeVersion,
  Executions: []maven.Execution{
  {
  ID: "generate-catalog",
@@ -206,7 +213,7 @@ func (t *camelTrait) GenerateMavenProject(version string) (maven.Project, error)
  {
  GroupID:    "org.apache.camel",
  ArtifactID: "camel-catalog",
- Version:    version,
+ Version:    camelVersion,
  },
  },
  },
diff --git a/pkg/trait/camel_test.go b/pkg/trait/camel_test.go
index ea2483a..08d5af3 100644
--- a/pkg/trait/camel_test.go
+++ b/pkg/trait/camel_test.go
@@ -72,7 +72,7 @@ func TestApplyCamelTraitWithoutEnvironmentCatalogAndUnmatchableVersionFails(t *t
 func TestCamelTraitGenerateMavenProjectSucceeds(t *testing.T) {
  trait, _ := createNominalCamelTest()
 
- mvnProject, err := trait.GenerateMavenProject("1.23.0")
+ mvnProject, err := trait.GenerateMavenProject("1.23.0", "1.0.0")
  assert.Nil(t, err)
  assert.NotNil(t, mvnProject)
  assert.Equal(t, "org.apache.camel.k.integration", mvnProject.GroupID)
diff --git a/pkg/util/camel/camel.go b/pkg/util/camel/camel.go
deleted file mode 100644
index 65ad6f5..0000000
--- a/pkg/util/camel/camel.go
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License.  You may obtain a copy of the License at
-
-   http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package camel
-
-import (
- "context"
- "fmt"
-
- "github.com/apache/camel-k/pkg/client"
-)
-
-// R --
-var R Runtime
-
-func init() {
- R = NewRuntime()
-}
-
-// Catalog --
-func Catalog(ctx context.Context, client client.Client, namespace string, version string) (*RuntimeCatalog, error) {
- c, err := R.LoadCatalog(ctx, client, namespace, version)
- if c == nil && err != nil {
- return nil, fmt.Errorf("unable to find catalog matching version requirement: %s", version)
- }
-
- return c, err
-}
diff --git a/pkg/util/camel/camel_runtime.go b/pkg/util/camel/camel_runtime.go
index fed3a0a..178b432 100644
--- a/pkg/util/camel/camel_runtime.go
+++ b/pkg/util/camel/camel_runtime.go
@@ -19,7 +19,7 @@ package camel
 
 import (
  "context"
- "sync"
+ "fmt"
 
  "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
  "github.com/apache/camel-k/pkg/client"
@@ -27,28 +27,8 @@ import (
  k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
 )
 
-// NewRuntime --
-func NewRuntime() Runtime {
- return Runtime{
- catalogs: make(map[string]RuntimeCatalog),
- }
-}
-
-// Runtime --
-type Runtime struct {
- catalogs map[string]RuntimeCatalog
- lock     sync.Mutex
-}
-
 // LoadCatalog --
-func (r *Runtime) LoadCatalog(ctx context.Context, client client.Client, namespace string, version string) (*RuntimeCatalog, error) {
- r.lock.Lock()
- defer r.lock.Unlock()
-
- if c, ok := r.catalogs[version]; ok {
- return &c, nil
- }
-
+func LoadCatalog(ctx context.Context, client client.Client, namespace string, camelVersion string, runtimeVersion string) (*RuntimeCatalog, error) {
  var catalog *RuntimeCatalog
  var err error
 
@@ -58,10 +38,14 @@ func (r *Runtime) LoadCatalog(ctx context.Context, client client.Client, namespa
  return nil, err
  }
 
- catalog, err = FindBestMatch(version, list.Items)
+ catalog, err = FindBestMatch(list.Items, camelVersion, runtimeVersion)
  if err != nil {
  return nil, err
  }
 
+ if catalog == nil && err != nil {
+ return nil, fmt.Errorf("unable to find catalog matching version requirement: camel=%s, runtime=%s", camelVersion, runtimeVersion)
+ }
+
  return catalog, nil
 }
diff --git a/pkg/util/camel/camel_types.go b/pkg/util/camel/camel_types.go
new file mode 100644
index 0000000..364d162
--- /dev/null
+++ b/pkg/util/camel/camel_types.go
@@ -0,0 +1,58 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package camel
+
+import (
+ "github.com/Masterminds/semver"
+ "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
+)
+
+// CatalogVersion --
+type CatalogVersion struct {
+ Version        *semver.Version
+ RuntimeVersion *semver.Version
+ Catalog        *v1alpha1.CamelCatalog
+}
+
+// CatalogVersionCollection --
+type CatalogVersionCollection []CatalogVersion
+
+// Len returns the length of a collection. The number of CatalogVersion instances
+// on the slice.
+func (c CatalogVersionCollection) Len() int {
+ return len(c)
+}
+
+// Less is needed for the sort interface to compare two CatalogVersion objects on the
+// slice. If checks if one is less than the other.
+func (c CatalogVersionCollection) Less(i, j int) bool {
+ if c[i].Version.LessThan(c[j].Version) {
+ return true
+ }
+ if c[i].Version.GreaterThan(c[j].Version) {
+ return false
+ }
+
+ return c[i].RuntimeVersion.LessThan(c[j].RuntimeVersion)
+}
+
+// Swap is needed for the sort interface to replace the CatalogVersion objects
+// at two different positions in the slice.
+func (c CatalogVersionCollection) Swap(i, j int) {
+ c[i], c[j] = c[j], c[i]
+}
diff --git a/pkg/util/camel/camel_util.go b/pkg/util/camel/camel_util.go
index a06a5cf..4741222 100644
--- a/pkg/util/camel/camel_util.go
+++ b/pkg/util/camel/camel_util.go
@@ -26,67 +26,73 @@ import (
 )
 
 // FindBestMatch --
-func FindBestMatch(version string, catalogs []v1alpha1.CamelCatalog) (*RuntimeCatalog, error) {
- constraint, err := semver.NewConstraint(version)
-
- //
- // if the version is not a constraint, use exact match
- //
- if err != nil || constraint == nil {
- if err != nil {
- log.Debug("Unable to parse constraint: %s, error:\n", version, err.Error())
- }
- if constraint == nil {
- log.Debug("Unable to parse constraint: %s\n", version)
+func FindBestMatch(catalogs []v1alpha1.CamelCatalog, camelVersion string, runtimeVersion string) (*RuntimeCatalog, error) {
+ for _, catalog := range catalogs {
+ if catalog.Spec.Version == camelVersion && catalog.Spec.RuntimeVersion == runtimeVersion {
+ return NewRuntimeCatalog(catalog.Spec), nil
  }
+ }
 
- return FindExactMatch(version, catalogs)
+ vc := NewSemVerConstraint(camelVersion)
+ rc := NewSemVerConstraint(runtimeVersion)
+ if vc == nil || rc == nil {
+ return nil, nil
  }
 
- return FindBestSemVerMatch(constraint, catalogs)
+ cc := NewCatalogVersionCollection(catalogs)
+ for _, x := range cc {
+ if vc.Check(x.Version) && rc.Check(x.RuntimeVersion) {
+ return NewRuntimeCatalog(x.Catalog.Spec), nil
+ }
+ }
+
+ return nil, nil
 }
 
-// FindExactMatch --
-func FindExactMatch(version string, catalogs []v1alpha1.CamelCatalog) (*RuntimeCatalog, error) {
- for _, catalog := range catalogs {
- if catalog.Spec.Version == version {
- return NewRuntimeCatalog(catalog.Spec), nil
+// NewSemVerConstraint --
+func NewSemVerConstraint(versionConstraint string) *semver.Constraints {
+ constraint, err := semver.NewConstraint(versionConstraint)
+ if err != nil || constraint == nil {
+ if err != nil {
+ log.Debug("Unable to parse version constraint: %s, error:\n", versionConstraint, err.Error())
+ }
+ if constraint == nil {
+ log.Debug("Unable to parse version constraint: %s\n", versionConstraint)
  }
  }
 
- return nil, nil
+ return constraint
 }
 
-// FindBestSemVerMatch --
-func FindBestSemVerMatch(constraint *semver.Constraints, catalogs []v1alpha1.CamelCatalog) (*RuntimeCatalog, error) {
- versions := make([]*semver.Version, 0)
+// NewCatalogVersionCollection --
+func NewCatalogVersionCollection(catalogs []v1alpha1.CamelCatalog) CatalogVersionCollection {
+ versions := make([]CatalogVersion, 0, len(catalogs))
 
- for _, catalog := range catalogs {
- v, err := semver.NewVersion(catalog.Spec.Version)
+ for i := range catalogs {
+ cv, err := semver.NewVersion(catalogs[i].Spec.Version)
+ if err != nil {
+ log.Debugf("Invalid semver version (camel) %s", cv)
+ continue
+ }
+
+ rv, err := semver.NewVersion(catalogs[i].Spec.RuntimeVersion)
  if err != nil {
- log.Debugf("Invalid semver version %s, skip it", catalog.Spec.Version)
+ log.Debugf("Invalid semver version (runtime) %s", rv)
  continue
  }
 
- versions = append(versions, v)
+ versions = append(versions, CatalogVersion{
+ Version:        cv,
+ RuntimeVersion: rv,
+ Catalog:        &catalogs[i],
+ })
  }
 
+ answer := CatalogVersionCollection(versions)
+
  sort.Sort(
- sort.Reverse(semver.Collection(versions)),
+ sort.Reverse(answer),
  )
 
- for _, v := range versions {
- ver := v
-
- if constraint.Check(ver) {
- for _, catalog := range catalogs {
- if catalog.Spec.Version == ver.Original() {
- return NewRuntimeCatalog(catalog.Spec), nil
- }
- }
-
- }
- }
-
- return nil, nil
+ return answer
 }
diff --git a/pkg/util/camel/camel_util_test.go b/pkg/util/camel/camel_util_test.go
index dc82f23..5dff8ab 100644
--- a/pkg/util/camel/camel_util_test.go
+++ b/pkg/util/camel/camel_util_test.go
@@ -25,72 +25,147 @@ import (
  "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
 )
 
+func TestFindBestMatch_Camel(t *testing.T) {
+ catalogs := []v1alpha1.CamelCatalog{
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.0", RuntimeVersion: "1.0.0"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.1", RuntimeVersion: "1.0.0"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.22.1", RuntimeVersion: "1.0.0"}},
+ }
+
+ c, err := FindBestMatch(catalogs, "~2.23.x", "1.0.0")
+ assert.Nil(t, err)
+ assert.NotNil(t, c)
+ assert.Equal(t, "2.23.1", c.Version)
+}
+
+func TestFindBestMatch_Runtime(t *testing.T) {
+ catalogs := []v1alpha1.CamelCatalog{
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.0", RuntimeVersion: "1.0.0"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.0", RuntimeVersion: "1.0.1"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.22.1", RuntimeVersion: "1.0.0"}},
+ }
+
+ c, err := FindBestMatch(catalogs, "2.23.0", "~1.0.x")
+ assert.Nil(t, err)
+ assert.NotNil(t, c)
+ assert.Equal(t, "2.23.0", c.Version)
+ assert.Equal(t, "1.0.1", c.RuntimeVersion)
+}
+
 func TestFindBestMatch(t *testing.T) {
  catalogs := []v1alpha1.CamelCatalog{
- {
- Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.0"},
- },
- {
- Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.1"},
- },
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.0", RuntimeVersion: "1.0.0"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.1", RuntimeVersion: "1.0.0"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.1", RuntimeVersion: "1.0.1"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.22.1", RuntimeVersion: "1.0.0"}},
  }
 
- c, err := FindBestMatch("~2.23.x", catalogs)
+ c, err := FindBestMatch(catalogs, "~2.23.x", "~1.0.x")
  assert.Nil(t, err)
  assert.NotNil(t, c)
  assert.Equal(t, "2.23.1", c.Version)
+ assert.Equal(t, "1.0.1", c.RuntimeVersion)
+}
+
+func TestFindExactSemVerMatch_Camel(t *testing.T) {
+ catalogs := []v1alpha1.CamelCatalog{
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.0", RuntimeVersion: "1.0.0"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.1", RuntimeVersion: "1.0.0"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.22.1", RuntimeVersion: "1.0.0"}},
+ }
+
+ c, err := FindBestMatch(catalogs, "2.23.0", "1.0.0")
+ assert.Nil(t, err)
+ assert.NotNil(t, c)
+ assert.Equal(t, "2.23.0", c.Version)
 }
 
-func TestFindExactSemVerMatch(t *testing.T) {
+func TestFindExactSemVerMatch_Runtime(t *testing.T) {
  catalogs := []v1alpha1.CamelCatalog{
- {
- Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.0"},
- },
- {
- Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.1"},
- },
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.0", RuntimeVersion: "1.0.0"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.1", RuntimeVersion: "1.0.1"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.22.1", RuntimeVersion: "1.0.0"}},
  }
 
- c, err := FindBestMatch("2.23.0", catalogs)
+ c, err := FindBestMatch(catalogs, "2.23.0", "1.0.0")
  assert.Nil(t, err)
  assert.NotNil(t, c)
  assert.Equal(t, "2.23.0", c.Version)
+ assert.Equal(t, "1.0.0", c.RuntimeVersion)
 }
 
-func TestFindExactMatch(t *testing.T) {
+func TestFindExactMatch_Camel(t *testing.T) {
  catalogs := []v1alpha1.CamelCatalog{
- {
- Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.1"},
- },
- {
- Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.1-tag-00001"},
- },
- {
- Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.1-tag-00002"},
- },
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.1", RuntimeVersion: "1.0.0"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.1-tag-00001", RuntimeVersion: "1.0.0"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.1-tag-00002", RuntimeVersion: "1.0.0"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.22.1", RuntimeVersion: "1.0.0"}},
  }
 
- c, err := FindBestMatch("2.23.1-tag-00001", catalogs)
+ c, err := FindBestMatch(catalogs, "2.23.1-tag-00001", "1.0.0")
  assert.Nil(t, err)
  assert.NotNil(t, c)
  assert.Equal(t, "2.23.1-tag-00001", c.Version)
 }
 
+func TestFindExactMatch_Runtime(t *testing.T) {
+ catalogs := []v1alpha1.CamelCatalog{
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.1", RuntimeVersion: "1.0.0"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.1-tag-00001", RuntimeVersion: "1.0.1"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.1-tag-00002", RuntimeVersion: "1.0.0"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.22.1", RuntimeVersion: "1.0.0"}},
+ }
+
+ c, err := FindBestMatch(catalogs, "2.23.1-tag-00001", "1.0.1")
+ assert.Nil(t, err)
+ assert.NotNil(t, c)
+ assert.Equal(t, "2.23.1-tag-00001", c.Version)
+ assert.Equal(t, "1.0.1", c.RuntimeVersion)
+}
+
+func TestFindRangeMatch_Camel(t *testing.T) {
+ catalogs := []v1alpha1.CamelCatalog{
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.0", RuntimeVersion: "1.0.0"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.1", RuntimeVersion: "1.0.0"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.2", RuntimeVersion: "1.0.0"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.22.1", RuntimeVersion: "1.0.0"}},
+ }
+
+ c, err := FindBestMatch(catalogs, ">= 2.23.0, < 2.23.2", "1.0.0")
+ assert.Nil(t, err)
+ assert.NotNil(t, c)
+ assert.Equal(t, "2.23.1", c.Version)
+}
+
+func TestFindRangeMatch_Runtime(t *testing.T) {
+ catalogs := []v1alpha1.CamelCatalog{
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.0", RuntimeVersion: "1.0.0"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.1", RuntimeVersion: "1.0.0"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.2", RuntimeVersion: "1.0.0"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.0", RuntimeVersion: "1.0.2"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.22.1", RuntimeVersion: "1.0.0"}},
+ }
+
+ c, err := FindBestMatch(catalogs, "2.23.0", "> 1.0.1, < 1.0.3")
+ assert.Nil(t, err)
+ assert.NotNil(t, c)
+ assert.Equal(t, "2.23.0", c.Version)
+ assert.Equal(t, "1.0.2", c.RuntimeVersion)
+}
+
 func TestFindRangeMatch(t *testing.T) {
  catalogs := []v1alpha1.CamelCatalog{
- {
- Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.0"},
- },
- {
- Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.1"},
- },
- {
- Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.2"},
- },
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.0", RuntimeVersion: "1.0.0"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.1", RuntimeVersion: "1.0.0"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.2", RuntimeVersion: "1.0.0"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.0", RuntimeVersion: "1.0.2"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.23.1", RuntimeVersion: "1.0.2"}},
+ {Spec: v1alpha1.CamelCatalogSpec{Version: "2.22.1", RuntimeVersion: "1.0.0"}},
  }
 
- c, err := FindBestMatch(">= 2.23.0, < 2.23.2", catalogs)
+ c, err := FindBestMatch(catalogs, ">= 2.23.0, < 2.23.2", "> 1.0.1, < 1.0.3")
  assert.Nil(t, err)
  assert.NotNil(t, c)
  assert.Equal(t, "2.23.1", c.Version)
+ assert.Equal(t, "1.0.2", c.RuntimeVersion)
 }
diff --git a/pkg/util/defaults/defaults.go b/pkg/util/defaults/defaults.go
index cc780cf..a728332 100644
--- a/pkg/util/defaults/defaults.go
+++ b/pkg/util/defaults/defaults.go
@@ -24,11 +24,17 @@ const (
  // Version --
  Version = "1.0.0-M3-SNAPSHOT"
 
+ // DefaultCamelVersion --
+ DefaultCamelVersion = "3.0.0-RC1"
+
  // CamelVersionConstraint --
  CamelVersionConstraint = ">=3.0.0-RC1"
 
- // RuntimeVersion --
- RuntimeVersion = "1.0.4"
+ // DefaultRuntimeVersion --
+ DefaultRuntimeVersion = "1.0.4"
+
+ // RuntimeVersionConstraint --
+ RuntimeVersionConstraint = ">=1.0.4"
 
  // KanikoVersion --
  KanikoVersion = "0.9.0"
diff --git a/pkg/util/test/catalog.go b/pkg/util/test/catalog.go
index 110fe31..b20b9c3 100644
--- a/pkg/util/test/catalog.go
+++ b/pkg/util/test/catalog.go
@@ -43,5 +43,5 @@ func DefaultCatalog() (*camel.RuntimeCatalog, error) {
  }
  }
 
- return camel.FindBestMatch(defaults.CamelVersionConstraint, catalogs)
+ return camel.FindBestMatch(catalogs, defaults.DefaultCamelVersion, defaults.DefaultRuntimeVersion)
 }
diff --git a/pkg/util/test/catalog_test.go b/pkg/util/test/catalog_test.go
index 6cdabc2..a93e1cf 100644
--- a/pkg/util/test/catalog_test.go
+++ b/pkg/util/test/catalog_test.go
@@ -20,6 +20,8 @@ package test
 import (
  "testing"
 
+ "github.com/apache/camel-k/pkg/util/defaults"
+
  "github.com/stretchr/testify/assert"
 )
 
@@ -27,7 +29,7 @@ func TestRuntimeContainsEmbeddedArtifacts(t *testing.T) {
  catalog, err := DefaultCatalog()
  assert.Nil(t, err)
 
- assert.Equal(t, "3.0.0-RC1", catalog.Version)
+ assert.Equal(t, defaults.DefaultCamelVersion, catalog.Version)
 
  artifact := catalog.GetArtifactByScheme("knative")
  assert.Equal(t, 1, len(artifact.Schemes))
diff --git a/script/Makefile b/script/Makefile
index 14cd358..55c53d9 100644
--- a/script/Makefile
+++ b/script/Makefile
@@ -17,6 +17,7 @@ VERSIONFILE := pkg/util/defaults/defaults.go
 VERSION := 1.0.0-M3-SNAPSHOT
 LAST_RELEASED_VERSION := 1.0.0-M1
 RUNTIME_VERSION := 1.0.4
+RUNTIME_VERSION_CONSTRAINT := >=1.0.4
 CAMEL_VERSION := 3.0.0-RC1
 CAMEL_VERSION_CONSTRAINT := >=3.0.0-RC1
 KANIKO_VERSION := 0.9.0
@@ -76,11 +77,17 @@ codegen:
  @echo "  // Version -- " >> $(VERSIONFILE)
  @echo "  Version = \"$(VERSION)\"" >> $(VERSIONFILE)
  @echo "" >> $(VERSIONFILE)
+ @echo "  // DefaultCamelVersion -- " >> $(VERSIONFILE)
+ @echo "  DefaultCamelVersion = \"$(CAMEL_VERSION)\"" >> $(VERSIONFILE)
+ @echo "" >> $(VERSIONFILE)
  @echo "  // CamelVersionConstraint -- " >> $(VERSIONFILE)
  @echo "  CamelVersionConstraint = \"$(CAMEL_VERSION_CONSTRAINT)\"" >> $(VERSIONFILE)
  @echo "" >> $(VERSIONFILE)
- @echo "  // RuntimeVersion -- " >> $(VERSIONFILE)
- @echo "  RuntimeVersion = \"$(RUNTIME_VERSION)\"" >> $(VERSIONFILE)
+ @echo "  // DefaultRuntimeVersion -- " >> $(VERSIONFILE)
+ @echo "  DefaultRuntimeVersion = \"$(RUNTIME_VERSION)\"" >> $(VERSIONFILE)
+ @echo "" >> $(VERSIONFILE)
+ @echo "  // RuntimeVersionConstraint -- " >> $(VERSIONFILE)
+ @echo "  RuntimeVersionConstraint = \"$(RUNTIME_VERSION_CONSTRAINT)\"" >> $(VERSIONFILE)
  @echo "" >> $(VERSIONFILE)
  @echo "  // KanikoVersion -- " >> $(VERSIONFILE)
  @echo "  KanikoVersion = \"$(KANIKO_VERSION)\"" >> $(VERSIONFILE)
diff --git a/script/build_catalog.sh b/script/build_catalog.sh
index 2227888..50d580b 100755
--- a/script/build_catalog.sh
+++ b/script/build_catalog.sh
@@ -26,6 +26,5 @@ fi
 $rootdir/mvnw -q \
     -f ${rootdir}/build/maven/pom-catalog.xml \
     -Dcatalog.path=${rootdir}/deploy \
-    -Dcatalog.version=$1 \
     -Dcamel.version=$1 \
     -Druntime.version=$2
\ No newline at end of file

Reply | Threaded
Open this post in threaded view
|

[camel-k] 02/03: chore: upgrade and tune lint, fix findings

lburgazzoli-2
In reply to this post by lburgazzoli-2
This is an automated email from the ASF dual-hosted git repository.

lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 8a577b360f5f6eaadd437dea76f16d12c5a3d01f
Author: lburgazzoli <[hidden email]>
AuthorDate: Tue Oct 8 19:23:24 2019 +0200

    chore: upgrade and tune lint, fix findings
---
 .golangci.yml                                      |  5 ++
 .travis.yml                                        |  2 +-
 .../v1alpha1/integrationplatform_types_support.go  |  1 -
 pkg/builder/builder_steps_test.go                  | 55 +++++-----------------
 pkg/cmd/describe_kit.go                            |  1 -
 pkg/cmd/kit_get.go                                 |  1 -
 pkg/controller/integrationplatform/initialize.go   |  1 -
 .../integrationplatform_controller.go              |  1 -
 pkg/controller/integrationplatform/warm.go         |  3 --
 pkg/install/operator.go                            |  1 -
 pkg/trait/gc_test.go                               |  4 --
 pkg/trait/ingress_test.go                          | 11 -----
 pkg/trait/trait_types.go                           |  1 -
 pkg/util/envvar/envvar.go                          |  1 -
 pkg/util/kubernetes/log/annotation_scraper.go      |  1 -
 pkg/util/kubernetes/log/pod_scraper.go             |  2 -
 pkg/util/openshift/register.go                     |  1 -
 pkg/util/test/client.go                            |  1 -
 18 files changed, 17 insertions(+), 76 deletions(-)

diff --git a/.golangci.yml b/.golangci.yml
index a67fb8d..3cfed89 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -7,3 +7,8 @@ linters:
     - dupl
     - gochecknoinits
     - gochecknoglobals
+    - funlen
+    - godox
+    - whitespace
+    - gocognit
+    - wsl
diff --git a/.travis.yml b/.travis.yml
index d59ff53..492f211 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -40,7 +40,7 @@ services:
   - docker
 
 before_script:
-  - curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b . v1.17.1
+  - curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b . v1.20.0
   - ./golangci-lint config path
   - ./golangci-lint --version
 
diff --git a/pkg/apis/camel/v1alpha1/integrationplatform_types_support.go b/pkg/apis/camel/v1alpha1/integrationplatform_types_support.go
index e752347..5dda22e 100644
--- a/pkg/apis/camel/v1alpha1/integrationplatform_types_support.go
+++ b/pkg/apis/camel/v1alpha1/integrationplatform_types_support.go
@@ -91,7 +91,6 @@ func (in *IntegrationPlatformStatus) GetCondition(condType IntegrationPlatformCo
  if c.Type == condType {
  return &c
  }
-
  }
  return nil
 }
diff --git a/pkg/builder/builder_steps_test.go b/pkg/builder/builder_steps_test.go
index e7da61a..d21564d 100644
--- a/pkg/builder/builder_steps_test.go
+++ b/pkg/builder/builder_steps_test.go
@@ -99,22 +99,10 @@ func TestGenerateJvmProject(t *testing.T) {
  t,
  ctx.Maven.Project.Dependencies,
  []maven.Dependency{
- {
- GroupID:    "org.apache.camel.k",
- ArtifactID: "camel-k-runtime-main",
- },
- {
- GroupID:    "org.apache.camel",
- ArtifactID: "camel-core-engine",
- },
- {
- GroupID:    "org.apache.camel",
- ArtifactID: "camel-main",
- },
- {
- GroupID:    "org.apache.camel",
- ArtifactID: "camel-properties",
- },
+ {GroupID: "org.apache.camel.k", ArtifactID: "camel-k-runtime-main"},
+ {GroupID: "org.apache.camel", ArtifactID: "camel-core-engine"},
+ {GroupID: "org.apache.camel", ArtifactID: "camel-main"},
+ {GroupID: "org.apache.camel", ArtifactID: "camel-properties"},
  },
  )
 }
@@ -273,34 +261,13 @@ func TestGenerateGroovyProject(t *testing.T) {
  t,
  ctx.Maven.Project.Dependencies,
  []maven.Dependency{
- {
- GroupID:    "org.apache.camel.k",
- ArtifactID: "camel-k-runtime-main",
- },
- {
- GroupID:    "org.apache.camel.k",
- ArtifactID: "camel-k-loader-groovy",
- },
- {
- GroupID:    "org.apache.camel",
- ArtifactID: "camel-core-engine",
- },
- {
- GroupID:    "org.apache.camel",
- ArtifactID: "camel-main",
- },
- {
- GroupID:    "org.apache.camel",
- ArtifactID: "camel-groovy",
- },
- {
- GroupID:    "org.apache.camel",
- ArtifactID: "camel-properties",
- },
- {
- GroupID:    "org.apache.camel",
- ArtifactID: "camel-endpointdsl",
- },
+ {GroupID: "org.apache.camel.k", ArtifactID: "camel-k-runtime-main"},
+ {GroupID: "org.apache.camel.k", ArtifactID: "camel-k-loader-groovy"},
+ {GroupID: "org.apache.camel", ArtifactID: "camel-core-engine"},
+ {GroupID: "org.apache.camel", ArtifactID: "camel-main"},
+ {GroupID: "org.apache.camel", ArtifactID: "camel-groovy"},
+ {GroupID: "org.apache.camel", ArtifactID: "camel-properties"},
+ {GroupID: "org.apache.camel", ArtifactID: "camel-endpointdsl"},
  },
  )
 }
diff --git a/pkg/cmd/describe_kit.go b/pkg/cmd/describe_kit.go
index d2afd7f..c182650 100644
--- a/pkg/cmd/describe_kit.go
+++ b/pkg/cmd/describe_kit.go
@@ -29,7 +29,6 @@ import (
 )
 
 func newDescribeKitCmd(rootCmdOptions *RootCmdOptions) *cobra.Command {
-
  impl := &describeKitCommand{
  rootCmdOptions,
  }
diff --git a/pkg/cmd/kit_get.go b/pkg/cmd/kit_get.go
index 2cc5691..187cde2 100644
--- a/pkg/cmd/kit_get.go
+++ b/pkg/cmd/kit_get.go
@@ -65,7 +65,6 @@ type kitGetCommand struct {
 
 func (command *kitGetCommand) validate(cmd *cobra.Command, args []string) error {
  return nil
-
 }
 
 func (command *kitGetCommand) run() error {
diff --git a/pkg/controller/integrationplatform/initialize.go b/pkg/controller/integrationplatform/initialize.go
index a2e4178..2e54ae0 100644
--- a/pkg/controller/integrationplatform/initialize.go
+++ b/pkg/controller/integrationplatform/initialize.go
@@ -149,7 +149,6 @@ func (action *initializeAction) Handle(ctx context.Context, platform *v1alpha1.I
  // Skip the warmer pod creation
  platform.Status.Phase = v1alpha1.IntegrationPlatformPhaseCreating
  }
-
  } else {
  platform.Status.Phase = v1alpha1.IntegrationPlatformPhaseCreating
  }
diff --git a/pkg/controller/integrationplatform/integrationplatform_controller.go b/pkg/controller/integrationplatform/integrationplatform_controller.go
index 21acde2..15a52f0 100644
--- a/pkg/controller/integrationplatform/integrationplatform_controller.go
+++ b/pkg/controller/integrationplatform/integrationplatform_controller.go
@@ -189,5 +189,4 @@ func (r *ReconcileIntegrationPlatform) Reconcile(request reconcile.Request) (rec
  return reconcile.Result{
  RequeueAfter: 5 * time.Second,
  }, nil
-
 }
diff --git a/pkg/controller/integrationplatform/warm.go b/pkg/controller/integrationplatform/warm.go
index dceadb2..cc3d0ef 100644
--- a/pkg/controller/integrationplatform/warm.go
+++ b/pkg/controller/integrationplatform/warm.go
@@ -64,15 +64,12 @@ func (action *warmAction) Handle(ctx context.Context, platform *v1alpha1.Integra
  }
 
  switch pod.Status.Phase {
-
  case corev1.PodSucceeded:
  action.L.Info("Kaniko cache successfully warmed up")
  platform.Status.Phase = v1alpha1.IntegrationPlatformPhaseCreating
  return platform, nil
-
  case corev1.PodFailed:
  return nil, errors.New("failed to warm up Kaniko cache")
-
  default:
  action.L.Info("Waiting for Kaniko cache to warm up...")
  // Requeue
diff --git a/pkg/install/operator.go b/pkg/install/operator.go
index 9acf70d..e5cfc64 100644
--- a/pkg/install/operator.go
+++ b/pkg/install/operator.go
@@ -171,7 +171,6 @@ func PlatformOrCollect(ctx context.Context, c client.Client, namespace string, r
  pl := platformObject.(*v1alpha1.IntegrationPlatform)
 
  if !isOpenshift {
-
  pl.Spec.Build.Registry = registry
 
  // Kubernetes only (Minikube)
diff --git a/pkg/trait/gc_test.go b/pkg/trait/gc_test.go
index 744db84..88086ab 100644
--- a/pkg/trait/gc_test.go
+++ b/pkg/trait/gc_test.go
@@ -28,9 +28,7 @@ import (
 )
 
 func TestConfigureGarbageCollectorTraitDoesSucceed(t *testing.T) {
-
  gcTrait, environment := createNominalGarbageCollectorTest()
-
  configured, err := gcTrait.Configure(environment)
 
  assert.True(t, configured)
@@ -38,7 +36,6 @@ func TestConfigureGarbageCollectorTraitDoesSucceed(t *testing.T) {
 }
 
 func TestConfigureDisabledGarbageCollectorTraitDoesNotSucceed(t *testing.T) {
-
  gcTrait, environment := createNominalGarbageCollectorTest()
  gcTrait.Enabled = new(bool)
 
@@ -70,7 +67,6 @@ func TestApplyGarbageCollectorTraitDuringInitializationPhaseSkipPostActions(t *t
 }
 
 func createNominalGarbageCollectorTest() (*garbageCollectorTrait, *Environment) {
-
  trait := newGarbageCollectorTrait()
  enabled := true
  trait.Enabled = &enabled
diff --git a/pkg/trait/ingress_test.go b/pkg/trait/ingress_test.go
index 339686e..30b018f 100644
--- a/pkg/trait/ingress_test.go
+++ b/pkg/trait/ingress_test.go
@@ -33,9 +33,7 @@ import (
 )
 
 func TestConfigureIngressTraitDoesSucceed(t *testing.T) {
-
  ingressTrait, environment := createNominalIngressTest()
-
  configured, err := ingressTrait.Configure(environment)
 
  assert.True(t, configured)
@@ -44,7 +42,6 @@ func TestConfigureIngressTraitDoesSucceed(t *testing.T) {
 }
 
 func TestConfigureDisabledIngressTraitDoesNotSucceed(t *testing.T) {
-
  ingressTrait, environment := createNominalIngressTest()
  ingressTrait.Enabled = new(bool)
 
@@ -58,7 +55,6 @@ func TestConfigureDisabledIngressTraitDoesNotSucceed(t *testing.T) {
 }
 
 func TestConfigureIngressTraitInWrongPhaseDoesNotSucceed(t *testing.T) {
-
  ingressTrait, environment := createNominalIngressTest()
  environment.Integration.Status.Phase = v1alpha1.IntegrationPhaseError
 
@@ -70,7 +66,6 @@ func TestConfigureIngressTraitInWrongPhaseDoesNotSucceed(t *testing.T) {
 }
 
 func TestConfigureAutoIngressTraitWithoutUserServiceDoesNotSucceed(t *testing.T) {
-
  ingressTrait, environment := createNominalIngressTest()
  auto := true
  ingressTrait.Auto = &auto
@@ -86,7 +81,6 @@ func TestConfigureAutoIngressTraitWithoutUserServiceDoesNotSucceed(t *testing.T)
 }
 
 func TestConfigureAutoIngressTraitWithEmptyHostDoesNotSucceed(t *testing.T) {
-
  ingressTrait, environment := createNominalIngressTest()
  ingressTrait.Auto = nil
  ingressTrait.Host = ""
@@ -101,7 +95,6 @@ func TestConfigureAutoIngressTraitWithEmptyHostDoesNotSucceed(t *testing.T) {
 }
 
 func TestConfigureAutoIngressTraitWithUserServiceDoesSucceed(t *testing.T) {
-
  ingressTrait, environment := createNominalIngressTest()
  ingressTrait.Auto = nil
 
@@ -113,7 +106,6 @@ func TestConfigureAutoIngressTraitWithUserServiceDoesSucceed(t *testing.T) {
 }
 
 func TestConfigureIngressTraitWithoutHostDoesNotSucceed(t *testing.T) {
-
  ingressTrait, environment := createNominalIngressTest()
  ingressTrait.Host = ""
 
@@ -128,7 +120,6 @@ func TestConfigureIngressTraitWithoutHostDoesNotSucceed(t *testing.T) {
 }
 
 func TestApplyIngressTraitWithoutUserServiceDoesNotSucceed(t *testing.T) {
-
  ingressTrait, environment := createNominalIngressTest()
  environment.Resources = kubernetes.NewCollection()
 
@@ -140,7 +131,6 @@ func TestApplyIngressTraitWithoutUserServiceDoesNotSucceed(t *testing.T) {
 }
 
 func TestApplyIngressTraitDoesSucceed(t *testing.T) {
-
  ingressTrait, environment := createNominalIngressTest()
 
  err := ingressTrait.Apply(environment)
@@ -165,7 +155,6 @@ func TestApplyIngressTraitDoesSucceed(t *testing.T) {
 }
 
 func createNominalIngressTest() (*ingressTrait, *Environment) {
-
  trait := newIngressTrait()
  enabled := true
  trait.Enabled = &enabled
diff --git a/pkg/trait/trait_types.go b/pkg/trait/trait_types.go
index 3399057..fabf049 100644
--- a/pkg/trait/trait_types.go
+++ b/pkg/trait/trait_types.go
@@ -410,7 +410,6 @@ func (e *Environment) ComputeSourcesURI() []string {
 
 // ConfigureVolumesAndMounts --
 func (e *Environment) ConfigureVolumesAndMounts(vols *[]corev1.Volume, mnts *[]corev1.VolumeMount) {
-
  //
  // Volumes :: Sources
  //
diff --git a/pkg/util/envvar/envvar.go b/pkg/util/envvar/envvar.go
index 2c87ca1..806c818 100644
--- a/pkg/util/envvar/envvar.go
+++ b/pkg/util/envvar/envvar.go
@@ -69,7 +69,6 @@ func SetVar(vars *[]corev1.EnvVar, newEnvVar corev1.EnvVar) {
  from := *newEnvVar.ValueFrom
  envVar.ValueFrom = &from
  }
-
  } else {
  *vars = append(*vars, newEnvVar)
  }
diff --git a/pkg/util/kubernetes/log/annotation_scraper.go b/pkg/util/kubernetes/log/annotation_scraper.go
index 11c8e20..adc5f1a 100644
--- a/pkg/util/kubernetes/log/annotation_scraper.go
+++ b/pkg/util/kubernetes/log/annotation_scraper.go
@@ -159,7 +159,6 @@ func (s *SelectorScraper) addPodScraper(ctx context.Context, podName string, out
  }
  }
  }()
-
 }
 
 func (s *SelectorScraper) listPods() (*corev1.PodList, error) {
diff --git a/pkg/util/kubernetes/log/pod_scraper.go b/pkg/util/kubernetes/log/pod_scraper.go
index 162e26c..1d1a583 100644
--- a/pkg/util/kubernetes/log/pod_scraper.go
+++ b/pkg/util/kubernetes/log/pod_scraper.go
@@ -178,7 +178,6 @@ func (s *PodScraper) waitForPodRunning(ctx context.Context, namespace string, po
  if err := json.Unmarshal(jsondata, recvPod); err != nil {
  return "", err
  }
-
  } else if gotPod, ok := e.Object.(*corev1.Pod); ok {
  recvPod = gotPod
  }
@@ -193,7 +192,6 @@ func (s *PodScraper) waitForPodRunning(ctx context.Context, namespace string, po
  return "", errors.New("no state change after 30 seconds for pod " + s.podName)
  }
  }
-
 }
 
 func (s *PodScraper) chooseContainer(p *corev1.Pod, defaultContainerName string) string {
diff --git a/pkg/util/openshift/register.go b/pkg/util/openshift/register.go
index b347a5c..0dd244d 100644
--- a/pkg/util/openshift/register.go
+++ b/pkg/util/openshift/register.go
@@ -33,7 +33,6 @@ type registerFunction func(*runtime.Scheme) error
 
 // AddToScheme adds OpenShift types to the scheme
 func AddToScheme(scheme *runtime.Scheme) error {
-
  var err error
 
  // Standardized groups
diff --git a/pkg/util/test/client.go b/pkg/util/test/client.go
index a758844..97b7c13 100644
--- a/pkg/util/test/client.go
+++ b/pkg/util/test/client.go
@@ -45,7 +45,6 @@ func NewFakeClient(initObjs ...runtime.Object) (client.Client, error) {
  Client:    c,
  Interface: nil,
  }, nil
-
 }
 
 // FakeClient ---

Reply | Threaded
Open this post in threaded view
|

[camel-k] 03/03: chore: remove go version from go.mod

lburgazzoli-2
In reply to this post by lburgazzoli-2
This is an automated email from the ASF dual-hosted git repository.

lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 6cb3dd525589d3b2b5af10bca9f11abd5b8017f7
Author: lburgazzoli <[hidden email]>
AuthorDate: Wed Oct 9 10:45:10 2019 +0200

    chore: remove go version from go.mod
---
 go.mod | 2 --
 1 file changed, 2 deletions(-)

diff --git a/go.mod b/go.mod
index 583473d..bedbd73 100644
--- a/go.mod
+++ b/go.mod
@@ -51,5 +51,3 @@ replace (
 )
 
 replace git.apache.org/thrift.git => github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999
-
-go 1.13