You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2020/03/10 17:11:37 UTC

[camel-k] 02/09: Rename rest-dsl trait to openapi #1317

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 395c3c487421a6c741a3c05548ac3dc6f4db6afd
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Mon Mar 9 11:20:21 2020 +0100

    Rename rest-dsl trait to openapi #1317
---
 docs/modules/ROOT/nav.adoc                         |  2 +-
 .../pages/traits/{rest-dsl.adoc => openapi.adoc}   |  4 +--
 docs/modules/ROOT/pages/traits/traits.adoc         |  2 +-
 pkg/trait/{rest-dsl.go => openapi.go}              | 30 +++++++++++-----------
 pkg/trait/{rest-dsl_test.go => openapi_test.go}    |  6 ++---
 pkg/trait/trait_register.go                        |  2 +-
 pkg/trait/trait_test.go                            |  2 +-
 7 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc
index ab5709c..efbf12e 100644
--- a/docs/modules/ROOT/nav.adoc
+++ b/docs/modules/ROOT/nav.adoc
@@ -39,7 +39,7 @@
 ** xref:traits/prometheus.adoc[Prometheus]
 ** xref:traits/pull-secret.adoc[Pull Secret]
 ** xref:traits/quarkus.adoc[Quarkus]
-** xref:traits/rest-dsl.adoc[Rest Dsl]
+** xref:traits/openapi.adoc[Rest Dsl]
 ** xref:traits/route.adoc[Route]
 ** xref:traits/service.adoc[Service]
 // End of autogenerated code - DO NOT EDIT! (trait-nav)
diff --git a/docs/modules/ROOT/pages/traits/rest-dsl.adoc b/docs/modules/ROOT/pages/traits/openapi.adoc
similarity index 82%
rename from docs/modules/ROOT/pages/traits/rest-dsl.adoc
rename to docs/modules/ROOT/pages/traits/openapi.adoc
index fad21da..e3fe189 100755
--- a/docs/modules/ROOT/pages/traits/rest-dsl.adoc
+++ b/docs/modules/ROOT/pages/traits/openapi.adoc
@@ -6,7 +6,7 @@ The Rest DSL trait is internally used to allow creating integrations from a Open
 
 This trait is available in the following profiles: **Kubernetes, Knative, OpenShift**.
 
-WARNING: The rest-dsl trait is a *platform trait*: disabling it may compromise the platform functionality.
+WARNING: The openapi trait is a *platform trait*: disabling it may compromise the platform functionality.
 
 // End of autogenerated code - DO NOT EDIT! (description)
 // Start of autogenerated code - DO NOT EDIT! (configuration)
@@ -14,7 +14,7 @@ WARNING: The rest-dsl trait is a *platform trait*: disabling it may compromise t
 
 Trait properties can be specified when running any integration with the CLI:
 ```
-kamel run --trait rest-dsl.[key]=[value] integration.groovy
+kamel run --trait openapi.[key]=[value] integration.groovy
 ```
 The following configuration options are available:
 
diff --git a/docs/modules/ROOT/pages/traits/traits.adoc b/docs/modules/ROOT/pages/traits/traits.adoc
index 476b19d..8109aea 100644
--- a/docs/modules/ROOT/pages/traits/traits.adoc
+++ b/docs/modules/ROOT/pages/traits/traits.adoc
@@ -57,7 +57,7 @@ See the trait description pages for more information on a specific trait:
 * xref:traits/prometheus.adoc[Prometheus Trait]
 * xref:traits/pull-secret.adoc[Pull Secret Trait]
 * xref:traits/quarkus.adoc[Quarkus Trait]
-* xref:traits/rest-dsl.adoc[Rest Dsl Trait]
+* xref:traits/openapi.adoc[Rest Dsl Trait]
 * xref:traits/route.adoc[Route Trait]
 * xref:traits/service.adoc[Service Trait]
 // End of autogenerated code - DO NOT EDIT! (trait-list)
diff --git a/pkg/trait/rest-dsl.go b/pkg/trait/openapi.go
similarity index 91%
rename from pkg/trait/rest-dsl.go
rename to pkg/trait/openapi.go
index 0d18945..93955c7 100644
--- a/pkg/trait/rest-dsl.go
+++ b/pkg/trait/openapi.go
@@ -28,37 +28,37 @@ import (
 	"strconv"
 	"strings"
 
-	"github.com/apache/camel-k/pkg/util"
-
 	corev1 "k8s.io/api/core/v1"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 
 	v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+
+	"github.com/apache/camel-k/pkg/util"
 	"github.com/apache/camel-k/pkg/util/defaults"
 	"github.com/apache/camel-k/pkg/util/gzip"
 	"github.com/apache/camel-k/pkg/util/kubernetes"
 	"github.com/apache/camel-k/pkg/util/maven"
 )
 
-// The Rest DSL trait is internally used to allow creating integrations from a OpenAPI specs.
+// The OpenAPI DSL trait is internally used to allow creating integrations from a OpenAPI specs.
 //
-// +camel-k:trait=rest-dsl
-type restDslTrait struct {
+// +camel-k:trait=openapi
+type openAPITrait struct {
 	BaseTrait `property:",squash"`
 }
 
-func newRestDslTrait() Trait {
-	return &restDslTrait{
-		BaseTrait: NewBaseTrait("rest-dsl", 300),
+func newOpenAPITrait() Trait {
+	return &openAPITrait{
+		BaseTrait: NewBaseTrait("openapi", 300),
 	}
 }
 
 // IsPlatformTrait overrides base class method
-func (t *restDslTrait) IsPlatformTrait() bool {
+func (t *openAPITrait) IsPlatformTrait() bool {
 	return true
 }
 
-func (t *restDslTrait) Configure(e *Environment) (bool, error) {
+func (t *openAPITrait) Configure(e *Environment) (bool, error) {
 	if t.Enabled != nil && !*t.Enabled {
 		return false, nil
 	}
@@ -85,7 +85,7 @@ func (t *restDslTrait) Configure(e *Environment) (bool, error) {
 	return false, nil
 }
 
-func (t *restDslTrait) Apply(e *Environment) error {
+func (t *openAPITrait) Apply(e *Environment) error {
 	if len(e.Integration.Spec.Resources) == 0 {
 		return nil
 	}
@@ -103,9 +103,9 @@ func (t *restDslTrait) Apply(e *Environment) error {
 	return nil
 }
 
-func (t *restDslTrait) generateRestDSL(e *Environment) error {
+func (t *openAPITrait) generateRestDSL(e *Environment) error {
 	root := os.TempDir()
-	tmpDir, err := ioutil.TempDir(root, "rest-dsl")
+	tmpDir, err := ioutil.TempDir(root, "openapi")
 	if err != nil {
 		return err
 	}
@@ -242,7 +242,7 @@ func (t *restDslTrait) generateRestDSL(e *Environment) error {
 	return nil
 }
 
-func (t *restDslTrait) generateMavenProject(e *Environment) (maven.Project, error) {
+func (t *openAPITrait) generateMavenProject(e *Environment) (maven.Project, error) {
 	if e.CamelCatalog == nil {
 		return maven.Project{}, errors.New("unknown camel catalog")
 	}
@@ -270,7 +270,7 @@ func (t *restDslTrait) generateMavenProject(e *Environment) (maven.Project, erro
 	return p, nil
 }
 
-func (t *restDslTrait) computeDependencies(e *Environment) {
+func (t *openAPITrait) computeDependencies(e *Environment) {
 	// check if the runtime provides 'rest' capabilities
 	if capability, ok := e.CamelCatalog.Runtime.Capabilities["rest"]; ok {
 		for _, dependency := range capability.Dependencies {
diff --git a/pkg/trait/rest-dsl_test.go b/pkg/trait/openapi_test.go
similarity index 96%
rename from pkg/trait/rest-dsl_test.go
rename to pkg/trait/openapi_test.go
index 4f71ebb..791fbc5 100644
--- a/pkg/trait/rest-dsl_test.go
+++ b/pkg/trait/openapi_test.go
@@ -35,7 +35,7 @@ func TestRestDslTraitApplicability(t *testing.T) {
 		CamelCatalog: catalog,
 	}
 
-	trait := newRestDslTrait()
+	trait := newOpenAPITrait()
 	enabled, err := trait.Configure(e)
 	assert.Nil(t, err)
 	assert.False(t, enabled)
@@ -81,7 +81,7 @@ func TestRestDslTraitDeps(t *testing.T) {
 		},
 	}
 
-	trait := newRestDslTrait().(*restDslTrait)
+	trait := newOpenAPITrait().(*openAPITrait)
 	trait.computeDependencies(e)
 
 	assert.Contains(t, e.Integration.Status.Dependencies, "mvn:org.apache.camel/camel-rest")
@@ -106,7 +106,7 @@ func TestRestDslTraitDepsQuarkus(t *testing.T) {
 		},
 	}
 
-	trait := newRestDslTrait().(*restDslTrait)
+	trait := newOpenAPITrait().(*openAPITrait)
 	trait.computeDependencies(e)
 
 	assert.Contains(t, e.Integration.Status.Dependencies, "mvn:org.apache.camel.quarkus/camel-quarkus-rest")
diff --git a/pkg/trait/trait_register.go b/pkg/trait/trait_register.go
index 61bf7b1..27ea26d 100644
--- a/pkg/trait/trait_register.go
+++ b/pkg/trait/trait_register.go
@@ -22,7 +22,7 @@ func init() {
 	// Declaration order is not important, but let's keep them sorted for debugging.
 	AddToTraits(newPlatformTrait)
 	AddToTraits(newCamelTrait)
-	AddToTraits(newRestDslTrait)
+	AddToTraits(newOpenAPITrait)
 	AddToTraits(newKnativeTrait)
 	AddToTraits(newDependenciesTrait)
 	AddToTraits(newBuilderTrait)
diff --git a/pkg/trait/trait_test.go b/pkg/trait/trait_test.go
index 4ffe2f0..46e80db 100644
--- a/pkg/trait/trait_test.go
+++ b/pkg/trait/trait_test.go
@@ -393,7 +393,7 @@ func TestOnlySomeTraitsInfluenceBuild(t *testing.T) {
 
 func TestOnlySomeTraitsArePlatform(t *testing.T) {
 	c := NewTraitTestCatalog()
-	platformTraits := []string{"builder", "camel", "jvm", "container", "dependencies", "deployer", "deployment", "environment", "rest-dsl", "owner", "platform"}
+	platformTraits := []string{"builder", "camel", "jvm", "container", "dependencies", "deployer", "deployment", "environment", "openapi", "owner", "platform"}
 
 	for _, trait := range c.allTraits() {
 		if trait.IsPlatformTrait() {