Skip to content

Commit

Permalink
Rename rest-dsl trait to openapi apache#1317
Browse files Browse the repository at this point in the history
  • Loading branch information
lburgazzoli committed Mar 9, 2020
1 parent 2039f7d commit 2505911
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ 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)
== Configuration

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:

Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/traits/traits.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
28 changes: 14 additions & 14 deletions pkg/trait/rest-dsl.go → pkg/trait/openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,32 @@ import (
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/apis/camel/v1"
"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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions pkg/trait/rest-dsl_test.go → pkg/trait/openapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion pkg/trait/trait_register.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/trait/trait_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 2505911

Please sign in to comment.