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


The following commit(s) were added to refs/heads/master by this push:
     new 4c99ef8  camel-k --runtime-version is not honoured for all runtimes 
#538
4c99ef8 is described below

commit 4c99ef854245cbd7457f3ffb4d4f5b291ee2e0f4
Author: lburgazzoli <lburgazz...@gmail.com>
AuthorDate: Sun Mar 10 20:00:09 2019 +0100

    camel-k --runtime-version is not honoured for all runtimes #538
---
 pkg/builder/builder_steps.go                     | 17 -----
 pkg/builder/builder_steps_test.go                | 61 ++++++++++++++++
 pkg/builder/builder_utils.go                     | 21 ++++++
 pkg/builder/springboot/generator.go              | 15 ----
 pkg/builder/springboot/generator_test.go         | 90 ++++++++++++++++++++++++
 pkg/controller/integrationplatform/initialize.go |  2 +-
 6 files changed, 173 insertions(+), 33 deletions(-)

diff --git a/pkg/builder/builder_steps.go b/pkg/builder/builder_steps.go
index 6fcd317..f12470d 100644
--- a/pkg/builder/builder_steps.go
+++ b/pkg/builder/builder_steps.go
@@ -48,23 +48,6 @@ func GenerateProject(ctx *Context) error {
        ctx.Project = p
 
        //
-       // Repositories
-       //
-
-       ctx.Project.Repositories = make([]maven.Repository, 0, 
len(ctx.Request.Repositories))
-       ctx.Project.PluginRepositories = make([]maven.Repository, 0, 
len(ctx.Request.Repositories))
-
-       for i, r := range ctx.Request.Repositories {
-               repo := maven.NewRepository(r)
-               if repo.ID == "" {
-                       repo.ID = fmt.Sprintf("repo-%03d", i)
-               }
-
-               ctx.Project.Repositories = append(ctx.Project.Repositories, 
repo)
-               ctx.Project.PluginRepositories = 
append(ctx.Project.PluginRepositories, repo)
-       }
-
-       //
        // set-up dependencies
        //
 
diff --git a/pkg/builder/builder_steps_test.go 
b/pkg/builder/builder_steps_test.go
index 19dcd65..f85a80e 100644
--- a/pkg/builder/builder_steps_test.go
+++ b/pkg/builder/builder_steps_test.go
@@ -28,6 +28,67 @@ import (
        "github.com/stretchr/testify/assert"
 )
 
+func TestMavenRepositories(t *testing.T) {
+       catalog, err := test.DefaultCatalog()
+       assert.Nil(t, err)
+
+       ctx := Context{
+               Catalog: catalog,
+               Request: Request{
+                       Catalog:        catalog,
+                       RuntimeVersion: defaults.RuntimeVersion,
+                       Platform: v1alpha1.IntegrationPlatformSpec{
+                               Build: v1alpha1.IntegrationPlatformBuildSpec{
+                                       CamelVersion: catalog.Version,
+                               },
+                       },
+                       Dependencies: []string{
+                               "runtime:jvm",
+                       },
+                       Repositories: []string{
+                               
"https://repository.apache.org/content/repositories/snapshots@id=apache.snapshots@snapshots@noreleases";,
+                               
"https://oss.sonatype.org/content/repositories/snapshots/@id=sonatype.snapshots@snapshots";,
+                       },
+               },
+       }
+
+       err = GenerateProject(&ctx)
+       assert.Nil(t, err)
+       err = InjectDependencies(&ctx)
+       assert.Nil(t, err)
+
+       assert.Equal(t, 2, len(ctx.Project.Repositories))
+       assert.Equal(t, 2, len(ctx.Project.PluginRepositories))
+
+       assert.Contains(t, ctx.Project.Repositories, maven.Repository{
+               ID:        "apache.snapshots",
+               URL:       
"https://repository.apache.org/content/repositories/snapshots";,
+               Snapshots: maven.RepositoryPolicy{Enabled: true},
+               Releases:  maven.RepositoryPolicy{Enabled: false},
+       })
+
+       assert.Contains(t, ctx.Project.Repositories, maven.Repository{
+               ID:        "sonatype.snapshots",
+               URL:       
"https://oss.sonatype.org/content/repositories/snapshots/";,
+               Snapshots: maven.RepositoryPolicy{Enabled: true},
+               Releases:  maven.RepositoryPolicy{Enabled: true},
+       })
+
+       assert.Contains(t, ctx.Project.PluginRepositories, maven.Repository{
+               ID:        "apache.snapshots",
+               URL:       
"https://repository.apache.org/content/repositories/snapshots";,
+               Snapshots: maven.RepositoryPolicy{Enabled: true},
+               Releases:  maven.RepositoryPolicy{Enabled: false},
+       })
+
+       assert.Contains(t, ctx.Project.PluginRepositories, maven.Repository{
+               ID:        "sonatype.snapshots",
+               URL:       
"https://oss.sonatype.org/content/repositories/snapshots/";,
+               Snapshots: maven.RepositoryPolicy{Enabled: true},
+               Releases:  maven.RepositoryPolicy{Enabled: true},
+       })
+}
+
 func TestGenerateJvmProject(t *testing.T) {
        catalog, err := test.DefaultCatalog()
        assert.Nil(t, err)
diff --git a/pkg/builder/builder_utils.go b/pkg/builder/builder_utils.go
index 45d5b25..3256b65 100644
--- a/pkg/builder/builder_utils.go
+++ b/pkg/builder/builder_utils.go
@@ -19,6 +19,7 @@ package builder
 
 import (
        "encoding/xml"
+       "fmt"
 
        "github.com/apache/camel-k/pkg/util/defaults"
 
@@ -40,6 +41,9 @@ func ArtifactIDs(artifacts []v1alpha1.Artifact) []string {
 
 // NewProject --
 func NewProject(ctx *Context) (maven.Project, error) {
+       //
+       // Catalog
+       //
        if ctx.Catalog == nil {
                c, err := camel.Catalog(ctx.Request.C, ctx.Client, 
ctx.Namespace, ctx.Request.Platform.Build.CamelVersion)
                if err != nil {
@@ -73,5 +77,22 @@ func NewProject(ctx *Context) (maven.Project, error) {
                Dependencies: make([]maven.Dependency, 0),
        }
 
+       //
+       // Repositories
+       //
+
+       p.Repositories = make([]maven.Repository, 0, 
len(ctx.Request.Repositories))
+       p.PluginRepositories = make([]maven.Repository, 0, 
len(ctx.Request.Repositories))
+
+       for i, r := range ctx.Request.Repositories {
+               repo := maven.NewRepository(r)
+               if repo.ID == "" {
+                       repo.ID = fmt.Sprintf("repo-%03d", i)
+               }
+
+               p.Repositories = append(p.Repositories, repo)
+               p.PluginRepositories = append(p.PluginRepositories, repo)
+       }
+
        return p, nil
 }
diff --git a/pkg/builder/springboot/generator.go 
b/pkg/builder/springboot/generator.go
index 1062b9e..7b9f9f4 100644
--- a/pkg/builder/springboot/generator.go
+++ b/pkg/builder/springboot/generator.go
@@ -35,21 +35,6 @@ func GenerateProject(ctx *builder.Context) error {
        ctx.Project = p
 
        //
-       // Repositories
-       //
-
-       ctx.Project.Repositories = make([]maven.Repository, 0, 
len(ctx.Request.Repositories))
-
-       for i, r := range ctx.Request.Repositories {
-               repo := maven.NewRepository(r)
-               if repo.ID == "" {
-                       repo.ID = fmt.Sprintf("repo-%03d", i)
-               }
-
-               ctx.Project.Repositories = append(ctx.Project.Repositories, 
repo)
-       }
-
-       //
        // set-up dependencies
        //
 
diff --git a/pkg/builder/springboot/generator_test.go 
b/pkg/builder/springboot/generator_test.go
new file mode 100644
index 0000000..3c0e1a5
--- /dev/null
+++ b/pkg/builder/springboot/generator_test.go
@@ -0,0 +1,90 @@
+/*
+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 springboot
+
+import (
+       "testing"
+
+       "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
+       "github.com/apache/camel-k/pkg/builder"
+       "github.com/apache/camel-k/pkg/util/defaults"
+       "github.com/apache/camel-k/pkg/util/maven"
+       "github.com/apache/camel-k/pkg/util/test"
+       "github.com/stretchr/testify/assert"
+)
+
+func TestMavenRepositories(t *testing.T) {
+       catalog, err := test.DefaultCatalog()
+       assert.Nil(t, err)
+
+       ctx := builder.Context{
+               Catalog: catalog,
+               Request: builder.Request{
+                       Catalog:        catalog,
+                       RuntimeVersion: defaults.RuntimeVersion,
+                       Platform: v1alpha1.IntegrationPlatformSpec{
+                               Build: v1alpha1.IntegrationPlatformBuildSpec{
+                                       CamelVersion: catalog.Version,
+                               },
+                       },
+                       Dependencies: []string{
+                               "runtime:jvm",
+                       },
+                       Repositories: []string{
+                               
"https://repository.apache.org/content/repositories/snapshots@id=apache.snapshots@snapshots@noreleases";,
+                               
"https://oss.sonatype.org/content/repositories/snapshots/@id=sonatype.snapshots@snapshots";,
+                       },
+               },
+       }
+
+       err = GenerateProject(&ctx)
+       assert.Nil(t, err)
+       err = builder.InjectDependencies(&ctx)
+       assert.Nil(t, err)
+
+       assert.Equal(t, 2, len(ctx.Project.Repositories))
+       assert.Equal(t, 2, len(ctx.Project.PluginRepositories))
+
+       assert.Contains(t, ctx.Project.Repositories, maven.Repository{
+               ID:        "apache.snapshots",
+               URL:       
"https://repository.apache.org/content/repositories/snapshots";,
+               Snapshots: maven.RepositoryPolicy{Enabled: true},
+               Releases:  maven.RepositoryPolicy{Enabled: false},
+       })
+
+       assert.Contains(t, ctx.Project.Repositories, maven.Repository{
+               ID:        "sonatype.snapshots",
+               URL:       
"https://oss.sonatype.org/content/repositories/snapshots/";,
+               Snapshots: maven.RepositoryPolicy{Enabled: true},
+               Releases:  maven.RepositoryPolicy{Enabled: true},
+       })
+
+       assert.Contains(t, ctx.Project.PluginRepositories, maven.Repository{
+               ID:        "apache.snapshots",
+               URL:       
"https://repository.apache.org/content/repositories/snapshots";,
+               Snapshots: maven.RepositoryPolicy{Enabled: true},
+               Releases:  maven.RepositoryPolicy{Enabled: false},
+       })
+
+       assert.Contains(t, ctx.Project.PluginRepositories, maven.Repository{
+               ID:        "sonatype.snapshots",
+               URL:       
"https://oss.sonatype.org/content/repositories/snapshots/";,
+               Snapshots: maven.RepositoryPolicy{Enabled: true},
+               Releases:  maven.RepositoryPolicy{Enabled: true},
+       })
+}
diff --git a/pkg/controller/integrationplatform/initialize.go 
b/pkg/controller/integrationplatform/initialize.go
index 7182575..fe84775 100644
--- a/pkg/controller/integrationplatform/initialize.go
+++ b/pkg/controller/integrationplatform/initialize.go
@@ -115,7 +115,7 @@ func (action *initializeAction) Handle(ctx context.Context, 
ip *v1alpha1.Integra
                        action.L.Info("Repositories:")
                }
 
-               action.L.Infof("    %d - %s", i, r)
+               action.L.Infof("%d - %s", i, r)
        }
 
        err = action.client.Update(ctx, target)

Reply via email to