From 395c3c487421a6c741a3c05548ac3dc6f4db6afd Mon Sep 17 00:00:00 2001 From: lburgazzoli Date: Mon, 9 Mar 2020 11:20:21 +0100 Subject: [PATCH] Rename rest-dsl trait to openapi #1317 --- docs/modules/ROOT/nav.adoc | 2 +- .../traits/{rest-dsl.adoc => openapi.adoc} | 4 +-- docs/modules/ROOT/pages/traits/traits.adoc | 2 +- pkg/trait/{rest-dsl.go => openapi.go} | 30 +++++++++---------- .../{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(-) rename docs/modules/ROOT/pages/traits/{rest-dsl.adoc => openapi.adoc} (82%) rename pkg/trait/{rest-dsl.go => openapi.go} (91%) rename pkg/trait/{rest-dsl_test.go => openapi_test.go} (96%) diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index ab5709cbf9..efbf12e0c3 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 fad21da2b3..e3fe189890 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 476b19d5f4..8109aea0d1 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 0d18945a84..93955c77fb 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 4f71ebb3ac..791fbc53c4 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 61bf7b1ea8..27ea26db65 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 4ffe2f0982..46e80db76d 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() {