From aa88c5c8273b799cd8d02babfd7df5225aa431a4 Mon Sep 17 00:00:00 2001 From: Nicola Ferraro Date: Mon, 16 Mar 2020 18:48:02 +0100 Subject: [PATCH] Fix #1325: add 3scale addon --- addons/register_3scale.go | 27 ++++ addons/threescale/3scale.go | 138 ++++++++++++++++++ addons/threescale/3scale_test.go | 114 +++++++++++++++ addons/threescale/zz_generated_doc.go | 1 + build/maven/pom-runtime.xml | 36 +++++ deploy/resources.go | 8 + docs/modules/ROOT/nav.adoc | 3 +- docs/modules/ROOT/pages/traits/3scale.adoc | 52 +++++++ docs/modules/ROOT/pages/traits/container.adoc | 59 ++++++++ docs/modules/ROOT/pages/traits/openapi.adoc | 4 +- docs/modules/ROOT/pages/traits/traits.adoc | 3 +- pkg/cmd/run.go | 2 +- 12 files changed, 442 insertions(+), 5 deletions(-) create mode 100644 addons/register_3scale.go create mode 100644 addons/threescale/3scale.go create mode 100644 addons/threescale/3scale_test.go create mode 100644 addons/threescale/zz_generated_doc.go create mode 100755 docs/modules/ROOT/pages/traits/3scale.adoc diff --git a/addons/register_3scale.go b/addons/register_3scale.go new file mode 100644 index 0000000000..aaa3cb1f49 --- /dev/null +++ b/addons/register_3scale.go @@ -0,0 +1,27 @@ +/* +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 addons + +import ( + "github.com/apache/camel-k/addons/threescale" + "github.com/apache/camel-k/pkg/trait" +) + +func init() { + trait.AddToTraits(threescale.NewThreeScaleTrait) +} diff --git a/addons/threescale/3scale.go b/addons/threescale/3scale.go new file mode 100644 index 0000000000..fa2250ce29 --- /dev/null +++ b/addons/threescale/3scale.go @@ -0,0 +1,138 @@ +/* +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 threescale + +import ( + "strconv" + + v1 "github.com/apache/camel-k/pkg/apis/camel/v1" + "github.com/apache/camel-k/pkg/trait" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// The 3scale trait can be used to automatically create annotations that allow +// 3scale to discover the generated service and make it available for API management. +// +// The 3scale trait is disabled by default. +// +// +camel-k:trait=3scale +type threeScaleTrait struct { + trait.BaseTrait `property:",squash"` + // Enables automatic configuration of the trait. + Auto *bool `property:"auto"` + // The scheme to use to contact the service (default `http`) + Scheme string `property:"scheme"` + // The path where the API is published (default `/`) + Path string `property:"path"` + // The port where the service is exposed (default `80`) + Port int `property:"port"` + // The path where the Open-API specification is published (default `/api-doc`) + DescriptionPath *string `property:"description-path"` +} + +const ( + // ThreeScaleSchemeAnnotation -- + ThreeScaleSchemeAnnotation = "discovery.3scale.net/scheme" + // ThreeScaleSchemeDefaultValue -- + ThreeScaleSchemeDefaultValue = "http" + + // ThreeScalePortAnnotation -- + ThreeScalePortAnnotation = "discovery.3scale.net/port" + // ThreeScalePortDefaultValue -- + ThreeScalePortDefaultValue = 80 + + // ThreeScalePathAnnotation -- + ThreeScalePathAnnotation = "discovery.3scale.net/path" + // ThreeScalePathDefaultValue -- + ThreeScalePathDefaultValue = "/" + + // ThreeScaleDescriptionPathAnnotation -- + ThreeScaleDescriptionPathAnnotation = "discovery.3scale.net/description-path" + // ThreeScaleDescriptionPathDefaultValue -- + ThreeScaleDescriptionPathDefaultValue = "/api-doc" + + // ThreeScaleDiscoveryLabel -- + ThreeScaleDiscoveryLabel = "discovery.3scale.net" + // ThreeScaleDiscoveryLabelEnabled -- + ThreeScaleDiscoveryLabelEnabled = "true" +) + +// NewThreeScaleTrait -- +func NewThreeScaleTrait() trait.Trait { + return &threeScaleTrait{ + BaseTrait: trait.NewBaseTrait("3scale", trait.TraitOrderPostProcessResources), + } +} + +func (t *threeScaleTrait) Configure(e *trait.Environment) (bool, error) { + if t.Enabled == nil || !*t.Enabled { + // disabled by default + return false, nil + } + + if !e.IntegrationInPhase(v1.IntegrationPhaseDeploying) { + return false, nil + } + + if t.Auto == nil || *t.Auto { + if t.Scheme == "" { + t.Scheme = ThreeScaleSchemeDefaultValue + } + if t.Path == "" { + t.Path = ThreeScalePathDefaultValue + } + if t.Port == 0 { + t.Port = ThreeScalePortDefaultValue + } + if t.DescriptionPath == nil { + openAPI := ThreeScaleDescriptionPathDefaultValue + t.DescriptionPath = &openAPI + } + } + return true, nil +} + +func (t *threeScaleTrait) Apply(e *trait.Environment) error { + if svc := e.Resources.GetServiceForIntegration(e.Integration); svc != nil { + t.addLabelsAndAnnotations(&svc.ObjectMeta) + } + return nil +} + +func (t *threeScaleTrait) addLabelsAndAnnotations(obj *metav1.ObjectMeta) { + if obj.Labels == nil { + obj.Labels = make(map[string]string) + } + obj.Labels[ThreeScaleDiscoveryLabel] = ThreeScaleDiscoveryLabelEnabled + + if obj.Annotations == nil { + obj.Annotations = make(map[string]string) + } + if t.Scheme != "" { + obj.Annotations[ThreeScaleSchemeAnnotation] = t.Scheme + } + if t.Path != "" { + obj.Annotations[ThreeScalePathAnnotation] = t.Path + } + if t.Port != 0 { + obj.Annotations[ThreeScalePortAnnotation] = strconv.Itoa(t.Port) + } + if t.DescriptionPath != nil && *t.DescriptionPath != "" { + obj.Annotations[ThreeScaleDescriptionPathAnnotation] = *t.DescriptionPath + } +} diff --git a/addons/threescale/3scale_test.go b/addons/threescale/3scale_test.go new file mode 100644 index 0000000000..2ac850623f --- /dev/null +++ b/addons/threescale/3scale_test.go @@ -0,0 +1,114 @@ +/* +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 threescale + +import ( + "testing" + + v1 "github.com/apache/camel-k/pkg/apis/camel/v1" + "github.com/apache/camel-k/pkg/trait" + "github.com/apache/camel-k/pkg/util/camel" + "github.com/apache/camel-k/pkg/util/kubernetes" + "github.com/stretchr/testify/assert" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +func TestThreeScaleDisabled(t *testing.T) { + catalog, err := camel.DefaultCatalog() + assert.Nil(t, err) + + e := &trait.Environment{ + CamelCatalog: catalog, + } + + threeScale := NewThreeScaleTrait() + enabled, err := threeScale.Configure(e) + assert.Nil(t, err) + assert.False(t, enabled) +} + +func TestThreeScaleInjection(t *testing.T) { + svc, e := createEnvironment(t) + threeScale := NewThreeScaleTrait() + enabled := true + threeScale.(*threeScaleTrait).Enabled = &enabled + ok, err := threeScale.Configure(e) + assert.Nil(t, err) + assert.True(t, ok) + + err = threeScale.Apply(e) + assert.Nil(t, err) + + assert.Equal(t, "true", svc.Labels["discovery.3scale.net"]) + assert.Equal(t, "http", svc.Annotations["discovery.3scale.net/scheme"]) + assert.Equal(t, "/", svc.Annotations["discovery.3scale.net/path"]) + assert.Equal(t, "80", svc.Annotations["discovery.3scale.net/port"]) + assert.Equal(t, "/api-doc", svc.Annotations["discovery.3scale.net/description-path"]) +} + +func TestThreeScaleInjectionNoAPIPath(t *testing.T) { + svc, e := createEnvironment(t) + threeScale := NewThreeScaleTrait() + enabled := true + threeScale.(*threeScaleTrait).Enabled = &enabled + noPath := "" + threeScale.(*threeScaleTrait).DescriptionPath = &noPath + ok, err := threeScale.Configure(e) + assert.Nil(t, err) + assert.True(t, ok) + + err = threeScale.Apply(e) + assert.Nil(t, err) + + assert.Equal(t, "true", svc.Labels["discovery.3scale.net"]) + assert.Equal(t, "http", svc.Annotations["discovery.3scale.net/scheme"]) + assert.Equal(t, "/", svc.Annotations["discovery.3scale.net/path"]) + assert.Equal(t, "80", svc.Annotations["discovery.3scale.net/port"]) + _, p := svc.Annotations["discovery.3scale.net/description-path"] + assert.False(t, p) +} + +func createEnvironment(t *testing.T) (*corev1.Service, *trait.Environment) { + catalog, err := camel.DefaultCatalog() + assert.Nil(t, err) + + e := trait.Environment{ + CamelCatalog: catalog, + } + + svc := corev1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{ + "camel.apache.org/integration": "test", + }, + }, + } + e.Resources = kubernetes.NewCollection(&svc) + + it := v1.Integration{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test", + }, + Status: v1.IntegrationStatus{ + Phase: v1.IntegrationPhaseDeploying, + }, + } + e.Integration = &it + return &svc, &e +} diff --git a/addons/threescale/zz_generated_doc.go b/addons/threescale/zz_generated_doc.go new file mode 100644 index 0000000000..38eec99ee5 --- /dev/null +++ b/addons/threescale/zz_generated_doc.go @@ -0,0 +1 @@ +package threescale diff --git a/build/maven/pom-runtime.xml b/build/maven/pom-runtime.xml index 0241670fce..741496fb38 100644 --- a/build/maven/pom-runtime.xml +++ b/build/maven/pom-runtime.xml @@ -108,6 +108,10 @@ com.oracle.substratevm * + + org.graalvm.nativeimage + * + @@ -119,6 +123,10 @@ com.oracle.substratevm * + + org.graalvm.nativeimage + * + @@ -130,6 +138,10 @@ com.oracle.substratevm * + + org.graalvm.nativeimage + * + @@ -141,6 +153,10 @@ com.oracle.substratevm * + + org.graalvm.nativeimage + * + @@ -152,6 +168,10 @@ com.oracle.substratevm * + + org.graalvm.nativeimage + * + @@ -163,6 +183,10 @@ com.oracle.substratevm * + + org.graalvm.nativeimage + * + @@ -174,6 +198,10 @@ com.oracle.substratevm * + + org.graalvm.nativeimage + * + @@ -185,6 +213,10 @@ com.oracle.substratevm * + + org.graalvm.nativeimage + * + @@ -196,6 +228,10 @@ com.oracle.substratevm * + + org.graalvm.nativeimage + * + diff --git a/deploy/resources.go b/deploy/resources.go index 4d1a34514f..48109236cd 100644 --- a/deploy/resources.go +++ b/deploy/resources.go @@ -214,6 +214,13 @@ var assets = func() http.FileSystem { compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x53\x4d\x6f\x9b\x40\x14\xbc\xef\xaf\x18\x99\x4b\x22\xf9\xa3\xed\xd1\x3d\xd1\xc4\x56\x51\x23\x5b\x0a\x4e\xa3\x1c\x9f\xe1\x19\x9e\x02\xfb\xe8\xee\x12\xe2\x7f\x5f\x2d\xb6\x9b\x44\xbd\x66\x6f\x88\x61\x3e\x76\x86\x04\xb3\xcf\x3b\x26\xc1\x9d\x14\x6c\x3d\x97\x08\x8a\x50\x33\xd2\x8e\x8a\x9a\x91\xeb\x21\x0c\xe4\x18\x6b\xed\x6d\x49\x41\xd4\xe2\x2a\xcd\xd7\xd7\xe8\x6d\xc9\x0e\x6a\x19\xea\xd0\xaa\x63\x93\xa0\x50\x1b\x9c\xec\xfb\xa0\x0e\xcd\x89\x10\x54\x39\xe6\x96\x6d\xf0\x73\x20\x67\x1e\xd9\x37\xdb\x5d\x76\xb3\xc2\x41\x1a\x46\x29\xfe\xf4\x11\x97\x18\x24\xd4\x26\x41\xa8\xc5\x63\x50\xf7\x8c\x83\x3a\x50\x59\x4a\x14\xa6\x06\x62\x0f\xea\xda\x93\x0d\xc7\x15\xb9\x52\x6c\x85\x42\xbb\xa3\x93\xaa\x0e\xd0\xc1\xb2\xf3\xb5\x74\x73\x93\x60\x17\x63\xe4\xeb\x8b\x13\x7f\xa2\x1d\x35\x83\xe2\x49\xfb\x73\x86\x77\x71\xcf\xb7\x30\xc5\x6f\x76\x3e\x8a\x7c\x9b\x7f\x31\x09\xae\x22\x64\x72\x7e\x39\xb9\xfe\x8e\xa3\xf6\x68\xe9\x08\xab\x01\xbd\xe7\x77\xcc\xfc\x5a\x70\x17\x20\x16\x85\xb6\x5d\x23\x64\x0b\x7e\x8b\xf5\x4f\x61\x8e\xd1\x40\xe4\xd0\x7d\x20\xb1\xa0\x31\x06\xf4\xf0\x1e\x06\x0a\x26\x31\x09\xc6\x53\x87\xd0\x2d\x17\x8b\x61\x18\xe6\x34\xda\x9d\xab\xab\x16\x97\x74\x8b\xbb\xec\x66\xb5\xc9\x57\xb3\xd1\xb2\x49\xf0\x60\x1b\xf6\x1e\x8e\xff\xf4\xe2\xb8\xc4\xfe\x08\xea\xba\x46\x0a\xda\x37\x8c\x86\x86\x58\xdc\xd8\xce\x58\xba\x58\x0c\x4e\x82\xd8\x6a\x0a\x7f\x6e\xdd\x24\x1f\xda\x79\xbb\xae\x8b\x3d\xf1\x1f\x00\x6a\x41\x16\x93\x34\x47\x96\x4f\xf0\x23\xcd\xb3\x7c\x6a\x12\x3c\x66\xbb\x9f\xdb\x87\x1d\x1e\xd3\xfb\xfb\x74\xb3\xcb\x56\x39\xb6\xf7\xb8\xd9\x6e\x6e\xb3\x5d\xb6\xdd\xe4\xd8\xae\x91\x6e\x9e\xf0\x2b\xdb\xdc\x4e\xc1\x12\x6a\x76\xe0\xd7\xce\x45\xff\xea\x20\xf1\x22\xb9\x8c\x9d\x5e\x06\x74\x31\x10\xf7\x11\x9f\x7d\xc7\x85\x1c\xa4\x40\x43\xb6\xea\xa9\x62\x54\xfa\xc2\xce\xc6\x79\x74\xec\x5a\xf1\xb1\x4e\x0f\xb2\xa5\x49\xd0\x48\x2b\x61\x5c\x91\xff\x3f\x54\x94\xf9\xcc\x7f\xcb\x50\x27\xe7\x39\x2d\xf1\xf2\xd5\x3c\x8b\x2d\x97\xc8\xd9\xbd\x48\xc1\x69\x51\x68\x6f\x83\x69\x39\x50\x49\x81\x96\x06\xb0\xd4\xf2\x12\x05\xb5\xdc\xcc\x9e\x67\xda\xb1\xa3\xa0\xce\x00\x0d\xed\xb9\xf1\x11\x82\x58\xe5\x12\x93\x33\x68\x62\xfe\x06\x00\x00\xff\xff\xaf\x8c\x67\xdd\x0f\x04\x00\x00"), }, + "/operator.yaml": &vfsgen۰CompressedFileInfo{ + name: "operator.yaml", + modTime: time.Time{}, + uncompressedSize: 2101, + + compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xbc\x54\xc1\x6e\xe3\x36\x10\xbd\xeb\x2b\x1e\xac\xcb\x2e\x10\xdb\x9b\x3d\xaa\x27\xd5\x71\xb0\x42\x53\xd9\xb0\xbc\x0d\xf6\x54\x4c\xa8\x91\x44\x84\x22\x55\x92\x8a\x56\x7f\x5f\x50\xb6\x13\x3b\xbb\x4d\x7b\x08\xca\x93\xa4\x99\x79\xf3\xde\xcc\x13\x63\xcc\xdf\xef\x44\x31\xee\xa4\x60\xed\xb8\x84\x37\xf0\x0d\x23\xed\x48\x34\x8c\xc2\x54\x7e\x20\xcb\xb8\x35\xbd\x2e\xc9\x4b\xa3\xf1\x21\x2d\x6e\x3f\xa2\xd7\x25\x5b\x18\xcd\x30\x16\xad\xb1\x1c\xc5\x10\x46\x7b\x2b\x1f\x7a\x6f\x2c\xd4\x01\x10\x54\x5b\xe6\x96\xb5\x77\x0b\xa0\x60\x9e\xd0\xf3\xcd\x3e\x5b\xad\x51\x49\xc5\x28\xa5\x3b\x14\x71\x89\x41\xfa\x26\x8a\xe1\x1b\xe9\x30\x18\xfb\x88\xca\x58\x50\x59\xca\xd0\x98\x14\xa4\xae\x8c\x6d\x0f\x34\x2c\xd7\x64\x4b\xa9\x6b\x08\xd3\x8d\x56\xd6\x8d\x87\x19\x34\x5b\xd7\xc8\x6e\x11\xc5\xd8\x07\x19\xc5\xed\x89\x89\x3b\xc0\x4e\x3d\xbd\xc1\x37\xd3\x1f\x35\x9c\xc9\x3d\x4e\xe1\x0a\x7f\xb0\x75\xa1\xc9\xe7\xc5\xa7\x28\xc6\x87\x90\x32\x3b\x06\x67\x1f\x7f\xc1\x68\x7a\xb4\x34\x42\x1b\x8f\xde\xf1\x19\x32\x7f\x17\xdc\x79\x48\x0d\x61\xda\x4e\x49\xd2\x82\x5f\x64\x3d\x77\x58\x60\x22\x10\x30\xcc\x83\x27\xa9\x41\x93\x0c\x98\xea\x3c\x0d\xe4\xa3\x38\x8a\x31\x9d\xc6\xfb\x2e\x59\x2e\x87\x61\x58\xd0\x44\x77\x61\x6c\xbd\x3c\xa9\x5b\xde\x65\xab\x75\x5e\xac\xe7\x13\xe5\x28\xc6\x57\xad\xd8\x39\x58\xfe\xab\x97\x96\x4b\x3c\x8c\xa0\xae\x53\x52\xd0\x83\x62\x28\x1a\xc2\xe2\xa6\xed\x4c\x4b\x97\x1a\x83\x95\x5e\xea\xfa\x0a\xee\xb8\xf5\x28\xbe\xd8\xce\xcb\xb8\x4e\xf4\xa4\xbb\x48\x30\x1a\xa4\x31\x4b\x0b\x64\xc5\x0c\xbf\xa6\x45\x56\x5c\x45\x31\xee\xb3\xfd\x97\xcd\xd7\x3d\xee\xd3\xdd\x2e\xcd\xf7\xd9\xba\xc0\x66\x87\xd5\x26\xbf\xc9\xf6\xd9\x26\x2f\xb0\xb9\x45\x9a\x7f\xc3\x6f\x59\x7e\x73\x05\x96\xbe\x61\x0b\xfe\xde\xd9\xc0\xdf\x58\xc8\x30\x48\x2e\xc3\x4e\x4f\x06\x3a\x11\x08\xfe\x08\xef\xae\x63\x21\x2b\x29\xa0\x48\xd7\x3d\xd5\x8c\xda\x3c\xb1\xd5\xc1\x1e\x1d\xdb\x56\xba\xb0\x4e\x07\xd2\x65\x14\x43\xc9\x56\xfa\xc9\x45\xee\x47\x51\xa1\xcd\x7b\xfe\x5b\x11\x75\xf2\x68\xa7\x24\x6c\xc0\x2d\x9f\xae\xa3\x47\xa9\xcb\x04\x37\xdc\x29\x33\x86\x9f\x23\x6a\xd9\x53\x49\x9e\x92\x08\xd0\xd4\x72\x02\x41\x2d\xab\xf9\xe3\xdc\x74\x6c\xc9\x1b\x1b\x01\x8a\x1e\x58\xb9\x90\x82\x80\x94\x60\x76\x4c\x9a\x4d\x9f\xa6\x97\x73\x6f\x04\x0b\x1a\xcd\xda\x27\x78\x46\x09\x93\x0a\x08\x96\x27\x2f\xb8\x04\xd7\x11\xe0\xbc\x25\xcf\xf5\x78\xc0\xf6\x63\xc7\x09\x76\x2c\x2c\x93\xe7\x10\x66\xc5\xc2\x1b\x7b\x08\xb7\xe4\x45\x73\x77\xc6\xe5\x0d\xca\x9e\xdb\x4e\x91\xe7\x63\xe5\x99\xca\x70\xd4\x05\xc8\x1b\x30\x87\xf3\x9f\x04\x86\xc4\x93\xc8\xe9\x99\xed\x93\x14\x9c\x0a\x61\x7a\xed\xf3\xb7\x3a\x84\xfb\x8b\x64\xb8\x42\x5e\x28\xcd\xff\x8d\x14\x20\x5b\xaa\x39\x41\x69\xc4\x23\xdb\x85\x34\xcb\x03\xc3\xe5\xb1\x24\xb9\x5e\x7c\x5a\x7c\x9a\xef\x56\x9f\xcf\x6a\x84\x69\x5b\xd2\x65\x72\xf6\x69\x7e\xea\xf1\x1a\x7a\xdb\x2b\xb5\x35\x4a\x8a\x31\x41\x56\xe5\xc6\x6f\x2d\xbb\x60\x9a\x97\x3c\xd6\x4f\xe7\x50\x2f\xb4\xef\xd3\xfd\xea\xcb\x9f\x79\xfa\xfb\xba\xd8\xa6\xab\xf5\x45\x0e\xf0\x44\xaa\xe7\x5b\x6b\xda\xe4\x55\x00\xa8\x24\xab\x72\xc7\xd5\x8f\x91\x63\x6c\x4b\xbe\x49\x9e\x37\xba\x08\xed\x5c\x47\x82\x7f\x4a\x63\xb3\x5d\xef\xd2\xfd\x66\x37\x31\xf9\x19\x89\xd7\x5e\x7e\x0d\xb0\xdd\xdc\xfc\x63\xed\xfb\x09\xb8\x48\x8d\xf1\x3c\xb6\x70\xd1\x91\x1a\x68\x74\xd3\x4d\x71\xf2\x00\x9e\x45\x5f\x41\xea\x92\x3b\xd6\x25\x6b\xaf\x46\x54\xd6\xb4\x6f\xce\xfe\xa4\xeb\x7f\xdd\xcc\xdf\x01\x00\x00\xff\xff\x61\x8c\x0a\x1b\x35\x08\x00\x00"), + }, "/platform-cr.yaml": &vfsgen۰CompressedFileInfo{ name: "platform-cr.yaml", modTime: time.Time{}, @@ -362,6 +369,7 @@ var assets = func() http.FileSystem { fs["/operator-role-olm.yaml"].(os.FileInfo), fs["/operator-role-openshift.yaml"].(os.FileInfo), fs["/operator-service-account.yaml"].(os.FileInfo), + fs["/operator.yaml"].(os.FileInfo), fs["/platform-cr.yaml"].(os.FileInfo), fs["/platform-integration-kit-groovy.yaml"].(os.FileInfo), fs["/platform-integration-kit-java.yaml"].(os.FileInfo), diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index 9a7f96bb1c..9d9daa5d80 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -16,6 +16,7 @@ ** xref:configuration/configmap-secret.adoc[ConfigMap/Secret] * xref:traits/traits.adoc[Traits] // Start of autogenerated code - DO NOT EDIT! (trait-nav) +** xref:traits/3scale.adoc[3scale] ** xref:traits/affinity.adoc[Affinity] ** xref:traits/builder.adoc[Builder] ** xref:traits/camel.adoc[Camel] @@ -33,12 +34,12 @@ ** xref:traits/knative-service.adoc[Knative Service] ** xref:traits/knative.adoc[Knative] ** xref:traits/master.adoc[Master] +** xref:traits/openapi.adoc[Openapi] ** xref:traits/owner.adoc[Owner] ** xref:traits/platform.adoc[Platform] ** xref:traits/prometheus.adoc[Prometheus] ** xref:traits/pull-secret.adoc[Pull Secret] ** xref:traits/quarkus.adoc[Quarkus] -** 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/3scale.adoc b/docs/modules/ROOT/pages/traits/3scale.adoc new file mode 100755 index 0000000000..ff11f2c466 --- /dev/null +++ b/docs/modules/ROOT/pages/traits/3scale.adoc @@ -0,0 +1,52 @@ += 3scale Trait + +// Start of autogenerated code - DO NOT EDIT! (description) +The 3scale trait can be used to automatically create annotations that allow +3scale to discover the generated service and make it available for API management. + +The 3scale trait is disabled by default. + + +This trait is available in the following profiles: **Kubernetes, Knative, OpenShift**. + +// 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 3scale.[key]=[value] --trait 3scale.[key2]=[value2] integration.groovy +``` +The following configuration options are available: + +[cols="2,1,5a"] +|=== +|Property | Type | Description + +| 3scale.enabled +| bool +| Can be used to enable or disable a trait. All traits share this common property. + +| 3scale.auto +| bool +| Enables automatic configuration of the trait. + +| 3scale.scheme +| string +| The scheme to use to contact the service (default `http`) + +| 3scale.path +| string +| The path where the API is published (default `/`) + +| 3scale.port +| int +| The port where the service is exposed (default `80`) + +| 3scale.description-path +| string +| The path where the Open-API specification is published (default `/api-doc`) + +|=== + +// End of autogenerated code - DO NOT EDIT! (configuration) diff --git a/docs/modules/ROOT/pages/traits/container.adoc b/docs/modules/ROOT/pages/traits/container.adoc index 1f982447d9..95edc4124b 100755 --- a/docs/modules/ROOT/pages/traits/container.adoc +++ b/docs/modules/ROOT/pages/traits/container.adoc @@ -72,6 +72,65 @@ The following configuration options are available: | string | The main container name. It's named `integration` by default. +| container.probes-enabled +| bool +| ProbesEnabled enable/disable probes on the container (default `false`) + +| container.probe-port +| int +| ProbePort configures the port on which the probes are exposed, by default it inhierit the +value from the `http` port configured on the container. Note that the value has no effect for Knative service +as the port should be the same as the port declared by the container. + +| container.probe-path +| string +| Path to access on the probe ( default `/health`). Note that this property is not supported +on quarkus runtime and setting it will result in the integration failing to start. + +| container.liveness-initial-delay +| int32 +| Number of seconds after the container has started before liveness probes are initiated. + +| container.liveness-timeout +| int32 +| Number of seconds after which the probe times out. Applies to the liveness probe. + +| container.liveness-period +| int32 +| How often to perform the probe. Applies to the liveness probe. + +| container.liveness-success-threshold +| int32 +| Minimum consecutive successes for the probe to be considered successful after having failed. +Applies to the liveness probe. + +| container.liveness-failure-threshold +| int32 +| Minimum consecutive failures for the probe to be considered failed after having succeeded. +Applies to the liveness probe. + +| container.readiness-initial-delay +| int32 +| Number of seconds after the container has started before readiness probes are initiated. + +| container.readiness-timeout +| int32 +| Number of seconds after which the probe times out. Applies to the readiness probe. + +| container.readiness-period +| int32 +| How often to perform the probe. Applies to the readiness probe. + +| container.readiness-success-threshold +| int32 +| Minimum consecutive successes for the probe to be considered successful after having failed. +Applies to the readiness probe. + +| container.readiness-failure-threshold +| int32 +| Minimum consecutive failures for the probe to be considered failed after having succeeded. +Applies to the readiness probe. + |=== // End of autogenerated code - DO NOT EDIT! (configuration) diff --git a/docs/modules/ROOT/pages/traits/openapi.adoc b/docs/modules/ROOT/pages/traits/openapi.adoc index e3fe189890..b8d919c109 100755 --- a/docs/modules/ROOT/pages/traits/openapi.adoc +++ b/docs/modules/ROOT/pages/traits/openapi.adoc @@ -1,7 +1,7 @@ = Rest Dsl Trait // Start of autogenerated code - DO NOT EDIT! (description) -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. This trait is available in the following profiles: **Kubernetes, Knative, OpenShift**. @@ -22,7 +22,7 @@ The following configuration options are available: |=== |Property | Type | Description -| rest-dsl.enabled +| openapi.enabled | bool | Can be used to enable or disable a trait. All traits share this common property. diff --git a/docs/modules/ROOT/pages/traits/traits.adoc b/docs/modules/ROOT/pages/traits/traits.adoc index fac82b1f97..e2e663ce40 100644 --- a/docs/modules/ROOT/pages/traits/traits.adoc +++ b/docs/modules/ROOT/pages/traits/traits.adoc @@ -34,6 +34,7 @@ A trait may have additional properties that can be configured by the end user. See the trait description pages for more information on a specific trait: // Start of autogenerated code - DO NOT EDIT! (trait-list) +* xref:traits/3scale.adoc[3scale Trait] * xref:traits/affinity.adoc[Affinity Trait] * xref:traits/builder.adoc[Builder Trait] * xref:traits/camel.adoc[Camel Trait] @@ -51,12 +52,12 @@ See the trait description pages for more information on a specific trait: * xref:traits/knative-service.adoc[Knative Service Trait] * xref:traits/knative.adoc[Knative Trait] * xref:traits/master.adoc[Master Trait] +* xref:traits/openapi.adoc[Openapi Trait] * xref:traits/owner.adoc[Owner Trait] * xref:traits/platform.adoc[Platform Trait] * xref:traits/prometheus.adoc[Prometheus Trait] * xref:traits/pull-secret.adoc[Pull Secret Trait] * xref:traits/quarkus.adoc[Quarkus 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/cmd/run.go b/pkg/cmd/run.go index 918c694e58..5329c0dd8a 100644 --- a/pkg/cmd/run.go +++ b/pkg/cmd/run.go @@ -50,7 +50,7 @@ import ( ) var ( - traitConfigRegexp = regexp.MustCompile(`^([a-z-]+)((?:\.[a-z-]+)+)=(.*)$`) + traitConfigRegexp = regexp.MustCompile(`^([a-z0-9-]+)((?:\.[a-z0-9-]+)+)=(.*)$`) ) func newCmdRun(rootCmdOptions *RootCmdOptions) (*cobra.Command, *runCmdOptions) {