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

camel-k --runtime-version is not honoured for all runtimes #539

Merged
merged 1 commit into from
Mar 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 0 additions & 17 deletions pkg/builder/builder_steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,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
//
Expand Down
61 changes: 61 additions & 0 deletions pkg/builder/builder_steps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 21 additions & 0 deletions pkg/builder/builder_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package builder

import (
"encoding/xml"
"fmt"

"github.com/apache/camel-k/pkg/util/defaults"

Expand All @@ -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 {
Expand Down Expand Up @@ -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
}
15 changes: 0 additions & 15 deletions pkg/builder/springboot/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,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
//
Expand Down
90 changes: 90 additions & 0 deletions pkg/builder/springboot/generator_test.go
Original file line number Diff line number Diff line change
@@ -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},
})
}
2 changes: 1 addition & 1 deletion pkg/controller/integrationplatform/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down