This is an automated email from the ASF dual-hosted git repository. astefanutti pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 57f134e35bdeed74eeeb4612f1ae810631803878 Author: Antonin Stefanutti <[email protected]> AuthorDate: Mon Oct 21 17:07:46 2019 +0200 chore(catalog): Move DefaultCatalog method into camel package --- pkg/builder/builder_steps_test.go | 11 ++++---- pkg/builder/builder_test.go | 7 ++--- pkg/builder/runtime/main_test.go | 10 +++---- pkg/cmd/completion_bash.go | 4 +-- pkg/metadata/metadata_dependencies_test.go | 42 +++++++++++++++--------------- pkg/metadata/metadata_http_test.go | 24 ++++++++--------- pkg/metadata/metadata_uri_test.go | 20 +++++++------- pkg/trait/builder_test.go | 11 ++++---- pkg/trait/container_test.go | 13 +++++---- pkg/trait/debug_test.go | 10 +++---- pkg/trait/dependencies_test.go | 13 ++++----- pkg/trait/environment_test.go | 15 +++++------ pkg/trait/istio_test.go | 11 ++++---- pkg/trait/knative_service_test.go | 16 ++++++------ pkg/trait/knative_test.go | 20 +++++++------- pkg/trait/route_test.go | 13 +++++---- pkg/trait/service_test.go | 15 +++++------ pkg/trait/trait_test.go | 12 ++++----- pkg/util/camel/camel_runtime.go | 2 +- pkg/util/camel/camel_util.go | 16 +++++------- pkg/util/camel/camel_util_test.go | 20 +++++++------- pkg/util/{test => camel}/catalog.go | 11 ++++---- pkg/util/test/catalog_test.go | 7 ++--- 23 files changed, 160 insertions(+), 163 deletions(-) diff --git a/pkg/builder/builder_steps_test.go b/pkg/builder/builder_steps_test.go index c950477..1985dee 100644 --- a/pkg/builder/builder_steps_test.go +++ b/pkg/builder/builder_steps_test.go @@ -20,14 +20,15 @@ package builder import ( "testing" + "github.com/stretchr/testify/assert" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" + "github.com/apache/camel-k/pkg/util/camel" "github.com/apache/camel-k/pkg/util/cancellable" "github.com/apache/camel-k/pkg/util/test" - - "github.com/stretchr/testify/assert" ) type testSteps struct { @@ -50,7 +51,7 @@ func TestRegisterDuplicatedSteps(t *testing.T) { } func TestMavenSettingsFromConfigMap(t *testing.T) { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) c, err := test.NewFakeClient( @@ -102,7 +103,7 @@ func TestMavenSettingsFromConfigMap(t *testing.T) { } func TestMavenSettingsFromSecret(t *testing.T) { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) c, err := test.NewFakeClient( @@ -154,7 +155,7 @@ func TestMavenSettingsFromSecret(t *testing.T) { } func TestListPublishedImages(t *testing.T) { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) c, err := test.NewFakeClient( diff --git a/pkg/builder/builder_test.go b/pkg/builder/builder_test.go index ca899ae..3ef98aa 100644 --- a/pkg/builder/builder_test.go +++ b/pkg/builder/builder_test.go @@ -21,10 +21,11 @@ import ( "errors" "testing" + "github.com/stretchr/testify/assert" + "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" + "github.com/apache/camel-k/pkg/util/camel" "github.com/apache/camel-k/pkg/util/test" - - "github.com/stretchr/testify/assert" ) type errorTestSteps struct { @@ -33,7 +34,7 @@ type errorTestSteps struct { } func TestFailure(t *testing.T) { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) c, err := test.NewFakeClient() diff --git a/pkg/builder/runtime/main_test.go b/pkg/builder/runtime/main_test.go index e98b813..89c3d56 100644 --- a/pkg/builder/runtime/main_test.go +++ b/pkg/builder/runtime/main_test.go @@ -24,12 +24,12 @@ import ( "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" "github.com/apache/camel-k/pkg/builder" + "github.com/apache/camel-k/pkg/util/camel" "github.com/apache/camel-k/pkg/util/maven" - "github.com/apache/camel-k/pkg/util/test" ) func TestNewProject(t *testing.T) { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) ctx := builder.Context{ @@ -91,7 +91,7 @@ func TestNewProject(t *testing.T) { } func TestGenerateJvmProject(t *testing.T) { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) ctx := builder.Context{ @@ -148,7 +148,7 @@ func TestGenerateJvmProject(t *testing.T) { } func TestGenerateGroovyProject(t *testing.T) { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) ctx := builder.Context{ @@ -209,7 +209,7 @@ func TestGenerateGroovyProject(t *testing.T) { } func TestSanitizeDependencies(t *testing.T) { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) ctx := builder.Context{ diff --git a/pkg/cmd/completion_bash.go b/pkg/cmd/completion_bash.go index ee53550..0cdc16c 100644 --- a/pkg/cmd/completion_bash.go +++ b/pkg/cmd/completion_bash.go @@ -25,8 +25,6 @@ import ( "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" - "github.com/apache/camel-k/pkg/util/test" - "github.com/apache/camel-k/pkg/platform" "github.com/apache/camel-k/pkg/trait" @@ -254,7 +252,7 @@ func configureBashAnnotationForFlag(command *cobra.Command, flagName string, ann } func computeCamelDependencies() string { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() if err != nil || catalog == nil { catalog = camel.NewRuntimeCatalog(v1alpha1.CamelCatalog{}.Spec) } diff --git a/pkg/metadata/metadata_dependencies_test.go b/pkg/metadata/metadata_dependencies_test.go index cb86863..d0919b5 100644 --- a/pkg/metadata/metadata_dependencies_test.go +++ b/pkg/metadata/metadata_dependencies_test.go @@ -20,10 +20,10 @@ package metadata import ( "testing" - "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" - "github.com/apache/camel-k/pkg/util/test" - "github.com/stretchr/testify/assert" + + "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" + "github.com/apache/camel-k/pkg/util/camel" ) func TestDependenciesJavaSource(t *testing.T) { @@ -41,7 +41,7 @@ func TestDependenciesJavaSource(t *testing.T) { Language: v1alpha1.LanguageJavaSource, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := Extract(catalog, code) @@ -63,7 +63,7 @@ func TestDependenciesJavaScript(t *testing.T) { Language: v1alpha1.LanguageJavaScript, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := Extract(catalog, code) @@ -87,7 +87,7 @@ func TestDependenciesGroovy(t *testing.T) { Language: v1alpha1.LanguageGroovy, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := Extract(catalog, code) @@ -108,7 +108,7 @@ func TestDependencies(t *testing.T) { Language: v1alpha1.LanguageJavaSource, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := Extract(catalog, code) @@ -127,7 +127,7 @@ func TestJacksonDependency(t *testing.T) { Language: v1alpha1.LanguageJavaSource, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := Extract(catalog, code) @@ -154,7 +154,7 @@ func TestLanguageDependencies(t *testing.T) { Language: v1alpha1.LanguageJavaSource, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := Extract(catalog, code) @@ -177,7 +177,7 @@ func TestLanguageDependenciesTransformExpression(t *testing.T) { Language: v1alpha1.LanguageJavaSource, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := Extract(catalog, code) @@ -199,7 +199,7 @@ func TestHystrixDependency(t *testing.T) { Language: v1alpha1.LanguageGroovy, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := Extract(catalog, code) @@ -222,7 +222,7 @@ func TestRestDependency(t *testing.T) { Language: v1alpha1.LanguageGroovy, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := Extract(catalog, code) @@ -245,7 +245,7 @@ func TestRestWithPathDependency(t *testing.T) { Language: v1alpha1.LanguageGroovy, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := Extract(catalog, code) @@ -267,7 +267,7 @@ func TestRestConfigurationDependency(t *testing.T) { Language: v1alpha1.LanguageGroovy, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := Extract(catalog, code) @@ -289,7 +289,7 @@ func TestRestClosureDependency(t *testing.T) { Language: v1alpha1.LanguageGroovy, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := Extract(catalog, code) @@ -315,7 +315,7 @@ func TestXMLHystrixDependency(t *testing.T) { Language: v1alpha1.LanguageXML, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := Extract(catalog, code) @@ -345,7 +345,7 @@ func TestXMLRestDependency(t *testing.T) { Language: v1alpha1.LanguageXML, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := Extract(catalog, code) @@ -394,7 +394,7 @@ func TestXMLLanguageDependencies(t *testing.T) { Language: v1alpha1.LanguageXML, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := Extract(catalog, code) @@ -453,7 +453,7 @@ func TestYAMLRestDependency(t *testing.T) { Language: v1alpha1.LanguageYaml, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := Extract(catalog, code) @@ -471,7 +471,7 @@ func TestYAMLHystrixDependency(t *testing.T) { Language: v1alpha1.LanguageYaml, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := Extract(catalog, code) @@ -488,7 +488,7 @@ func TestYAMLLanguageDependencies(t *testing.T) { Language: v1alpha1.LanguageYaml, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := Extract(catalog, code) diff --git a/pkg/metadata/metadata_http_test.go b/pkg/metadata/metadata_http_test.go index edf80b7..2bbaa3d 100644 --- a/pkg/metadata/metadata_http_test.go +++ b/pkg/metadata/metadata_http_test.go @@ -20,10 +20,10 @@ package metadata import ( "testing" - "github.com/apache/camel-k/pkg/util/test" + "github.com/stretchr/testify/assert" "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" - "github.com/stretchr/testify/assert" + "github.com/apache/camel-k/pkg/util/camel" ) func TestHttpJavaSource(t *testing.T) { @@ -39,7 +39,7 @@ func TestHttpJavaSource(t *testing.T) { Language: v1alpha1.LanguageJavaSource, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := Extract(catalog, code) @@ -62,7 +62,7 @@ func TestHttpOnlyJavaSource(t *testing.T) { Language: v1alpha1.LanguageJavaSource, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := Extract(catalog, code) @@ -83,7 +83,7 @@ func TestHttpOnlyJavaSourceRest(t *testing.T) { Language: v1alpha1.LanguageJavaSource, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := Extract(catalog, code) @@ -104,7 +104,7 @@ func TestHttpOnlyJavaSourceRest2(t *testing.T) { Language: v1alpha1.LanguageJavaSource, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := Extract(catalog, code) @@ -126,7 +126,7 @@ func TestNoHttpGroovySource(t *testing.T) { Language: v1alpha1.LanguageGroovy, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := Extract(catalog, code) @@ -148,7 +148,7 @@ func TestHttpOnlyGroovySource(t *testing.T) { Language: v1alpha1.LanguageGroovy, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := Extract(catalog, code) @@ -170,7 +170,7 @@ func TestHttpXMLSource(t *testing.T) { Language: v1alpha1.LanguageXML, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := Extract(catalog, code) @@ -193,7 +193,7 @@ func TestHttpOnlyXMLSource(t *testing.T) { Language: v1alpha1.LanguageXML, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := Extract(catalog, code) @@ -227,7 +227,7 @@ func TestMultilangHTTPOnlySource(t *testing.T) { }, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := ExtractAll(catalog, codes) @@ -263,7 +263,7 @@ func TestMultilangHTTPSource(t *testing.T) { }, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) meta := ExtractAll(catalog, codes) diff --git a/pkg/metadata/metadata_uri_test.go b/pkg/metadata/metadata_uri_test.go index 74d6133..16c8e33 100644 --- a/pkg/metadata/metadata_uri_test.go +++ b/pkg/metadata/metadata_uri_test.go @@ -20,10 +20,10 @@ package metadata import ( "testing" - "github.com/apache/camel-k/pkg/util/test" + "github.com/stretchr/testify/assert" "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" - "github.com/stretchr/testify/assert" + "github.com/apache/camel-k/pkg/util/camel" ) func TestJava1(t *testing.T) { @@ -46,7 +46,7 @@ func TestJava1(t *testing.T) { Language: v1alpha1.LanguageJavaSource, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) metadata := Extract(catalog, source) @@ -83,7 +83,7 @@ func TestJava2(t *testing.T) { Language: v1alpha1.LanguageJavaSource, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) metadata := Extract(catalog, source) @@ -115,7 +115,7 @@ func TestGroovy1(t *testing.T) { Language: v1alpha1.LanguageGroovy, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) metadata := Extract(catalog, source) @@ -145,7 +145,7 @@ func TestGroovy2(t *testing.T) { Language: v1alpha1.LanguageGroovy, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) metadata := Extract(catalog, source) @@ -180,7 +180,7 @@ func TestXml1(t *testing.T) { Language: v1alpha1.LanguageXML, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) metadata := Extract(catalog, source) @@ -214,7 +214,7 @@ func TestKotlin1(t *testing.T) { Language: v1alpha1.LanguageKotlin, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) metadata := Extract(catalog, source) @@ -245,7 +245,7 @@ func TestJavascript1(t *testing.T) { Language: v1alpha1.LanguageJavaScript, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) metadata := Extract(catalog, source) @@ -281,7 +281,7 @@ func TestJYaml(t *testing.T) { Language: v1alpha1.LanguageYaml, } - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) metadata := Extract(catalog, source) diff --git a/pkg/trait/builder_test.go b/pkg/trait/builder_test.go index e3ae69e..651d522 100644 --- a/pkg/trait/builder_test.go +++ b/pkg/trait/builder_test.go @@ -21,6 +21,9 @@ import ( "context" "testing" + "github.com/scylladb/go-set/strset" + "github.com/stretchr/testify/assert" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -28,13 +31,9 @@ import ( "github.com/apache/camel-k/pkg/builder" "github.com/apache/camel-k/pkg/builder/kaniko" "github.com/apache/camel-k/pkg/builder/s2i" + "github.com/apache/camel-k/pkg/util/camel" "github.com/apache/camel-k/pkg/util/defaults" "github.com/apache/camel-k/pkg/util/kubernetes" - "github.com/apache/camel-k/pkg/util/test" - - "github.com/stretchr/testify/assert" - - "github.com/scylladb/go-set/strset" ) func TestBuilderTraitNotAppliedBecauseOfNilKit(t *testing.T) { @@ -120,7 +119,7 @@ func TestKanikoBuilderTrait(t *testing.T) { } func createBuilderTestEnv(cluster v1alpha1.IntegrationPlatformCluster, strategy v1alpha1.IntegrationPlatformBuildPublishStrategy) *Environment { - c, err := test.DefaultCatalog() + c, err := camel.DefaultCatalog() if err != nil { panic(err) } diff --git a/pkg/trait/container_test.go b/pkg/trait/container_test.go index f5793cc..10e8787 100644 --- a/pkg/trait/container_test.go +++ b/pkg/trait/container_test.go @@ -22,19 +22,18 @@ import ( "testing" "github.com/scylladb/go-set/strset" - - "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" - "github.com/apache/camel-k/pkg/util/kubernetes" - "github.com/apache/camel-k/pkg/util/test" + "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/stretchr/testify/assert" + "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" + "github.com/apache/camel-k/pkg/util/camel" + "github.com/apache/camel-k/pkg/util/kubernetes" ) func TestContainerWithDefaults(t *testing.T) { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) traitCatalog := NewCatalog(context.TODO(), nil) @@ -89,7 +88,7 @@ func TestContainerWithDefaults(t *testing.T) { } func TestContainerWithCustomName(t *testing.T) { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) traitCatalog := NewCatalog(context.TODO(), nil) diff --git a/pkg/trait/debug_test.go b/pkg/trait/debug_test.go index b01fdd0..4968b1f 100644 --- a/pkg/trait/debug_test.go +++ b/pkg/trait/debug_test.go @@ -20,17 +20,17 @@ package trait import ( "testing" - "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" - "github.com/apache/camel-k/pkg/util/envvar" - "github.com/apache/camel-k/pkg/util/test" - "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" + + "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" + "github.com/apache/camel-k/pkg/util/camel" + "github.com/apache/camel-k/pkg/util/envvar" ) func TestDebugTraitApplicability(t *testing.T) { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) env := Environment{ diff --git a/pkg/trait/dependencies_test.go b/pkg/trait/dependencies_test.go index 8e75159..fe3bed8 100644 --- a/pkg/trait/dependencies_test.go +++ b/pkg/trait/dependencies_test.go @@ -20,9 +20,10 @@ package trait import ( "testing" - "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" - "github.com/apache/camel-k/pkg/util/test" "github.com/stretchr/testify/assert" + + "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" + "github.com/apache/camel-k/pkg/util/camel" ) func TestDependenciesTraitApplicability(t *testing.T) { @@ -48,7 +49,7 @@ func TestDependenciesTraitApplicability(t *testing.T) { } func TestIntegrationDefaultDeps(t *testing.T) { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) e := &Environment{ @@ -91,7 +92,7 @@ func TestIntegrationDefaultDeps(t *testing.T) { } func TestIntegrationCustomDeps(t *testing.T) { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) e := &Environment{ @@ -139,7 +140,7 @@ func TestIntegrationCustomDeps(t *testing.T) { } func TestIntegrationAutoGeneratedDeps(t *testing.T) { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) e := &Environment{ @@ -193,7 +194,7 @@ func TestIntegrationAutoGeneratedDeps(t *testing.T) { } func TestIntegrationCustomLoader(t *testing.T) { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) e := &Environment{ diff --git a/pkg/trait/environment_test.go b/pkg/trait/environment_test.go index ca5929d..977ab4b 100644 --- a/pkg/trait/environment_test.go +++ b/pkg/trait/environment_test.go @@ -22,20 +22,19 @@ import ( "testing" "github.com/scylladb/go-set/strset" - - "github.com/apache/camel-k/pkg/util/test" - - "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" - "github.com/apache/camel-k/pkg/util/kubernetes" "github.com/stretchr/testify/assert" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" + "github.com/apache/camel-k/pkg/util/camel" + "github.com/apache/camel-k/pkg/util/kubernetes" ) func TestDefaultEnvironment(t *testing.T) { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) env := Environment{ @@ -96,7 +95,7 @@ func TestDefaultEnvironment(t *testing.T) { } func TestEnabledContainerMetaDataEnvVars(t *testing.T) { - c, err := test.DefaultCatalog() + c, err := camel.DefaultCatalog() assert.Nil(t, err) env := Environment{ @@ -164,7 +163,7 @@ func TestEnabledContainerMetaDataEnvVars(t *testing.T) { } func TestDisabledContainerMetaDataEnvVars(t *testing.T) { - c, err := test.DefaultCatalog() + c, err := camel.DefaultCatalog() assert.Nil(t, err) env := Environment{ diff --git a/pkg/trait/istio_test.go b/pkg/trait/istio_test.go index cd5830f..3671420 100644 --- a/pkg/trait/istio_test.go +++ b/pkg/trait/istio_test.go @@ -20,21 +20,22 @@ package trait import ( "testing" - "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" - "github.com/apache/camel-k/pkg/util/kubernetes" - "github.com/apache/camel-k/pkg/util/test" - "github.com/stretchr/testify/assert" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + servingv1 "knative.dev/serving/pkg/apis/serving/v1" serving "knative.dev/serving/pkg/apis/serving/v1beta1" + + "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" + "github.com/apache/camel-k/pkg/util/camel" + "github.com/apache/camel-k/pkg/util/kubernetes" ) func NewIstioTestEnv(t *testing.T, d *appsv1.Deployment, s *serving.Service, enabled bool) Environment { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) env := Environment{ diff --git a/pkg/trait/knative_service_test.go b/pkg/trait/knative_service_test.go index 0af56d9..da9708d 100644 --- a/pkg/trait/knative_service_test.go +++ b/pkg/trait/knative_service_test.go @@ -22,17 +22,17 @@ import ( "testing" "github.com/scylladb/go-set/strset" - - "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" - "github.com/apache/camel-k/pkg/util/envvar" - "github.com/apache/camel-k/pkg/util/kubernetes" - "github.com/apache/camel-k/pkg/util/test" + "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" serving "knative.dev/serving/pkg/apis/serving/v1beta1" - "github.com/stretchr/testify/assert" + "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" + "github.com/apache/camel-k/pkg/util/camel" + "github.com/apache/camel-k/pkg/util/envvar" + "github.com/apache/camel-k/pkg/util/kubernetes" + "github.com/apache/camel-k/pkg/util/test" ) const ( @@ -41,7 +41,7 @@ const ( ) func TestKnativeService(t *testing.T) { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) traitCatalog := NewCatalog(context.TODO(), nil) @@ -183,7 +183,7 @@ func TestKnativeService(t *testing.T) { } func TestKnativeServiceWithCustomContainerName(t *testing.T) { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) traitCatalog := NewCatalog(context.TODO(), nil) diff --git a/pkg/trait/knative_test.go b/pkg/trait/knative_test.go index 8cf3084..13038e5 100644 --- a/pkg/trait/knative_test.go +++ b/pkg/trait/knative_test.go @@ -21,28 +21,30 @@ import ( "context" "testing" - "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" - "github.com/apache/camel-k/pkg/client" - "github.com/apache/camel-k/pkg/util/envvar" - "github.com/apache/camel-k/pkg/util/test" - "github.com/scylladb/go-set/strset" "github.com/stretchr/testify/assert" - knativeapi "github.com/apache/camel-k/pkg/apis/camel/v1alpha1/knative" - k8sutils "github.com/apache/camel-k/pkg/util/kubernetes" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + messaging "knative.dev/eventing/pkg/apis/messaging/v1alpha1" "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" servingv1 "knative.dev/serving/pkg/apis/serving/v1" serving "knative.dev/serving/pkg/apis/serving/v1beta1" + + "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" + knativeapi "github.com/apache/camel-k/pkg/apis/camel/v1alpha1/knative" + "github.com/apache/camel-k/pkg/client" + "github.com/apache/camel-k/pkg/util/camel" + "github.com/apache/camel-k/pkg/util/envvar" + k8sutils "github.com/apache/camel-k/pkg/util/kubernetes" + "github.com/apache/camel-k/pkg/util/test" ) func TestKnativeEnvConfigurationFromTrait(t *testing.T) { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) traitCatalog := NewCatalog(context.TODO(), nil) @@ -141,7 +143,7 @@ func TestKnativeEnvConfigurationFromTrait(t *testing.T) { } func TestKnativeEnvConfigurationFromSource(t *testing.T) { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) traitCatalog := NewCatalog(context.TODO(), nil) diff --git a/pkg/trait/route_test.go b/pkg/trait/route_test.go index 0d270fc..6e7e74b 100644 --- a/pkg/trait/route_test.go +++ b/pkg/trait/route_test.go @@ -22,22 +22,21 @@ import ( "testing" "github.com/rs/xid" - "github.com/scylladb/go-set/strset" - - "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" - "github.com/apache/camel-k/pkg/util/kubernetes" - "github.com/apache/camel-k/pkg/util/test" - "github.com/stretchr/testify/assert" routev1 "github.com/openshift/api/route/v1" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" + "github.com/apache/camel-k/pkg/util/camel" + "github.com/apache/camel-k/pkg/util/kubernetes" ) func createTestRouteEnvironment(t *testing.T, name string) *Environment { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) return &Environment{ diff --git a/pkg/trait/service_test.go b/pkg/trait/service_test.go index fb5f6f5..095ab00 100644 --- a/pkg/trait/service_test.go +++ b/pkg/trait/service_test.go @@ -22,16 +22,15 @@ import ( "testing" "github.com/scylladb/go-set/strset" - - "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" - "github.com/apache/camel-k/pkg/util/kubernetes" - "github.com/apache/camel-k/pkg/util/test" + "github.com/stretchr/testify/assert" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/stretchr/testify/assert" + "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" + "github.com/apache/camel-k/pkg/util/camel" + "github.com/apache/camel-k/pkg/util/kubernetes" ) const ( @@ -40,7 +39,7 @@ const ( ) func TestServiceWithDefaults(t *testing.T) { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) traitCatalog := NewCatalog(context.TODO(), nil) @@ -128,7 +127,7 @@ func TestServiceWithDefaults(t *testing.T) { } func TestService(t *testing.T) { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) traitCatalog := NewCatalog(context.TODO(), nil) @@ -226,7 +225,7 @@ func TestService(t *testing.T) { } func TestServiceWithCustomContainerName(t *testing.T) { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) traitCatalog := NewCatalog(context.TODO(), nil) diff --git a/pkg/trait/trait_test.go b/pkg/trait/trait_test.go index 44ddda6..3729e0d 100644 --- a/pkg/trait/trait_test.go +++ b/pkg/trait/trait_test.go @@ -22,17 +22,17 @@ import ( "testing" "github.com/scylladb/go-set/strset" - - "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" - "github.com/apache/camel-k/pkg/util/kubernetes" - "github.com/apache/camel-k/pkg/util/test" + "github.com/stretchr/testify/assert" routev1 "github.com/openshift/api/route/v1" - "github.com/stretchr/testify/assert" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" + "github.com/apache/camel-k/pkg/util/camel" + "github.com/apache/camel-k/pkg/util/kubernetes" ) const ( @@ -391,7 +391,7 @@ func processTestEnv(t *testing.T, env *Environment) *kubernetes.Collection { } func createTestEnv(t *testing.T, cluster v1alpha1.IntegrationPlatformCluster, script string) *Environment { - catalog, err := test.DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) return &Environment{ diff --git a/pkg/util/camel/camel_runtime.go b/pkg/util/camel/camel_runtime.go index 71bac5f..a0d502a 100644 --- a/pkg/util/camel/camel_runtime.go +++ b/pkg/util/camel/camel_runtime.go @@ -38,7 +38,7 @@ func LoadCatalog(ctx context.Context, client client.Client, namespace string, ca return nil, err } - catalog, err = FindBestMatch(list.Items, camelVersion, runtimeVersion) + catalog, err = findBestMatch(list.Items, camelVersion, runtimeVersion) if err != nil { return nil, err } diff --git a/pkg/util/camel/camel_util.go b/pkg/util/camel/camel_util.go index 4741222..ae80ac7 100644 --- a/pkg/util/camel/camel_util.go +++ b/pkg/util/camel/camel_util.go @@ -21,25 +21,25 @@ import ( "sort" "github.com/Masterminds/semver" + "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" "github.com/apache/camel-k/pkg/util/log" ) -// FindBestMatch -- -func FindBestMatch(catalogs []v1alpha1.CamelCatalog, camelVersion string, runtimeVersion string) (*RuntimeCatalog, error) { +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 } } - vc := NewSemVerConstraint(camelVersion) - rc := NewSemVerConstraint(runtimeVersion) + vc := newSemVerConstraint(camelVersion) + rc := newSemVerConstraint(runtimeVersion) if vc == nil || rc == nil { return nil, nil } - cc := NewCatalogVersionCollection(catalogs) + cc := newCatalogVersionCollection(catalogs) for _, x := range cc { if vc.Check(x.Version) && rc.Check(x.RuntimeVersion) { return NewRuntimeCatalog(x.Catalog.Spec), nil @@ -49,8 +49,7 @@ func FindBestMatch(catalogs []v1alpha1.CamelCatalog, camelVersion string, runtim return nil, nil } -// NewSemVerConstraint -- -func NewSemVerConstraint(versionConstraint string) *semver.Constraints { +func newSemVerConstraint(versionConstraint string) *semver.Constraints { constraint, err := semver.NewConstraint(versionConstraint) if err != nil || constraint == nil { if err != nil { @@ -64,8 +63,7 @@ func NewSemVerConstraint(versionConstraint string) *semver.Constraints { return constraint } -// NewCatalogVersionCollection -- -func NewCatalogVersionCollection(catalogs []v1alpha1.CamelCatalog) CatalogVersionCollection { +func newCatalogVersionCollection(catalogs []v1alpha1.CamelCatalog) CatalogVersionCollection { versions := make([]CatalogVersion, 0, len(catalogs)) for i := range catalogs { diff --git a/pkg/util/camel/camel_util_test.go b/pkg/util/camel/camel_util_test.go index 5dff8ab..456556a 100644 --- a/pkg/util/camel/camel_util_test.go +++ b/pkg/util/camel/camel_util_test.go @@ -32,7 +32,7 @@ func TestFindBestMatch_Camel(t *testing.T) { {Spec: v1alpha1.CamelCatalogSpec{Version: "2.22.1", RuntimeVersion: "1.0.0"}}, } - c, err := FindBestMatch(catalogs, "~2.23.x", "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) @@ -45,7 +45,7 @@ func TestFindBestMatch_Runtime(t *testing.T) { {Spec: v1alpha1.CamelCatalogSpec{Version: "2.22.1", RuntimeVersion: "1.0.0"}}, } - c, err := FindBestMatch(catalogs, "2.23.0", "~1.0.x") + 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) @@ -60,7 +60,7 @@ func TestFindBestMatch(t *testing.T) { {Spec: v1alpha1.CamelCatalogSpec{Version: "2.22.1", RuntimeVersion: "1.0.0"}}, } - c, err := FindBestMatch(catalogs, "~2.23.x", "~1.0.x") + 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) @@ -74,7 +74,7 @@ func TestFindExactSemVerMatch_Camel(t *testing.T) { {Spec: v1alpha1.CamelCatalogSpec{Version: "2.22.1", RuntimeVersion: "1.0.0"}}, } - c, err := FindBestMatch(catalogs, "2.23.0", "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) @@ -87,7 +87,7 @@ func TestFindExactSemVerMatch_Runtime(t *testing.T) { {Spec: v1alpha1.CamelCatalogSpec{Version: "2.22.1", RuntimeVersion: "1.0.0"}}, } - c, err := FindBestMatch(catalogs, "2.23.0", "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) @@ -102,7 +102,7 @@ func TestFindExactMatch_Camel(t *testing.T) { {Spec: v1alpha1.CamelCatalogSpec{Version: "2.22.1", RuntimeVersion: "1.0.0"}}, } - c, err := FindBestMatch(catalogs, "2.23.1-tag-00001", "1.0.0") + 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) @@ -116,7 +116,7 @@ func TestFindExactMatch_Runtime(t *testing.T) { {Spec: v1alpha1.CamelCatalogSpec{Version: "2.22.1", RuntimeVersion: "1.0.0"}}, } - c, err := FindBestMatch(catalogs, "2.23.1-tag-00001", "1.0.1") + 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) @@ -131,7 +131,7 @@ func TestFindRangeMatch_Camel(t *testing.T) { {Spec: v1alpha1.CamelCatalogSpec{Version: "2.22.1", RuntimeVersion: "1.0.0"}}, } - c, err := FindBestMatch(catalogs, ">= 2.23.0, < 2.23.2", "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) @@ -146,7 +146,7 @@ func TestFindRangeMatch_Runtime(t *testing.T) { {Spec: v1alpha1.CamelCatalogSpec{Version: "2.22.1", RuntimeVersion: "1.0.0"}}, } - c, err := FindBestMatch(catalogs, "2.23.0", "> 1.0.1, < 1.0.3") + 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) @@ -163,7 +163,7 @@ func TestFindRangeMatch(t *testing.T) { {Spec: v1alpha1.CamelCatalogSpec{Version: "2.22.1", RuntimeVersion: "1.0.0"}}, } - c, err := FindBestMatch(catalogs, ">= 2.23.0, < 2.23.2", "> 1.0.1, < 1.0.3") + 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) diff --git a/pkg/util/test/catalog.go b/pkg/util/camel/catalog.go similarity index 85% rename from pkg/util/test/catalog.go rename to pkg/util/camel/catalog.go index b20b9c3..4b8df56 100644 --- a/pkg/util/test/catalog.go +++ b/pkg/util/camel/catalog.go @@ -15,21 +15,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -package test +package camel import ( "strings" + yaml2 "gopkg.in/yaml.v2" + "github.com/apache/camel-k/deploy" "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" - "github.com/apache/camel-k/pkg/util/camel" "github.com/apache/camel-k/pkg/util/defaults" - - yaml2 "gopkg.in/yaml.v2" ) // DefaultCatalog -- -func DefaultCatalog() (*camel.RuntimeCatalog, error) { +func DefaultCatalog() (*RuntimeCatalog, error) { catalogs := make([]v1alpha1.CamelCatalog, 0) for name, content := range deploy.Resources { @@ -43,5 +42,5 @@ func DefaultCatalog() (*camel.RuntimeCatalog, error) { } } - return camel.FindBestMatch(catalogs, defaults.DefaultCamelVersion, defaults.DefaultRuntimeVersion) + return findBestMatch(catalogs, defaults.DefaultCamelVersion, defaults.DefaultRuntimeVersion) } diff --git a/pkg/util/test/catalog_test.go b/pkg/util/test/catalog_test.go index a93e1cf..5e3e420 100644 --- a/pkg/util/test/catalog_test.go +++ b/pkg/util/test/catalog_test.go @@ -20,13 +20,14 @@ package test import ( "testing" - "github.com/apache/camel-k/pkg/util/defaults" - "github.com/stretchr/testify/assert" + + "github.com/apache/camel-k/pkg/util/camel" + "github.com/apache/camel-k/pkg/util/defaults" ) func TestRuntimeContainsEmbeddedArtifacts(t *testing.T) { - catalog, err := DefaultCatalog() + catalog, err := camel.DefaultCatalog() assert.Nil(t, err) assert.Equal(t, defaults.DefaultCamelVersion, catalog.Version)
