You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2025/09/19 07:04:07 UTC
(camel-k) branch main updated: feat: remove deprecations from 2.5
This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/main by this push:
new 784bc84df feat: remove deprecations from 2.5
784bc84df is described below
commit 784bc84df0a2c5562882d58405b87ac88cce5a5e
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Wed Sep 17 20:59:44 2025 +0200
feat: remove deprecations from 2.5
---
addons/register_3scale.go | 27 --
addons/register_aws_secrets.go | 27 --
addons/register_azure_key_vault.go | 27 --
addons/register_gcp_secrets.go | 27 --
addons/register_hashicorp_vault.go | 27 --
addons/register_resume.go | 27 --
addons/resume/resume.go | 130 --------
addons/resume/zz_desc_generated.go | 1 -
addons/resume/zz_generated_doc.go | 1 -
addons/threescale/3scale.go | 155 ---------
addons/threescale/3scale_test.go | 120 -------
addons/threescale/zz_desc_generated.go | 1 -
addons/threescale/zz_generated_doc.go | 1 -
addons/vault/aws/aws_secrets_manager.go | 160 ---------
addons/vault/aws/aws_secrets_manager_test.go | 197 -----------
addons/vault/aws/client_test.go | 299 -----------------
addons/vault/aws/zz_desc_generated.go | 1 -
addons/vault/aws/zz_generated_doc.go | 1 -
addons/vault/azure/azure_key_vault.go | 178 ----------
addons/vault/azure/azure_key_vault_test.go | 234 --------------
addons/vault/azure/client_test.go | 299 -----------------
addons/vault/azure/zz_desc_generated.go | 1 -
addons/vault/azure/zz_generated_doc.go | 1 -
addons/vault/gcp/gcp_secret_manager.go | 134 --------
addons/vault/gcp/gcp_secret_manager_test.go | 99 ------
addons/vault/gcp/zz_desc_generated.go | 1 -
addons/vault/gcp/zz_generated_doc.go | 1 -
addons/vault/hashicorp/client_test.go | 299 -----------------
addons/vault/hashicorp/hashicorp_vault.go | 124 -------
addons/vault/hashicorp/hashicorp_vault_test.go | 162 ----------
docs/modules/ROOT/nav.adoc | 7 -
docs/modules/ROOT/pages/languages/groovy.adoc | 195 -----------
docs/modules/ROOT/partials/apis/camel-k-crds.adoc | 2 +
e2e/advanced/kamelet_repo_test.go | 17 +-
e2e/common/cli/config_test.go | 70 ----
e2e/common/cli/describe_test.go | 74 -----
e2e/common/languages/groovy_test.go | 47 ---
e2e/common/traits/openapi_test.go | 71 ----
e2e/knative/openapi_test.go | 31 --
e2e/native/files/Groovy.groovy | 21 --
pkg/apis/camel/v1/common_types.go | 16 -
.../camel/v1/integration_types_support_test.go | 7 +-
pkg/apis/camel/v1/trait/openapi.go | 4 +-
pkg/cmd/completion_bash.go | 2 +-
pkg/cmd/config.go | 164 ----------
pkg/cmd/config_test.go | 133 --------
pkg/cmd/describe.go | 90 ------
pkg/cmd/describe_integration.go | 183 -----------
pkg/cmd/describe_kamelet.go | 181 -----------
pkg/cmd/describe_kit.go | 138 --------
pkg/cmd/describe_platform.go | 125 -------
pkg/cmd/kamelet.go | 38 ---
pkg/cmd/kamelet_add_repo.go | 149 ---------
pkg/cmd/kamelet_add_repo_test.go | 89 -----
pkg/cmd/kamelet_delete.go | 140 --------
pkg/cmd/kamelet_get.go | 135 --------
pkg/cmd/kamelet_remove_repo.go | 99 ------
pkg/cmd/kamelet_remove_repo_test.go | 86 -----
pkg/cmd/modeline_test.go | 34 +-
pkg/cmd/root.go | 3 -
pkg/cmd/util_config.go | 5 -
pkg/controller/integration/kits_test.go | 22 +-
pkg/metadata/metadata_dependencies_test.go | 151 +--------
pkg/metadata/metadata_http_test.go | 60 +---
pkg/metadata/metadata_uri_test.go | 132 --------
pkg/trait/kamelets_support_test.go | 36 +--
pkg/trait/kamelets_test.go | 20 +-
pkg/trait/knative_service_test.go | 38 +--
pkg/trait/knative_test.go | 54 ++--
pkg/trait/mount_test.go | 6 +-
pkg/trait/openapi.go | 339 -------------------
pkg/trait/openapi_test.go | 359 ---------------------
pkg/trait/quarkus_test.go | 41 +--
pkg/trait/service_test.go | 38 +--
pkg/trait/trait_register.go | 1 -
pkg/trait/trait_test.go | 28 +-
pkg/trait/trait_types_test.go | 6 +-
pkg/util/camel/camel_runtime_catalog_test.go | 6 -
pkg/util/digest/digest.go | 29 --
pkg/util/indentedwriter/writer.go | 66 ----
pkg/util/kubernetes/sanitize_test.go | 2 +-
pkg/util/modeline/parser_test.go | 52 ---
pkg/util/source/inspector.go | 31 --
pkg/util/source/inspector_groovy.go | 93 ------
pkg/util/source/inspector_groovy_test.go | 223 -------------
pkg/util/source/inspector_java_script.go | 63 ----
pkg/util/source/inspector_java_script_test.go | 205 ------------
pkg/util/source/inspector_java_source.go | 18 +-
pkg/util/source/inspector_kotlin.go | 57 ----
pkg/util/source/inspector_kotlin_test.go | 191 -----------
script/check_licenses.sh | 3 -
91 files changed, 197 insertions(+), 7291 deletions(-)
diff --git a/addons/register_3scale.go b/addons/register_3scale.go
deleted file mode 100644
index 0287b42e2..000000000
--- a/addons/register_3scale.go
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-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/v2/addons/threescale"
- "github.com/apache/camel-k/v2/pkg/trait"
-)
-
-func init() {
- trait.AddToTraits(threescale.NewThreeScaleTrait)
-}
diff --git a/addons/register_aws_secrets.go b/addons/register_aws_secrets.go
deleted file mode 100644
index f7de941ad..000000000
--- a/addons/register_aws_secrets.go
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-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/v2/addons/vault/aws"
- "github.com/apache/camel-k/v2/pkg/trait"
-)
-
-func init() {
- trait.AddToTraits(aws.NewAwsSecretsManagerTrait)
-}
diff --git a/addons/register_azure_key_vault.go b/addons/register_azure_key_vault.go
deleted file mode 100644
index af02c782e..000000000
--- a/addons/register_azure_key_vault.go
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-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/v2/addons/vault/azure"
- "github.com/apache/camel-k/v2/pkg/trait"
-)
-
-func init() {
- trait.AddToTraits(azure.NewAzureKeyVaultTrait)
-}
diff --git a/addons/register_gcp_secrets.go b/addons/register_gcp_secrets.go
deleted file mode 100644
index 148dbabc0..000000000
--- a/addons/register_gcp_secrets.go
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-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/v2/addons/vault/gcp"
- "github.com/apache/camel-k/v2/pkg/trait"
-)
-
-func init() {
- trait.AddToTraits(gcp.NewGcpSecretManagerTrait)
-}
diff --git a/addons/register_hashicorp_vault.go b/addons/register_hashicorp_vault.go
deleted file mode 100644
index a777627de..000000000
--- a/addons/register_hashicorp_vault.go
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-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/v2/addons/vault/hashicorp"
- "github.com/apache/camel-k/v2/pkg/trait"
-)
-
-func init() {
- trait.AddToTraits(hashicorp.NewHashicorpVaultTrait)
-}
diff --git a/addons/register_resume.go b/addons/register_resume.go
deleted file mode 100644
index 9ededdec4..000000000
--- a/addons/register_resume.go
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-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/v2/addons/resume"
- "github.com/apache/camel-k/v2/pkg/trait"
-)
-
-func init() {
- trait.AddToTraits(resume.NewResumeTrait)
-}
diff --git a/addons/resume/resume.go b/addons/resume/resume.go
deleted file mode 100644
index 749353532..000000000
--- a/addons/resume/resume.go
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
-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 resume
-
-import (
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- traitv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1/trait"
- "github.com/apache/camel-k/v2/pkg/trait"
- "github.com/apache/camel-k/v2/pkg/util"
- corev1 "k8s.io/api/core/v1"
- "k8s.io/utils/ptr"
-)
-
-// The Resume trait can be used to manage and configure resume strategies.
-//
-// This feature is meant to allow quick resume of processing by Camel K instances after they have been restarted.
-//
-// WARNING: this is an experimental implementation based on the support available on link:/components/next/eips/resume-strategies.html[Camel Core resume strategies].
-//
-// The Resume trait is disabled by default.
-//
-// WARNING: The trait is **deprecated** and will removed in future release versions: configure directly the Camel properties as required by the component instead.
-//
-// The main different from the implementation on Core is that it's not necessary to bind the strategies to the
-// registry. This step will be done automatically by Camel K, after resolving the options passed to the trait.
-//
-// A sample execution of this trait, using the Kafka backend (the only one supported at the moment), would require
-// the following trait options:
-// -t resume.enabled=true -t resume.resume-path=camel-file-sets -t resume.resume-server="address-of-your-kafka:9092"
-//
-// +camel-k:trait=resume.
-// +camel-k:deprecated=2.5.0.
-type Trait struct {
- traitv1.Trait `property:",squash"`
- // Enables automatic configuration of the trait.
- // Deprecated: not in use.
- Auto *bool `property:"auto" json:"auto,omitempty"`
- // The type of the resume strategy to use
- ResumeStrategy string `property:"resume-strategy,omitempty"`
- // The path used by the resume strategy (this is specific to the resume strategy type)
- ResumePath string `property:"resume-path,omitempty"`
- // The address of the resume server to use (protocol / implementation specific)
- ResumeServer string `property:"resume-server,omitempty"`
- // The adapter-specific policy to use when filling the cache (use: minimizing / maximizing). Check
- // the component documentation if unsure
- CacheFillPolicy string `property:"cache-fill-policy,omitempty"`
-}
-
-type resumeTrait struct {
- trait.BaseTrait
- Trait `property:",squash"`
-}
-
-const (
- kafkaSingle = "org.apache.camel.processor.resume.kafka.SingleNodeKafkaResumeStrategy"
- strategyPath = "camel-k-offsets"
-)
-
-func NewResumeTrait() trait.Trait {
- return &resumeTrait{
- BaseTrait: trait.NewBaseTrait("resume", trait.TraitOrderBeforeControllerCreation),
- }
-}
-
-func (r *resumeTrait) Configure(environment *trait.Environment) (bool, *trait.TraitCondition, error) {
- if !ptr.Deref(r.Enabled, false) {
- return false, nil, nil
- }
- if !environment.IntegrationInPhase(v1.IntegrationPhaseInitialization) && !environment.IntegrationInRunningPhases() {
- return false, nil, nil
- }
-
- condition := trait.NewIntegrationCondition(
- "Resume",
- v1.IntegrationConditionTraitInfo,
- corev1.ConditionTrue,
- trait.TraitConfigurationReason,
- "Resume trait is deprecated and may be removed in future version: "+
- "configure directly the Camel properties as required by the component instead",
- )
-
- return ptr.Deref(r.Enabled, false), condition, nil
-}
-
-func (r *resumeTrait) Apply(environment *trait.Environment) error {
- if environment.IntegrationInPhase(v1.IntegrationPhaseInitialization) {
- util.StringSliceUniqueAdd(&environment.Integration.Status.Capabilities, v1.CapabilityResumeKafka)
- }
-
- if environment.IntegrationInRunningPhases() {
- environment.ApplicationProperties["customizer.resume.enabled"] = "true"
- environment.ApplicationProperties["customizer.resume.resumeStrategy"] = r.getResumeStrategy()
- environment.ApplicationProperties["customizer.resume.resumePath"] = r.getResumePath()
- environment.ApplicationProperties["customizer.resume.resumeServer"] = r.ResumeServer
- environment.ApplicationProperties["customizer.resume.cacheFillPolicy"] = r.CacheFillPolicy
- }
-
- return nil
-}
-
-func (r *resumeTrait) getResumeStrategy() string {
- if r.ResumeStrategy == "" {
- return kafkaSingle
- }
-
- return r.ResumeStrategy
-}
-
-func (r *resumeTrait) getResumePath() string {
- if r.ResumePath == "" {
- return strategyPath
- }
-
- return r.ResumePath
-}
diff --git a/addons/resume/zz_desc_generated.go b/addons/resume/zz_desc_generated.go
deleted file mode 100644
index cfb741edf..000000000
--- a/addons/resume/zz_desc_generated.go
+++ /dev/null
@@ -1 +0,0 @@
-package resume
diff --git a/addons/resume/zz_generated_doc.go b/addons/resume/zz_generated_doc.go
deleted file mode 100644
index cfb741edf..000000000
--- a/addons/resume/zz_generated_doc.go
+++ /dev/null
@@ -1 +0,0 @@
-package resume
diff --git a/addons/threescale/3scale.go b/addons/threescale/3scale.go
deleted file mode 100644
index d15faa09f..000000000
--- a/addons/threescale/3scale.go
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
-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"
-
- corev1 "k8s.io/api/core/v1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- "k8s.io/utils/ptr"
-
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- traitv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1/trait"
- "github.com/apache/camel-k/v2/pkg/trait"
-)
-
-// 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.
-//
-// WARNING: The trait is **deprecated** and will removed in future release versions: configure directly the Camel properties as required by the component instead.
-//
-// +camel-k:trait=3scale.
-// +camel-k:deprecated=2.5.0.
-type Trait struct {
- traitv1.Trait `property:",squash" json:",inline"`
- // Enables automatic configuration of the trait.
- Auto *bool `property:"auto" json:"auto,omitempty"`
- // The scheme to use to contact the service (default `http`)
- Scheme string `property:"scheme" json:"scheme,omitempty"`
- // The path where the API is published (default `/`)
- Path string `property:"path" json:"path,omitempty"`
- // The port where the service is exposed (default `80`)
- Port int `property:"port" json:"port,omitempty"`
- // The path where the Open-API specification is published (default `/openapi.json`)
- DescriptionPath *string `property:"description-path" json:"descriptionPath,omitempty"`
-}
-
-type threeScaleTrait struct {
- trait.BaseTrait
- Trait `property:",squash"`
-}
-
-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 = "/openapi.json"
-
- // 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, *trait.TraitCondition, error) {
- if e.Integration == nil || !ptr.Deref(t.Enabled, false) {
- return false, nil, nil
- }
- if !e.IntegrationInRunningPhases() {
- return false, nil, nil
- }
-
- condition := trait.NewIntegrationCondition(
- "3Scale",
- v1.IntegrationConditionTraitInfo,
- corev1.ConditionTrue,
- trait.TraitConfigurationReason,
- "3Scale trait is deprecated and may be removed in future version: "+
- "use service trait to add 3Scale labels and annotations instead",
- )
-
- if ptr.Deref(t.Auto, true) {
- 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, condition, 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 t.Scheme != "" {
- v1.SetAnnotation(obj, ThreeScaleSchemeAnnotation, t.Scheme)
- }
- if t.Path != "" {
- v1.SetAnnotation(obj, ThreeScalePathAnnotation, t.Path)
- }
- if t.Port != 0 {
- v1.SetAnnotation(obj, ThreeScalePortAnnotation, strconv.Itoa(t.Port))
- }
- if t.DescriptionPath != nil && *t.DescriptionPath != "" {
- v1.SetAnnotation(obj, ThreeScaleDescriptionPathAnnotation, *t.DescriptionPath)
- }
-}
diff --git a/addons/threescale/3scale_test.go b/addons/threescale/3scale_test.go
deleted file mode 100644
index 0954e2745..000000000
--- a/addons/threescale/3scale_test.go
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
-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/v2/pkg/apis/camel/v1"
- "github.com/apache/camel-k/v2/pkg/trait"
- "github.com/apache/camel-k/v2/pkg/util/camel"
- "github.com/apache/camel-k/v2/pkg/util/kubernetes"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
- corev1 "k8s.io/api/core/v1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- "k8s.io/utils/ptr"
-)
-
-func TestThreeScaleDisabled(t *testing.T) {
- catalog, err := camel.DefaultCatalog()
- require.NoError(t, err)
-
- e := &trait.Environment{
- CamelCatalog: catalog,
- }
-
- threeScale := NewThreeScaleTrait()
- enabled, condition, err := threeScale.Configure(e)
- require.NoError(t, err)
- assert.False(t, enabled)
- assert.Nil(t, condition)
-}
-
-func TestThreeScaleInjection(t *testing.T) {
- svc, e := createEnvironment(t)
- threeScale := NewThreeScaleTrait()
- tst, _ := threeScale.(*threeScaleTrait)
- tst.Enabled = ptr.To(true)
- ok, condition, err := threeScale.Configure(e)
- require.NoError(t, err)
- assert.True(t, ok)
- assert.NotNil(t, condition)
-
- err = threeScale.Apply(e)
- require.NoError(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, "/openapi.json", svc.Annotations["discovery.3scale.net/description-path"])
-}
-
-func TestThreeScaleInjectionNoAPIPath(t *testing.T) {
- svc, e := createEnvironment(t)
- threeScale := NewThreeScaleTrait()
- tst, _ := threeScale.(*threeScaleTrait)
- tst.Enabled = ptr.To(true)
- tst.DescriptionPath = ptr.To("")
- ok, condition, err := threeScale.Configure(e)
- require.NoError(t, err)
- assert.True(t, ok)
- assert.NotNil(t, condition)
-
- err = threeScale.Apply(e)
- require.NoError(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) {
- t.Helper()
-
- catalog, err := camel.DefaultCatalog()
- require.NoError(t, err)
-
- e := trait.Environment{
- CamelCatalog: catalog,
- }
-
- svc := corev1.Service{
- ObjectMeta: metav1.ObjectMeta{
- Labels: map[string]string{
- v1.IntegrationLabel: "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_desc_generated.go b/addons/threescale/zz_desc_generated.go
deleted file mode 100644
index 38eec99ee..000000000
--- a/addons/threescale/zz_desc_generated.go
+++ /dev/null
@@ -1 +0,0 @@
-package threescale
diff --git a/addons/threescale/zz_generated_doc.go b/addons/threescale/zz_generated_doc.go
deleted file mode 100644
index 38eec99ee..000000000
--- a/addons/threescale/zz_generated_doc.go
+++ /dev/null
@@ -1 +0,0 @@
-package threescale
diff --git a/addons/vault/aws/aws_secrets_manager.go b/addons/vault/aws/aws_secrets_manager.go
deleted file mode 100644
index 139d8618e..000000000
--- a/addons/vault/aws/aws_secrets_manager.go
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
-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 aws
-
-import (
- "strconv"
-
- "github.com/apache/camel-k/v2/pkg/util/kubernetes"
-
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- traitv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1/trait"
- "github.com/apache/camel-k/v2/pkg/trait"
- "github.com/apache/camel-k/v2/pkg/util"
- corev1 "k8s.io/api/core/v1"
- "k8s.io/utils/ptr"
-)
-
-// The Secrets Manager trait can be used to use secrets from AWS Secrets Manager
-//
-// The AWS Secrets Manager trait is disabled by default.
-//
-// For more information about how to use secrets from AWS Secrets Manager take a look at the components docs: xref:components::aws-secrets-manager-component.adoc[AWS Secrets Manager component]
-//
-// A sample execution of this trait, would require
-// the following trait options:
-// -t aws-secrets-manager.enabled=true -t aws-secrets-manager.access-key="aws-access-key" -t aws-secrets-manager.secret-key="aws-secret-key" -t aws-secrets-manager.region="aws-region"
-//
-// To enable the automatic context reload on secrets updates you should define
-// the following trait options:
-// -t aws-secrets-manager.enabled=true -t aws-secrets-manager.access-key="aws-access-key" -t aws-secrets-manager.secret-key="aws-secret-key" -t aws-secrets-manager.region="aws-region" -t aws-secrets-manager.context-reload-enabled="true" -t aws-secrets-manager.refresh-enabled="true" -t aws-secrets-manager.refresh-period="30000" -t aws-secrets-manager.secrets="test*"
-//
-// WARNING: The trait is **deprecated** and will removed in future release versions: configure directly the Camel properties as required by the component instead.
-//
-// +camel-k:trait=aws-secrets-manager.
-// +camel-k:deprecated=2.5.0.
-type Trait struct {
- traitv1.Trait `property:",squash"`
- // Enables automatic configuration of the trait.
- Auto *bool `property:"auto" json:"auto,omitempty"`
- // The AWS Access Key to use. This could be a plain text or a configmap/secret
- // The content of the aws access key is expected to be a text containing a valid AWS access key.
- // Syntax: [configmap|secret]:name[/key], where name represents the resource name, key optionally represents the resource key to be filtered (default key value = aws-access-key).
- AccessKey string `property:"access-key" json:"accessKey,omitempty"`
- // The AWS Secret Key to use. This could be a plain text or a configmap/secret
- // The content of the aws secret key is expected to be a text containing a valid AWS secret key.
- // Syntax: [configmap|secret]:name[/key], where name represents the resource name, key optionally represents the resource key to be filtered (default key value = aws-secret-key).
- SecretKey string `property:"secret-key" json:"secretKey,omitempty"`
- // The AWS Region to use
- Region string `property:"region" json:"region,omitempty"`
- // Define if we want to use the Default Credentials Provider chain as authentication method
- UseDefaultCredentialsProvider *bool `property:"use-default-credentials-provider" json:"useDefaultCredentialsProvider,omitempty"`
- // Define if we want to use the Camel Context Reload feature or not
- ContextReloadEnabled *bool `property:"context-reload-enabled" json:"contextReloadEnabled,omitempty"`
- // Define if we want to use the Refresh Feature for secrets
- RefreshEnabled *bool `property:"refresh-enabled" json:"refreshEnabled,omitempty"`
- // If Refresh is enabled, this defines the interval to check the refresh event
- RefreshPeriod string `property:"refresh-period" json:"refreshPeriod,omitempty"`
- // If Refresh is enabled, the regular expression representing the secrets we want to track
- Secrets string `property:"secrets" json:"secrets,omitempty"`
-}
-
-type awsSecretsManagerTrait struct {
- trait.BaseTrait
- Trait `property:",squash"`
-}
-
-func NewAwsSecretsManagerTrait() trait.Trait {
- return &awsSecretsManagerTrait{
- BaseTrait: trait.NewBaseTrait("aws-secrets-manager", trait.TraitOrderBeforeControllerCreation),
- }
-}
-
-func (t *awsSecretsManagerTrait) Configure(environment *trait.Environment) (bool, *trait.TraitCondition, error) {
- if environment.Integration == nil || !ptr.Deref(t.Enabled, false) {
- return false, nil, nil
- }
-
- if !environment.IntegrationInPhase(v1.IntegrationPhaseInitialization) && !environment.IntegrationInRunningPhases() {
- return false, nil, nil
- }
-
- if t.UseDefaultCredentialsProvider == nil {
- t.UseDefaultCredentialsProvider = ptr.To(false)
- }
- if t.ContextReloadEnabled == nil {
- t.ContextReloadEnabled = ptr.To(false)
- }
- if t.RefreshEnabled == nil {
- t.RefreshEnabled = ptr.To(false)
- }
-
- condition := trait.NewIntegrationCondition(
- "AWSSecretManager",
- v1.IntegrationConditionTraitInfo,
- corev1.ConditionTrue,
- trait.TraitConfigurationReason,
- "AWSSecretManager trait is deprecated and may be removed in future version: "+
- "configure directly the Camel properties as required by the component instead",
- )
-
- return true, condition, nil
-}
-
-func (t *awsSecretsManagerTrait) Apply(environment *trait.Environment) error {
- if environment.IntegrationInPhase(v1.IntegrationPhaseInitialization) {
- util.StringSliceUniqueAdd(&environment.Integration.Status.Capabilities, v1.CapabilityAwsSecretsManager)
- }
-
- if !environment.IntegrationInRunningPhases() {
- return nil
- }
-
- hits := v1.PlainConfigSecretRegexp.FindAllStringSubmatch(t.AccessKey, -1)
- if len(hits) >= 1 {
- var res, _ = v1.DecodeValueSource(t.AccessKey, "aws-access-key")
- if secretValue, err := kubernetes.ResolveValueSource(environment.Ctx, environment.Client, environment.Platform.Namespace, &res); err != nil {
- return err
- } else if secretValue != "" {
- environment.ApplicationProperties["camel.vault.aws.accessKey"] = string([]byte(secretValue))
- }
- } else {
- environment.ApplicationProperties["camel.vault.aws.accessKey"] = t.AccessKey
- }
- hits = v1.PlainConfigSecretRegexp.FindAllStringSubmatch(t.SecretKey, -1)
- if len(hits) >= 1 {
- var res, _ = v1.DecodeValueSource(t.SecretKey, "aws-secret-key")
- if secretValue, err := kubernetes.ResolveValueSource(environment.Ctx, environment.Client, environment.Platform.Namespace, &res); err != nil {
- return err
- } else if secretValue != "" {
- environment.ApplicationProperties["camel.vault.aws.secretKey"] = string([]byte(secretValue))
- }
- } else {
- environment.ApplicationProperties["camel.vault.aws.secretKey"] = t.SecretKey
- }
- environment.ApplicationProperties["camel.vault.aws.region"] = t.Region
- environment.ApplicationProperties["camel.vault.aws.defaultCredentialsProvider"] = strconv.FormatBool(*t.UseDefaultCredentialsProvider)
- environment.ApplicationProperties["camel.vault.aws.refreshEnabled"] = strconv.FormatBool(*t.RefreshEnabled)
- environment.ApplicationProperties["camel.main.context-reload-enabled"] = strconv.FormatBool(*t.ContextReloadEnabled)
- environment.ApplicationProperties["camel.vault.aws.refreshPeriod"] = t.RefreshPeriod
- if t.Secrets != "" {
- environment.ApplicationProperties["camel.vault.aws.secrets"] = t.Secrets
- }
-
- return nil
-}
diff --git a/addons/vault/aws/aws_secrets_manager_test.go b/addons/vault/aws/aws_secrets_manager_test.go
deleted file mode 100644
index 18fb607fa..000000000
--- a/addons/vault/aws/aws_secrets_manager_test.go
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
-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 aws
-
-import (
- "testing"
-
- "github.com/apache/camel-k/v2/pkg/util/boolean"
-
- corev1 "k8s.io/api/core/v1"
-
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- "k8s.io/utils/ptr"
-
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- "github.com/apache/camel-k/v2/pkg/trait"
- "github.com/apache/camel-k/v2/pkg/util/camel"
-
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
- "k8s.io/apimachinery/pkg/runtime"
-)
-
-func TestAwsSecretsManagerTraitApply(t *testing.T) {
- e := createEnvironment(t, camel.QuarkusCatalog)
- aws := NewAwsSecretsManagerTrait()
- secrets, _ := aws.(*awsSecretsManagerTrait)
- secrets.Enabled = ptr.To(true)
- secrets.UseDefaultCredentialsProvider = ptr.To(false)
- secrets.Region = "eu-west-1"
- secrets.AccessKey = "access-key"
- secrets.SecretKey = "secret-key"
- ok, condition, err := secrets.Configure(e)
- require.NoError(t, err)
- assert.True(t, ok)
- assert.NotNil(t, condition)
-
- err = secrets.Apply(e)
- require.NoError(t, err)
-
- assert.Empty(t, e.ApplicationProperties["quarkus.jaeger.enabled"])
- assert.Equal(t, "eu-west-1", e.ApplicationProperties["camel.vault.aws.region"])
- assert.Equal(t, "access-key", e.ApplicationProperties["camel.vault.aws.accessKey"])
- assert.Equal(t, "secret-key", e.ApplicationProperties["camel.vault.aws.secretKey"])
- assert.Equal(t, boolean.FalseString, e.ApplicationProperties["camel.vault.aws.defaultCredentialsProvider"])
-}
-
-func TestAwsSecretsManagerTraitNoDefaultCreds(t *testing.T) {
- e := createEnvironment(t, camel.QuarkusCatalog)
- aws := NewAwsSecretsManagerTrait()
- secrets, _ := aws.(*awsSecretsManagerTrait)
- secrets.Enabled = ptr.To(true)
- secrets.Region = "eu-west-1"
- secrets.AccessKey = "access-key"
- secrets.SecretKey = "secret-key"
- ok, condition, err := secrets.Configure(e)
- require.NoError(t, err)
- assert.True(t, ok)
- assert.NotNil(t, condition)
-
- err = secrets.Apply(e)
- require.NoError(t, err)
-
- assert.Empty(t, e.ApplicationProperties["quarkus.jaeger.enabled"])
- assert.Equal(t, "eu-west-1", e.ApplicationProperties["camel.vault.aws.region"])
- assert.Equal(t, "access-key", e.ApplicationProperties["camel.vault.aws.accessKey"])
- assert.Equal(t, "secret-key", e.ApplicationProperties["camel.vault.aws.secretKey"])
- assert.Equal(t, boolean.FalseString, e.ApplicationProperties["camel.vault.aws.defaultCredentialsProvider"])
-}
-
-func TestAwsSecretsManagerTraitWithSecrets(t *testing.T) {
- e := createEnvironment(t, camel.QuarkusCatalog, &corev1.Secret{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "test",
- Name: "my-secret1",
- },
- Data: map[string][]byte{
- "aws-secret-key": []byte("my-secret-key"),
- },
- }, &corev1.Secret{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "test",
- Name: "my-secret2",
- },
- Data: map[string][]byte{
- "aws-access-key": []byte("my-access-key"),
- },
- })
-
- aws := NewAwsSecretsManagerTrait()
- secrets, _ := aws.(*awsSecretsManagerTrait)
- secrets.Enabled = ptr.To(true)
- secrets.Region = "eu-west-1"
- secrets.AccessKey = "secret:my-secret2/aws-access-key"
- secrets.SecretKey = "secret:my-secret1/aws-secret-key"
- ok, condition, err := secrets.Configure(e)
- require.NoError(t, err)
- assert.True(t, ok)
- assert.NotNil(t, condition)
-
- err = secrets.Apply(e)
- require.NoError(t, err)
-
- assert.Empty(t, e.ApplicationProperties["quarkus.jaeger.enabled"])
- assert.Equal(t, "eu-west-1", e.ApplicationProperties["camel.vault.aws.region"])
- assert.Equal(t, "my-access-key", e.ApplicationProperties["camel.vault.aws.accessKey"])
- assert.Equal(t, "my-secret-key", e.ApplicationProperties["camel.vault.aws.secretKey"])
- assert.Equal(t, boolean.FalseString, e.ApplicationProperties["camel.vault.aws.defaultCredentialsProvider"])
-}
-
-func TestAwsSecretsManagerTraitWithConfigMap(t *testing.T) {
- e := createEnvironment(t, camel.QuarkusCatalog, &corev1.ConfigMap{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "test",
- Name: "my-configmap1",
- },
- Data: map[string]string{
- "aws-secret-key": "my-secret-key",
- },
- }, &corev1.ConfigMap{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "test",
- Name: "my-configmap2",
- },
- Data: map[string]string{
- "aws-access-key": "my-access-key",
- },
- })
-
- aws := NewAwsSecretsManagerTrait()
- secrets, _ := aws.(*awsSecretsManagerTrait)
- secrets.Enabled = ptr.To(true)
- secrets.Region = "eu-west-1"
- secrets.AccessKey = "configmap:my-configmap2/aws-access-key"
- secrets.SecretKey = "configmap:my-configmap1/aws-secret-key"
- ok, condition, err := secrets.Configure(e)
- require.NoError(t, err)
- assert.True(t, ok)
- assert.NotNil(t, condition)
-
- err = secrets.Apply(e)
- require.NoError(t, err)
-
- assert.Empty(t, e.ApplicationProperties["quarkus.jaeger.enabled"])
- assert.Equal(t, "eu-west-1", e.ApplicationProperties["camel.vault.aws.region"])
- assert.Equal(t, "my-access-key", e.ApplicationProperties["camel.vault.aws.accessKey"])
- assert.Equal(t, "my-secret-key", e.ApplicationProperties["camel.vault.aws.secretKey"])
- assert.Equal(t, boolean.FalseString, e.ApplicationProperties["camel.vault.aws.defaultCredentialsProvider"])
-}
-
-func createEnvironment(t *testing.T, catalogGen func() (*camel.RuntimeCatalog, error), objects ...runtime.Object) *trait.Environment {
- t.Helper()
-
- catalog, err := catalogGen()
- client, _ := newFakeClient(objects...)
- require.NoError(t, err)
-
- e := trait.Environment{
- CamelCatalog: catalog,
- ApplicationProperties: make(map[string]string),
- Client: client,
- }
-
- it := v1.Integration{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "test",
- Name: "test",
- },
- Status: v1.IntegrationStatus{
- Phase: v1.IntegrationPhaseDeploying,
- },
- }
- platform := v1.IntegrationPlatform{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "test",
- Name: "test",
- },
- }
- e.Integration = &it
- e.Platform = &platform
- return &e
-}
diff --git a/addons/vault/aws/client_test.go b/addons/vault/aws/client_test.go
deleted file mode 100644
index b2c77c7d5..000000000
--- a/addons/vault/aws/client_test.go
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
-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.
-*/
-
-// IMPORTANT: this is a clone of pkg/internal. As the addons will be moved into pkg, we are using this utility here temporarily only!
-
-package aws
-
-import (
- "context"
- "fmt"
- "strings"
-
- "github.com/apache/camel-k/v2/pkg/apis"
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- "github.com/apache/camel-k/v2/pkg/client"
- fakecamelclientset "github.com/apache/camel-k/v2/pkg/client/camel/clientset/versioned/fake"
- camelv1 "github.com/apache/camel-k/v2/pkg/client/camel/clientset/versioned/typed/camel/v1"
- "github.com/apache/camel-k/v2/pkg/util"
- autoscalingv1 "k8s.io/api/autoscaling/v1"
- corev1 "k8s.io/api/core/v1"
- k8serrors "k8s.io/apimachinery/pkg/api/errors"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- "k8s.io/apimachinery/pkg/runtime"
- "k8s.io/apimachinery/pkg/runtime/schema"
- "k8s.io/client-go/discovery"
- "k8s.io/client-go/kubernetes"
- fakeclientset "k8s.io/client-go/kubernetes/fake"
- clientscheme "k8s.io/client-go/kubernetes/scheme"
- authorizationv1 "k8s.io/client-go/kubernetes/typed/authorization/v1"
- "k8s.io/client-go/rest"
- "k8s.io/client-go/scale"
- fakescale "k8s.io/client-go/scale/fake"
- "k8s.io/client-go/testing"
- controller "sigs.k8s.io/controller-runtime/pkg/client"
- "sigs.k8s.io/controller-runtime/pkg/client/fake"
- "sigs.k8s.io/controller-runtime/pkg/client/interceptor"
-)
-
-// newFakeClient ---.
-func newFakeClient(initObjs ...runtime.Object) (client.Client, error) {
- scheme := clientscheme.Scheme
-
- // Setup Scheme for all resources
- if err := apis.AddToScheme(scheme); err != nil {
- return nil, err
- }
-
- c := fake.
- NewClientBuilder().
- WithScheme(scheme).
- WithIndex(
- &corev1.Pod{},
- "status.phase",
- func(obj controller.Object) []string {
- pod, _ := obj.(*corev1.Pod)
- return []string{string(pod.Status.Phase)}
- },
- ).
- WithRuntimeObjects(initObjs...).
- WithStatusSubresource(&v1.IntegrationKit{}).
- Build()
-
- camelClientset := fakecamelclientset.NewSimpleClientset(filterObjects(scheme, initObjs, func(gvk schema.GroupVersionKind) bool {
- return strings.Contains(gvk.Group, "camel")
- })...)
- clientset := fakeclientset.NewSimpleClientset(filterObjects(scheme, initObjs, func(gvk schema.GroupVersionKind) bool {
- return !strings.Contains(gvk.Group, "camel") && !strings.Contains(gvk.Group, "knative")
- })...)
- replicasCount := make(map[string]int32)
- fakescaleclient := fakescale.FakeScaleClient{}
- fakescaleclient.AddReactor("update", "*", func(rawAction testing.Action) (bool, runtime.Object, error) {
- //nolint:forcetypeassert
- action := rawAction.(testing.UpdateAction)
-
- //nolint:forcetypeassert
- obj := action.GetObject().(*autoscalingv1.Scale)
-
- replicas := obj.Spec.Replicas
- key := fmt.Sprintf("%s:%s:%s/%s", action.GetResource().Group, action.GetResource().Resource, action.GetNamespace(), obj.GetName())
- replicasCount[key] = replicas
- return true, &autoscalingv1.Scale{
- ObjectMeta: metav1.ObjectMeta{
- Name: obj.Name,
- Namespace: action.GetNamespace(),
- },
- Spec: autoscalingv1.ScaleSpec{
- Replicas: replicas,
- },
- }, nil
- })
- fakescaleclient.AddReactor("get", "*", func(rawAction testing.Action) (bool, runtime.Object, error) {
- //nolint:forcetypeassert
- action := rawAction.(testing.GetAction)
-
- key := fmt.Sprintf("%s:%s:%s/%s", action.GetResource().Group, action.GetResource().Resource, action.GetNamespace(), action.GetName())
- obj := &autoscalingv1.Scale{
- ObjectMeta: metav1.ObjectMeta{
- Name: action.GetName(),
- Namespace: action.GetNamespace(),
- },
- Spec: autoscalingv1.ScaleSpec{
- Replicas: replicasCount[key],
- },
- }
- return true, obj, nil
- })
-
- return &FakeClient{
- Client: c,
- Interface: clientset,
- camel: camelClientset,
- scales: &fakescaleclient,
- enabledKnativeServing: true,
- enabledKnativeEventing: true,
- }, nil
-}
-
-func filterObjects(scheme *runtime.Scheme, input []runtime.Object, filter func(gvk schema.GroupVersionKind) bool) []runtime.Object {
- var res []runtime.Object
- for _, obj := range input {
- kinds, _, _ := scheme.ObjectKinds(obj)
- for _, k := range kinds {
- if filter(k) {
- res = append(res, obj)
- break
- }
- }
- }
- return res
-}
-
-// FakeClient ---.
-type FakeClient struct {
- controller.Client
- kubernetes.Interface
- camel *fakecamelclientset.Clientset
- scales *fakescale.FakeScaleClient
- disabledGroups []string
- enabledOpenshift bool
- enabledKnativeServing bool
- enabledKnativeEventing bool
-}
-
-func (c *FakeClient) Intercept(intercept *interceptor.Funcs) {
- //nolint:forcetypeassert
- cw := c.Client.(controller.WithWatch)
- c.Client = interceptor.NewClient(cw, *intercept)
-}
-
-func (c *FakeClient) AddReactor(verb, resource string, reaction testing.ReactionFunc) {
- c.camel.AddReactor(verb, resource, reaction)
-}
-
-func (c *FakeClient) CamelV1() camelv1.CamelV1Interface {
- return c.camel.CamelV1()
-}
-
-// GetScheme ---.
-func (c *FakeClient) GetScheme() *runtime.Scheme {
- return clientscheme.Scheme
-}
-
-func (c *FakeClient) GetConfig() *rest.Config {
- return &rest.Config{}
-}
-
-func (c *FakeClient) GetCurrentNamespace(kubeConfig string) (string, error) {
- return "", nil
-}
-
-// Patch mimicks patch for server-side apply and simply creates the obj.
-func (c *FakeClient) Patch(ctx context.Context, obj controller.Object, patch controller.Patch, opts ...controller.PatchOption) error {
- if err := c.Create(ctx, obj); err != nil {
- // Create fails if object already exists. Try to update it.
- return c.Update(ctx, obj)
- }
- return nil
-}
-
-func (c *FakeClient) DisableAPIGroupDiscovery(group string) {
- c.disabledGroups = append(c.disabledGroups, group)
-}
-
-func (c *FakeClient) EnableOpenshiftDiscovery() {
- c.enabledOpenshift = true
-}
-
-func (c *FakeClient) DisableKnativeServing() {
- c.enabledKnativeServing = false
-}
-
-func (c *FakeClient) DisableKnativeEventing() {
- c.enabledKnativeEventing = false
-}
-
-func (c *FakeClient) AuthorizationV1() authorizationv1.AuthorizationV1Interface {
- return &FakeAuthorization{
- AuthorizationV1Interface: c.Interface.AuthorizationV1(),
- disabledGroups: c.disabledGroups,
- enabledOpenshift: c.enabledOpenshift,
- }
-}
-
-func (c *FakeClient) Discovery() discovery.DiscoveryInterface {
- return &FakeDiscovery{
- DiscoveryInterface: c.Interface.Discovery(),
- disabledGroups: c.disabledGroups,
- enabledOpenshift: c.enabledOpenshift,
- enabledKnativeServing: c.enabledKnativeServing,
- enabledKnativeEventing: c.enabledKnativeEventing,
- }
-}
-
-func (c *FakeClient) ServerOrClientSideApplier() client.ServerOrClientSideApplier {
- return client.ServerOrClientSideApplier{
- Client: c,
- }
-}
-
-func (c *FakeClient) ScalesClient() (scale.ScalesGetter, error) {
- return c.scales, nil
-}
-
-type FakeAuthorization struct {
- authorizationv1.AuthorizationV1Interface
- disabledGroups []string
- enabledOpenshift bool
-}
-
-func (f *FakeAuthorization) SelfSubjectRulesReviews() authorizationv1.SelfSubjectRulesReviewInterface {
- return f.AuthorizationV1Interface.SelfSubjectRulesReviews()
-}
-
-type FakeDiscovery struct {
- discovery.DiscoveryInterface
- disabledGroups []string
- enabledOpenshift bool
- enabledKnativeServing bool
- enabledKnativeEventing bool
-}
-
-func (f *FakeDiscovery) ServerResourcesForGroupVersion(groupVersion string) (*metav1.APIResourceList, error) {
- // Normalize the fake discovery to behave like the real implementation when checking for openshift
- if groupVersion == "image.openshift.io/v1" {
- if f.enabledOpenshift {
- return &metav1.APIResourceList{
- GroupVersion: "image.openshift.io/v1",
- }, nil
- } else {
- return nil, k8serrors.NewNotFound(schema.GroupResource{
- Group: "image.openshift.io",
- }, "")
- }
- }
-
- // used to verify if Knative Serving is installed
- if f.enabledKnativeServing {
- if groupVersion == "serving.knative.dev/v1" && !util.StringSliceExists(f.disabledGroups, groupVersion) {
- return &metav1.APIResourceList{
- GroupVersion: "serving.knative.dev/v1",
- }, nil
- }
- }
-
- // used to verify if Knative Eventing is installed
- if f.enabledKnativeEventing {
- if groupVersion == "eventing.knative.dev/v1" && !util.StringSliceExists(f.disabledGroups, groupVersion) {
- return &metav1.APIResourceList{
- GroupVersion: "eventing.knative.dev/v1",
- }, nil
- }
- if groupVersion == "messaging.knative.dev/v1" && !util.StringSliceExists(f.disabledGroups, groupVersion) {
- return &metav1.APIResourceList{
- GroupVersion: "messaging.knative.dev/v1",
- }, nil
- }
- if groupVersion == "messaging.knative.dev/v1beta1" && !util.StringSliceExists(f.disabledGroups, groupVersion) {
- return &metav1.APIResourceList{
- GroupVersion: "messaging.knative.dev/v1beta1",
- }, nil
- }
- }
-
- return f.DiscoveryInterface.ServerResourcesForGroupVersion(groupVersion)
-}
diff --git a/addons/vault/aws/zz_desc_generated.go b/addons/vault/aws/zz_desc_generated.go
deleted file mode 100644
index a1f9c0e3b..000000000
--- a/addons/vault/aws/zz_desc_generated.go
+++ /dev/null
@@ -1 +0,0 @@
-package aws
diff --git a/addons/vault/aws/zz_generated_doc.go b/addons/vault/aws/zz_generated_doc.go
deleted file mode 100644
index a1f9c0e3b..000000000
--- a/addons/vault/aws/zz_generated_doc.go
+++ /dev/null
@@ -1 +0,0 @@
-package aws
diff --git a/addons/vault/azure/azure_key_vault.go b/addons/vault/azure/azure_key_vault.go
deleted file mode 100644
index cf6a491a3..000000000
--- a/addons/vault/azure/azure_key_vault.go
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
-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 azure
-
-import (
- "strconv"
-
- "github.com/apache/camel-k/v2/pkg/util/kubernetes"
-
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- traitv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1/trait"
- "github.com/apache/camel-k/v2/pkg/trait"
- "github.com/apache/camel-k/v2/pkg/util"
- corev1 "k8s.io/api/core/v1"
- "k8s.io/utils/ptr"
-)
-
-// The Azure Key Vault trait can be used to use secrets from Azure Key Vault service
-//
-// The Azure Key Vault trait is disabled by default.
-//
-// For more information about how to use secrets from Azure Key Vault component take a look at the components docs: xref:components::azure-key-vault-component.adoc[Azure Key Vault component]
-//
-// A sample execution of this trait, would require
-// the following trait options:
-// -t azure-key-vault.enabled=true -t azure-key-vault.tenant-id="tenant-id" -t azure-key-vault.client-id="client-id" -t azure-key-vault.client-secret="client-secret" -t azure-key-vault.vault-name="vault-name"
-//
-// To enable the automatic context reload on secrets updates you should define
-// the following trait options:
-// -t azure-key-vault.enabled=true -t azure-key-vault.tenant-id="tenant-id" -t azure-key-vault.client-id="client-id" -t azure-key-vault.client-secret="client-secret" -t azure-key-vault.vault-name="vault-name" -t azure-key-vault.context-reload-enabled="true" -t azure-key-vault.refresh-enabled="true" -t azure-key-vault.refresh-period="30000" -t azure-key-vault.secrets="test*" -t azure-key-vault.eventhub-connection-string="connection-string" -t azure-key-vault.blob-account-name="account-nam [...]
-//
-// WARNING: The trait is **deprecated** and will removed in future release versions: configure directly the Camel properties as required by the component instead.
-//
-// +camel-k:trait=azure-key-vault.
-// +camel-k:deprecated=2.5.0.
-type Trait struct {
- traitv1.Trait `property:",squash"`
- // Enables automatic configuration of the trait.
- Auto *bool `property:"auto" json:"auto,omitempty"`
- // The Azure Tenant Id for accessing Key Vault
- TenantID string `property:"tenant-id" json:"tenantId,omitempty"`
- // The Azure Client Id for accessing Key Vault
- ClientID string `property:"client-id" json:"clientId,omitempty"`
- // The Azure Client Secret for accessing Key Vault. This could be a plain text or a configmap/secret.
- // The content of the azure key vault client secret is expected to be a text containing a valid Client Secret.
- // Syntax: [configmap|secret]:name[/key], where name represents the resource name, key optionally represents the resource key to be filtered (default key value = azure-key-vault-client-secret).
- ClientSecret string `property:"client-secret" json:"clientSecret,omitempty"`
- // The Azure Vault Name for accessing Key Vault
- VaultName string `property:"vault-name" json:"vaultName,omitempty"`
- // Define if we want to use the Camel Context Reload feature or not
- ContextReloadEnabled *bool `property:"context-reload-enabled" json:"contextReloadEnabled,omitempty"`
- // Define if we want to use the Refresh Feature for secrets
- RefreshEnabled *bool `property:"refresh-enabled" json:"refreshEnabled,omitempty"`
- // Whether the Azure Identity Authentication should be used or not
- AzureIdentityEnabled *bool `property:"azure-identity-enabled" json:"azureIdentityEnabled,omitempty"`
- // If Refresh is enabled, this defines the interval to check the refresh event
- RefreshPeriod string `property:"refresh-period" json:"refreshPeriod,omitempty"`
- // If Refresh is enabled, the regular expression representing the secrets we want to track
- Secrets string `property:"secrets" json:"secrets,omitempty"`
- // If Refresh is enabled, the connection String to point to the Eventhub service used to track updates
- EventhubConnectionString string `property:"eventhub-connection-string" json:"eventhubConnectionString,omitempty"`
- // If Refresh is enabled, the account name for Azure Storage Blob service used to save checkpoint while consuming from Eventhub
- BlobAccountName string `property:"blob-account-name" json:"blobAccountName,omitempty"`
- // If Refresh is enabled, the access key for Azure Storage Blob service used to save checkpoint while consuming from Eventhub. This could be a plain text or a configmap/secret.
- // The content of the azure key vault blob access key is expected to be a text containing a valid Access Key for Azure Storage Blob.
- // Syntax: [configmap|secret]:name[/key], where name represents the resource name, key optionally represents the resource key to be filtered (default key value = azure-storage-blob-access-key).
- BlobAccessKey string `property:"blob-access-key" json:"blobAccessKey,omitempty"`
- // If Refresh is enabled, the container name for Azure Storage Blob service used to save checkpoint while consuming from Eventhub
- BlobContainerName string `property:"blob-container-name" json:"blobContainerName,omitempty"`
-}
-
-type azureKeyVaultTrait struct {
- trait.BaseTrait
- Trait `property:",squash"`
-}
-
-func NewAzureKeyVaultTrait() trait.Trait {
- return &azureKeyVaultTrait{
- BaseTrait: trait.NewBaseTrait("azure-key-vault", trait.TraitOrderBeforeControllerCreation),
- }
-}
-
-func (t *azureKeyVaultTrait) Configure(environment *trait.Environment) (bool, *trait.TraitCondition, error) {
- if environment.Integration == nil || !ptr.Deref(t.Enabled, false) {
- return false, nil, nil
- }
-
- if !environment.IntegrationInPhase(v1.IntegrationPhaseInitialization) && !environment.IntegrationInRunningPhases() {
- return false, nil, nil
- }
-
- if t.ContextReloadEnabled == nil {
- t.ContextReloadEnabled = ptr.To(false)
- }
-
- if t.RefreshEnabled == nil {
- t.RefreshEnabled = ptr.To(false)
- }
-
- if t.AzureIdentityEnabled == nil {
- t.AzureIdentityEnabled = ptr.To(false)
- }
-
- condition := trait.NewIntegrationCondition(
- "AzureKeyVault",
- v1.IntegrationConditionTraitInfo,
- corev1.ConditionTrue,
- trait.TraitConfigurationReason,
- "AzureKeyVault trait is deprecated and may be removed in future version: "+
- "configure directly the Camel properties as required by the component instead",
- )
-
- return true, condition, nil
-}
-
-func (t *azureKeyVaultTrait) Apply(environment *trait.Environment) error {
-
- if environment.IntegrationInPhase(v1.IntegrationPhaseInitialization) {
- util.StringSliceUniqueAdd(&environment.Integration.Status.Capabilities, v1.CapabilityAzureKeyVault)
- }
-
- if !environment.IntegrationInRunningPhases() {
- return nil
- }
-
- hits := v1.PlainConfigSecretRegexp.FindAllStringSubmatch(t.ClientSecret, -1)
- if len(hits) >= 1 {
- var res, _ = v1.DecodeValueSource(t.ClientSecret, "azure-key-vault-client-secret")
- if secretValue, err := kubernetes.ResolveValueSource(environment.Ctx, environment.Client, environment.Platform.Namespace, &res); err != nil {
- return err
- } else if secretValue != "" {
- environment.ApplicationProperties["camel.vault.azure.clientSecret"] = string([]byte(secretValue))
- }
- } else {
- environment.ApplicationProperties["camel.vault.azure.clientSecret"] = t.ClientSecret
- }
- hits = v1.PlainConfigSecretRegexp.FindAllStringSubmatch(t.BlobAccessKey, -1)
- if len(hits) >= 1 {
- var res, _ = v1.DecodeValueSource(t.BlobAccessKey, "azure-storage-blob-access-key")
- if secretValue, err := kubernetes.ResolveValueSource(environment.Ctx, environment.Client, environment.Platform.Namespace, &res); err != nil {
- return err
- } else if secretValue != "" {
- environment.ApplicationProperties["camel.vault.azure.blobAccessKey"] = string([]byte(secretValue))
- }
- } else {
- environment.ApplicationProperties["camel.vault.azure.blobAccessKey"] = t.BlobAccessKey
- }
- environment.ApplicationProperties["camel.vault.azure.tenantId"] = t.TenantID
- environment.ApplicationProperties["camel.vault.azure.clientId"] = t.ClientID
- environment.ApplicationProperties["camel.vault.azure.vaultName"] = t.VaultName
- environment.ApplicationProperties["camel.vault.azure.refreshEnabled"] = strconv.FormatBool(*t.RefreshEnabled)
- environment.ApplicationProperties["camel.vault.azure.azureIdentityEnabled"] = strconv.FormatBool(*t.AzureIdentityEnabled)
- environment.ApplicationProperties["camel.main.context-reload-enabled"] = strconv.FormatBool(*t.ContextReloadEnabled)
- environment.ApplicationProperties["camel.vault.azure.refreshPeriod"] = t.RefreshPeriod
- if t.Secrets != "" {
- environment.ApplicationProperties["camel.vault.azure.secrets"] = t.Secrets
- }
- environment.ApplicationProperties["camel.vault.azure.eventhubConnectionString"] = t.EventhubConnectionString
- environment.ApplicationProperties["camel.vault.azure.blobAccountName"] = t.BlobAccountName
- environment.ApplicationProperties["camel.vault.azure.blobContainerName"] = t.BlobContainerName
-
- return nil
-}
diff --git a/addons/vault/azure/azure_key_vault_test.go b/addons/vault/azure/azure_key_vault_test.go
deleted file mode 100644
index f4ddfc25f..000000000
--- a/addons/vault/azure/azure_key_vault_test.go
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
-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 azure
-
-import (
- "testing"
-
- corev1 "k8s.io/api/core/v1"
- "k8s.io/utils/ptr"
-
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- "github.com/apache/camel-k/v2/pkg/trait"
- "github.com/apache/camel-k/v2/pkg/util/camel"
-
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
- "k8s.io/apimachinery/pkg/runtime"
-)
-
-func TestAzureKeyVaultTraitApply(t *testing.T) {
- e := createEnvironment(t, camel.QuarkusCatalog)
- azure := NewAzureKeyVaultTrait()
- secrets, _ := azure.(*azureKeyVaultTrait)
- secrets.Enabled = ptr.To(true)
- secrets.TenantID = "tenant-id"
- secrets.ClientID = "client-id"
- secrets.ClientSecret = "secret"
- secrets.VaultName = "my-vault"
- ok, condition, err := secrets.Configure(e)
- require.NoError(t, err)
- assert.True(t, ok)
- assert.NotNil(t, condition)
-
- err = secrets.Apply(e)
- require.NoError(t, err)
-
- assert.Equal(t, "client-id", e.ApplicationProperties["camel.vault.azure.clientId"])
- assert.Equal(t, "secret", e.ApplicationProperties["camel.vault.azure.clientSecret"])
- assert.Equal(t, "tenant-id", e.ApplicationProperties["camel.vault.azure.tenantId"])
- assert.Equal(t, "my-vault", e.ApplicationProperties["camel.vault.azure.vaultName"])
-}
-
-func TestAzureKeyVaultTraitApplyWithConfigmapAndRefresh(t *testing.T) {
- e := createEnvironment(t, camel.QuarkusCatalog, &corev1.ConfigMap{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "test",
- Name: "my-configmap1",
- },
- Data: map[string]string{
- "azure-client-secret": "my-secret-key",
- },
- }, &corev1.ConfigMap{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "test",
- Name: "my-configmap2",
- },
- Data: map[string]string{
- "azure-storage-blob-key": "my-access-key",
- },
- })
- azure := NewAzureKeyVaultTrait()
- secrets, _ := azure.(*azureKeyVaultTrait)
- secrets.Enabled = ptr.To(true)
- secrets.TenantID = "tenant-id"
- secrets.ClientID = "client-id"
- secrets.ClientSecret = "configmap:my-configmap1/azure-client-secret"
- secrets.VaultName = "my-vault"
- secrets.RefreshEnabled = ptr.To(true)
- secrets.BlobAccessKey = "configmap:my-configmap2/azure-storage-blob-key"
- secrets.BlobAccountName = "camel-k"
- secrets.BlobContainerName = "camel-k-container"
- ok, condition, err := secrets.Configure(e)
- require.NoError(t, err)
- assert.True(t, ok)
- assert.NotNil(t, condition)
-
- err = secrets.Apply(e)
- require.NoError(t, err)
-
- assert.Equal(t, "client-id", e.ApplicationProperties["camel.vault.azure.clientId"])
- assert.Equal(t, "my-secret-key", e.ApplicationProperties["camel.vault.azure.clientSecret"])
- assert.Equal(t, "tenant-id", e.ApplicationProperties["camel.vault.azure.tenantId"])
- assert.Equal(t, "my-vault", e.ApplicationProperties["camel.vault.azure.vaultName"])
- assert.Equal(t, "camel-k", e.ApplicationProperties["camel.vault.azure.blobAccountName"])
- assert.Equal(t, "camel-k-container", e.ApplicationProperties["camel.vault.azure.blobContainerName"])
- assert.Equal(t, "my-access-key", e.ApplicationProperties["camel.vault.azure.blobAccessKey"])
- assert.True(t, true, e.ApplicationProperties["camel.vault.azure.refreshEnabled"])
-}
-
-func TestAzureKeyVaultTraitApplyWithSecretAndRefresh(t *testing.T) {
- e := createEnvironment(t, camel.QuarkusCatalog, &corev1.Secret{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "test",
- Name: "my-secret1",
- },
- Data: map[string][]byte{
- "azure-client-secret": []byte("my-secret-key"),
- },
- }, &corev1.Secret{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "test",
- Name: "my-secret2",
- },
- Data: map[string][]byte{
- "azure-storage-blob-key": []byte("my-access-key"),
- },
- })
- azure := NewAzureKeyVaultTrait()
- secrets, _ := azure.(*azureKeyVaultTrait)
- secrets.Enabled = ptr.To(true)
- secrets.TenantID = "tenant-id"
- secrets.ClientID = "client-id"
- secrets.ClientSecret = "secret:my-secret1/azure-client-secret"
- secrets.VaultName = "my-vault"
- secrets.RefreshEnabled = ptr.To(true)
- secrets.BlobAccessKey = "secret:my-secret2/azure-storage-blob-key"
- secrets.BlobAccountName = "camel-k"
- secrets.BlobContainerName = "camel-k-container"
- ok, condition, err := secrets.Configure(e)
- require.NoError(t, err)
- assert.True(t, ok)
- assert.NotNil(t, condition)
-
- err = secrets.Apply(e)
- require.NoError(t, err)
-
- assert.Equal(t, "client-id", e.ApplicationProperties["camel.vault.azure.clientId"])
- assert.Equal(t, "my-secret-key", e.ApplicationProperties["camel.vault.azure.clientSecret"])
- assert.Equal(t, "tenant-id", e.ApplicationProperties["camel.vault.azure.tenantId"])
- assert.Equal(t, "my-vault", e.ApplicationProperties["camel.vault.azure.vaultName"])
- assert.Equal(t, "camel-k", e.ApplicationProperties["camel.vault.azure.blobAccountName"])
- assert.Equal(t, "camel-k-container", e.ApplicationProperties["camel.vault.azure.blobContainerName"])
- assert.Equal(t, "my-access-key", e.ApplicationProperties["camel.vault.azure.blobAccessKey"])
- assert.True(t, true, e.ApplicationProperties["camel.vault.azure.refreshEnabled"])
-}
-
-func TestAzureKeyVaultTraitAzureIdentityEnabledApplyWithSecretAndRefresh(t *testing.T) {
- e := createEnvironment(t, camel.QuarkusCatalog, &corev1.Secret{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "test",
- Name: "my-secret1",
- },
- Data: map[string][]byte{
- "azure-client-secret": []byte("my-secret-key"),
- },
- }, &corev1.Secret{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "test",
- Name: "my-secret2",
- },
- Data: map[string][]byte{
- "azure-storage-blob-key": []byte("my-access-key"),
- },
- })
- azure := NewAzureKeyVaultTrait()
- secrets, _ := azure.(*azureKeyVaultTrait)
- secrets.Enabled = ptr.To(true)
- secrets.TenantID = "tenant-id"
- secrets.ClientID = "client-id"
- secrets.ClientSecret = "secret:my-secret1/azure-client-secret"
- secrets.VaultName = "my-vault"
- secrets.RefreshEnabled = ptr.To(true)
- secrets.AzureIdentityEnabled = ptr.To(true)
- secrets.BlobAccessKey = "secret:my-secret2/azure-storage-blob-key"
- secrets.BlobAccountName = "camel-k"
- secrets.BlobContainerName = "camel-k-container"
- ok, condition, err := secrets.Configure(e)
- require.NoError(t, err)
- assert.True(t, ok)
- assert.NotNil(t, condition)
-
- err = secrets.Apply(e)
- require.NoError(t, err)
-
- assert.Equal(t, "client-id", e.ApplicationProperties["camel.vault.azure.clientId"])
- assert.Equal(t, "my-secret-key", e.ApplicationProperties["camel.vault.azure.clientSecret"])
- assert.Equal(t, "tenant-id", e.ApplicationProperties["camel.vault.azure.tenantId"])
- assert.Equal(t, "my-vault", e.ApplicationProperties["camel.vault.azure.vaultName"])
- assert.Equal(t, "camel-k", e.ApplicationProperties["camel.vault.azure.blobAccountName"])
- assert.Equal(t, "camel-k-container", e.ApplicationProperties["camel.vault.azure.blobContainerName"])
- assert.Equal(t, "my-access-key", e.ApplicationProperties["camel.vault.azure.blobAccessKey"])
- assert.True(t, true, e.ApplicationProperties["camel.vault.azure.refreshEnabled"])
- assert.True(t, true, e.ApplicationProperties["camel.vault.azure.azureIdentityEnabled"])
-}
-
-func createEnvironment(t *testing.T, catalogGen func() (*camel.RuntimeCatalog, error), objects ...runtime.Object) *trait.Environment {
- t.Helper()
-
- catalog, err := catalogGen()
- client, _ := newFakeClient(objects...)
- require.NoError(t, err)
-
- e := trait.Environment{
- CamelCatalog: catalog,
- ApplicationProperties: make(map[string]string),
- Client: client,
- }
-
- it := v1.Integration{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "test",
- Name: "test",
- },
- Status: v1.IntegrationStatus{
- Phase: v1.IntegrationPhaseDeploying,
- },
- }
- platform := v1.IntegrationPlatform{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "test",
- Name: "test",
- },
- }
- e.Integration = &it
- e.Platform = &platform
- return &e
-}
diff --git a/addons/vault/azure/client_test.go b/addons/vault/azure/client_test.go
deleted file mode 100644
index c7fc29c29..000000000
--- a/addons/vault/azure/client_test.go
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
-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.
-*/
-
-// IMPORTANT: this is a clone of pkg/internal. As the addons will be moved into pkg, we are using this utility here temporarily only!
-
-package azure
-
-import (
- "context"
- "fmt"
- "strings"
-
- "github.com/apache/camel-k/v2/pkg/apis"
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- "github.com/apache/camel-k/v2/pkg/client"
- fakecamelclientset "github.com/apache/camel-k/v2/pkg/client/camel/clientset/versioned/fake"
- camelv1 "github.com/apache/camel-k/v2/pkg/client/camel/clientset/versioned/typed/camel/v1"
- "github.com/apache/camel-k/v2/pkg/util"
- autoscalingv1 "k8s.io/api/autoscaling/v1"
- corev1 "k8s.io/api/core/v1"
- k8serrors "k8s.io/apimachinery/pkg/api/errors"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- "k8s.io/apimachinery/pkg/runtime"
- "k8s.io/apimachinery/pkg/runtime/schema"
- "k8s.io/client-go/discovery"
- "k8s.io/client-go/kubernetes"
- fakeclientset "k8s.io/client-go/kubernetes/fake"
- clientscheme "k8s.io/client-go/kubernetes/scheme"
- authorizationv1 "k8s.io/client-go/kubernetes/typed/authorization/v1"
- "k8s.io/client-go/rest"
- "k8s.io/client-go/scale"
- fakescale "k8s.io/client-go/scale/fake"
- "k8s.io/client-go/testing"
- controller "sigs.k8s.io/controller-runtime/pkg/client"
- "sigs.k8s.io/controller-runtime/pkg/client/fake"
- "sigs.k8s.io/controller-runtime/pkg/client/interceptor"
-)
-
-// newFakeClient ---.
-func newFakeClient(initObjs ...runtime.Object) (client.Client, error) {
- scheme := clientscheme.Scheme
-
- // Setup Scheme for all resources
- if err := apis.AddToScheme(scheme); err != nil {
- return nil, err
- }
-
- c := fake.
- NewClientBuilder().
- WithScheme(scheme).
- WithIndex(
- &corev1.Pod{},
- "status.phase",
- func(obj controller.Object) []string {
- pod, _ := obj.(*corev1.Pod)
- return []string{string(pod.Status.Phase)}
- },
- ).
- WithRuntimeObjects(initObjs...).
- WithStatusSubresource(&v1.IntegrationKit{}).
- Build()
-
- camelClientset := fakecamelclientset.NewSimpleClientset(filterObjects(scheme, initObjs, func(gvk schema.GroupVersionKind) bool {
- return strings.Contains(gvk.Group, "camel")
- })...)
- clientset := fakeclientset.NewSimpleClientset(filterObjects(scheme, initObjs, func(gvk schema.GroupVersionKind) bool {
- return !strings.Contains(gvk.Group, "camel") && !strings.Contains(gvk.Group, "knative")
- })...)
- replicasCount := make(map[string]int32)
- fakescaleclient := fakescale.FakeScaleClient{}
- fakescaleclient.AddReactor("update", "*", func(rawAction testing.Action) (bool, runtime.Object, error) {
- //nolint:forcetypeassert
- action := rawAction.(testing.UpdateAction)
-
- //nolint:forcetypeassert
- obj := action.GetObject().(*autoscalingv1.Scale)
-
- replicas := obj.Spec.Replicas
- key := fmt.Sprintf("%s:%s:%s/%s", action.GetResource().Group, action.GetResource().Resource, action.GetNamespace(), obj.GetName())
- replicasCount[key] = replicas
- return true, &autoscalingv1.Scale{
- ObjectMeta: metav1.ObjectMeta{
- Name: obj.Name,
- Namespace: action.GetNamespace(),
- },
- Spec: autoscalingv1.ScaleSpec{
- Replicas: replicas,
- },
- }, nil
- })
- fakescaleclient.AddReactor("get", "*", func(rawAction testing.Action) (bool, runtime.Object, error) {
- //nolint:forcetypeassert
- action := rawAction.(testing.GetAction)
-
- key := fmt.Sprintf("%s:%s:%s/%s", action.GetResource().Group, action.GetResource().Resource, action.GetNamespace(), action.GetName())
- obj := &autoscalingv1.Scale{
- ObjectMeta: metav1.ObjectMeta{
- Name: action.GetName(),
- Namespace: action.GetNamespace(),
- },
- Spec: autoscalingv1.ScaleSpec{
- Replicas: replicasCount[key],
- },
- }
- return true, obj, nil
- })
-
- return &FakeClient{
- Client: c,
- Interface: clientset,
- camel: camelClientset,
- scales: &fakescaleclient,
- enabledKnativeServing: true,
- enabledKnativeEventing: true,
- }, nil
-}
-
-func filterObjects(scheme *runtime.Scheme, input []runtime.Object, filter func(gvk schema.GroupVersionKind) bool) []runtime.Object {
- var res []runtime.Object
- for _, obj := range input {
- kinds, _, _ := scheme.ObjectKinds(obj)
- for _, k := range kinds {
- if filter(k) {
- res = append(res, obj)
- break
- }
- }
- }
- return res
-}
-
-// FakeClient ---.
-type FakeClient struct {
- controller.Client
- kubernetes.Interface
- camel *fakecamelclientset.Clientset
- scales *fakescale.FakeScaleClient
- disabledGroups []string
- enabledOpenshift bool
- enabledKnativeServing bool
- enabledKnativeEventing bool
-}
-
-func (c *FakeClient) Intercept(intercept *interceptor.Funcs) {
- //nolint:forcetypeassert
- cw := c.Client.(controller.WithWatch)
- c.Client = interceptor.NewClient(cw, *intercept)
-}
-
-func (c *FakeClient) AddReactor(verb, resource string, reaction testing.ReactionFunc) {
- c.camel.AddReactor(verb, resource, reaction)
-}
-
-func (c *FakeClient) CamelV1() camelv1.CamelV1Interface {
- return c.camel.CamelV1()
-}
-
-// GetScheme ---.
-func (c *FakeClient) GetScheme() *runtime.Scheme {
- return clientscheme.Scheme
-}
-
-func (c *FakeClient) GetConfig() *rest.Config {
- return &rest.Config{}
-}
-
-func (c *FakeClient) GetCurrentNamespace(kubeConfig string) (string, error) {
- return "", nil
-}
-
-// Patch mimicks patch for server-side apply and simply creates the obj.
-func (c *FakeClient) Patch(ctx context.Context, obj controller.Object, patch controller.Patch, opts ...controller.PatchOption) error {
- if err := c.Create(ctx, obj); err != nil {
- // Create fails if object already exists. Try to update it.
- return c.Update(ctx, obj)
- }
- return nil
-}
-
-func (c *FakeClient) DisableAPIGroupDiscovery(group string) {
- c.disabledGroups = append(c.disabledGroups, group)
-}
-
-func (c *FakeClient) EnableOpenshiftDiscovery() {
- c.enabledOpenshift = true
-}
-
-func (c *FakeClient) DisableKnativeServing() {
- c.enabledKnativeServing = false
-}
-
-func (c *FakeClient) DisableKnativeEventing() {
- c.enabledKnativeEventing = false
-}
-
-func (c *FakeClient) AuthorizationV1() authorizationv1.AuthorizationV1Interface {
- return &FakeAuthorization{
- AuthorizationV1Interface: c.Interface.AuthorizationV1(),
- disabledGroups: c.disabledGroups,
- enabledOpenshift: c.enabledOpenshift,
- }
-}
-
-func (c *FakeClient) Discovery() discovery.DiscoveryInterface {
- return &FakeDiscovery{
- DiscoveryInterface: c.Interface.Discovery(),
- disabledGroups: c.disabledGroups,
- enabledOpenshift: c.enabledOpenshift,
- enabledKnativeServing: c.enabledKnativeServing,
- enabledKnativeEventing: c.enabledKnativeEventing,
- }
-}
-
-func (c *FakeClient) ServerOrClientSideApplier() client.ServerOrClientSideApplier {
- return client.ServerOrClientSideApplier{
- Client: c,
- }
-}
-
-func (c *FakeClient) ScalesClient() (scale.ScalesGetter, error) {
- return c.scales, nil
-}
-
-type FakeAuthorization struct {
- authorizationv1.AuthorizationV1Interface
- disabledGroups []string
- enabledOpenshift bool
-}
-
-func (f *FakeAuthorization) SelfSubjectRulesReviews() authorizationv1.SelfSubjectRulesReviewInterface {
- return f.AuthorizationV1Interface.SelfSubjectRulesReviews()
-}
-
-type FakeDiscovery struct {
- discovery.DiscoveryInterface
- disabledGroups []string
- enabledOpenshift bool
- enabledKnativeServing bool
- enabledKnativeEventing bool
-}
-
-func (f *FakeDiscovery) ServerResourcesForGroupVersion(groupVersion string) (*metav1.APIResourceList, error) {
- // Normalize the fake discovery to behave like the real implementation when checking for openshift
- if groupVersion == "image.openshift.io/v1" {
- if f.enabledOpenshift {
- return &metav1.APIResourceList{
- GroupVersion: "image.openshift.io/v1",
- }, nil
- } else {
- return nil, k8serrors.NewNotFound(schema.GroupResource{
- Group: "image.openshift.io",
- }, "")
- }
- }
-
- // used to verify if Knative Serving is installed
- if f.enabledKnativeServing {
- if groupVersion == "serving.knative.dev/v1" && !util.StringSliceExists(f.disabledGroups, groupVersion) {
- return &metav1.APIResourceList{
- GroupVersion: "serving.knative.dev/v1",
- }, nil
- }
- }
-
- // used to verify if Knative Eventing is installed
- if f.enabledKnativeEventing {
- if groupVersion == "eventing.knative.dev/v1" && !util.StringSliceExists(f.disabledGroups, groupVersion) {
- return &metav1.APIResourceList{
- GroupVersion: "eventing.knative.dev/v1",
- }, nil
- }
- if groupVersion == "messaging.knative.dev/v1" && !util.StringSliceExists(f.disabledGroups, groupVersion) {
- return &metav1.APIResourceList{
- GroupVersion: "messaging.knative.dev/v1",
- }, nil
- }
- if groupVersion == "messaging.knative.dev/v1beta1" && !util.StringSliceExists(f.disabledGroups, groupVersion) {
- return &metav1.APIResourceList{
- GroupVersion: "messaging.knative.dev/v1beta1",
- }, nil
- }
- }
-
- return f.DiscoveryInterface.ServerResourcesForGroupVersion(groupVersion)
-}
diff --git a/addons/vault/azure/zz_desc_generated.go b/addons/vault/azure/zz_desc_generated.go
deleted file mode 100644
index 6512f735e..000000000
--- a/addons/vault/azure/zz_desc_generated.go
+++ /dev/null
@@ -1 +0,0 @@
-package azure
diff --git a/addons/vault/azure/zz_generated_doc.go b/addons/vault/azure/zz_generated_doc.go
deleted file mode 100644
index 6512f735e..000000000
--- a/addons/vault/azure/zz_generated_doc.go
+++ /dev/null
@@ -1 +0,0 @@
-package azure
diff --git a/addons/vault/gcp/gcp_secret_manager.go b/addons/vault/gcp/gcp_secret_manager.go
deleted file mode 100644
index 9ac2b948e..000000000
--- a/addons/vault/gcp/gcp_secret_manager.go
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
-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 gcp
-
-import (
- "strconv"
-
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- traitv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1/trait"
- "github.com/apache/camel-k/v2/pkg/trait"
- "github.com/apache/camel-k/v2/pkg/util"
- corev1 "k8s.io/api/core/v1"
- "k8s.io/utils/ptr"
-)
-
-// The Google Secret Manager trait can be used to use secrets from Google Secret Manager
-//
-// The Google Secret Manager trait is disabled by default.
-//
-// For more information about how to use secrets from Google Secret Manager take a look at the components docs: xref:components::google-secret-manager-component.adoc[AWS Secrets Manager component]
-//
-// A sample execution of this trait, would require
-// the following trait options:
-// -t gpc-secret-manager.enabled=true -t gpc-secret-manager.project-id="project-id" -t gpc-secret-manager.service-account-key="file:serviceaccount.json"
-//
-// To enable the automatic context reload on secrets updates you should define
-// the following trait options:
-// -t gpc-secret-manager.enabled=true -t gpc-secret-manager.project-id="project-id" -t gpc-secret-manager.service-account-key="file:serviceaccount.json" -t gcp-secret-manager.subscription-name="pubsub-sub" -t gcp-secret-manager.context-reload-enabled="true" -t gcp-secret-manager.refresh-enabled="true" -t gcp-secret-manager.refresh-period="30000" -t gcp-secret-manager.secrets="test*"
-//
-// WARNING: The trait is **deprecated** and will removed in future release versions: configure directly the Camel properties as required by the component instead.
-//
-// +camel-k:trait=gcp-secret-manager.
-// +camel-k:deprecated=2.5.0.
-type Trait struct {
- traitv1.Trait `property:",squash"`
- // Enables automatic configuration of the trait.
- Auto *bool `property:"auto" json:"auto,omitempty"`
- // The Project Id from Google Cloud
- ProjectID string `property:"project-id" json:"projectId,omitempty"`
- // The Path to a service account Key File to use secrets from Google Secret Manager
- ServiceAccountKey string `property:"service-account-key" json:"serviceAccountKey,omitempty"`
- // Define if we want to use the Default Instance approach for accessing the Google Secret Manager service
- UseDefaultInstance *bool `property:"use-default-instance" json:"useDefaultInstance,omitempty"`
- // Define if we want to use the Camel Context Reload feature or not
- ContextReloadEnabled *bool `property:"context-reload-enabled" json:"contextReloadEnabled,omitempty"`
- // Define if we want to use the Refresh Feature for secrets
- RefreshEnabled *bool `property:"refresh-enabled" json:"refreshEnabled,omitempty"`
- // If Refresh is enabled, this defines the interval to check the refresh event
- RefreshPeriod string `property:"refresh-period" json:"refreshPeriod,omitempty"`
- // If Refresh is enabled, the regular expression representing the secrets we want to track
- Secrets string `property:"secrets" json:"secrets,omitempty"`
- // If Refresh is enabled, this defines the subscription name to the Google PubSub topic used to keep track of updates
- SubscriptionName string `property:"subscription-name" json:"subscriptionName,omitempty"`
-}
-
-type gcpSecretManagerTrait struct {
- trait.BaseTrait
- Trait `property:",squash"`
-}
-
-func NewGcpSecretManagerTrait() trait.Trait {
- return &gcpSecretManagerTrait{
- BaseTrait: trait.NewBaseTrait("gcp-secret-manager", trait.TraitOrderBeforeControllerCreation),
- }
-}
-
-func (t *gcpSecretManagerTrait) Configure(environment *trait.Environment) (bool, *trait.TraitCondition, error) {
- if environment.Integration == nil || !ptr.Deref(t.Enabled, false) {
- return false, nil, nil
- }
-
- if !environment.IntegrationInPhase(v1.IntegrationPhaseInitialization) && !environment.IntegrationInRunningPhases() {
- return false, nil, nil
- }
-
- if t.UseDefaultInstance == nil {
- t.UseDefaultInstance = ptr.To(false)
- }
-
- if t.ContextReloadEnabled == nil {
- t.ContextReloadEnabled = ptr.To(false)
- }
-
- if t.RefreshEnabled == nil {
- t.RefreshEnabled = ptr.To(false)
- }
-
- condition := trait.NewIntegrationCondition(
- "GCPSecretManager",
- v1.IntegrationConditionTraitInfo,
- corev1.ConditionTrue,
- trait.TraitConfigurationReason,
- "GCPSecretManager trait is deprecated and may be removed in future version: "+
- "configure directly the Camel properties as required by the component instead",
- )
-
- return true, condition, nil
-}
-
-func (t *gcpSecretManagerTrait) Apply(environment *trait.Environment) error {
- if environment.IntegrationInPhase(v1.IntegrationPhaseInitialization) {
- util.StringSliceUniqueAdd(&environment.Integration.Status.Capabilities, v1.CapabilityGcpSecretManager)
- }
-
- if environment.IntegrationInRunningPhases() {
- environment.ApplicationProperties["camel.vault.gcp.projectId"] = t.ProjectID
- environment.ApplicationProperties["camel.vault.gcp.serviceAccountKey"] = t.ServiceAccountKey
- environment.ApplicationProperties["camel.vault.gcp.useDefaultInstance"] = strconv.FormatBool(*t.UseDefaultInstance)
- environment.ApplicationProperties["camel.vault.gcp.refreshEnabled"] = strconv.FormatBool(*t.RefreshEnabled)
- environment.ApplicationProperties["camel.main.context-reload-enabled"] = strconv.FormatBool(*t.ContextReloadEnabled)
- environment.ApplicationProperties["camel.vault.gcp.refreshPeriod"] = t.RefreshPeriod
- environment.ApplicationProperties["camel.vault.gcp.subscriptionName"] = t.SubscriptionName
- if t.Secrets != "" {
- environment.ApplicationProperties["camel.vault.gcp.secrets"] = t.Secrets
- }
- }
-
- return nil
-}
diff --git a/addons/vault/gcp/gcp_secret_manager_test.go b/addons/vault/gcp/gcp_secret_manager_test.go
deleted file mode 100644
index 0759351a4..000000000
--- a/addons/vault/gcp/gcp_secret_manager_test.go
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
-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 gcp
-
-import (
- "testing"
-
- "github.com/apache/camel-k/v2/pkg/util/boolean"
-
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- "k8s.io/utils/ptr"
-
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- "github.com/apache/camel-k/v2/pkg/trait"
- "github.com/apache/camel-k/v2/pkg/util/camel"
-
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-)
-
-func TestGcpSecretManagerTraitApply(t *testing.T) {
- e := createEnvironment(t, camel.QuarkusCatalog)
- gcp := NewGcpSecretManagerTrait()
- secrets, _ := gcp.(*gcpSecretManagerTrait)
- secrets.Enabled = ptr.To(true)
- secrets.UseDefaultInstance = ptr.To(false)
- secrets.ProjectID = "project-gcp"
- secrets.ServiceAccountKey = "file:////usr/local/serviceaccount.json"
- ok, condition, err := secrets.Configure(e)
- require.NoError(t, err)
- assert.True(t, ok)
- assert.NotNil(t, condition)
-
- err = secrets.Apply(e)
- require.NoError(t, err)
-
- assert.Equal(t, "project-gcp", e.ApplicationProperties["camel.vault.gcp.projectId"])
- assert.Equal(t, "file:////usr/local/serviceaccount.json", e.ApplicationProperties["camel.vault.gcp.serviceAccountKey"])
- assert.Equal(t, boolean.FalseString, e.ApplicationProperties["camel.vault.gcp.useDefaultInstance"])
-}
-
-func TestGcpSecretManagerTraitNoDefaultCreds(t *testing.T) {
- e := createEnvironment(t, camel.QuarkusCatalog)
- gcp := NewGcpSecretManagerTrait()
- secrets, _ := gcp.(*gcpSecretManagerTrait)
- secrets.Enabled = ptr.To(true)
- secrets.UseDefaultInstance = ptr.To(false)
- secrets.ProjectID = "project-gcp"
- secrets.ServiceAccountKey = "file:////usr/local/serviceaccount.json"
- ok, condition, err := secrets.Configure(e)
- require.NoError(t, err)
- assert.True(t, ok)
- assert.NotNil(t, condition)
-
- err = secrets.Apply(e)
- require.NoError(t, err)
-
- assert.Equal(t, "project-gcp", e.ApplicationProperties["camel.vault.gcp.projectId"])
- assert.Equal(t, "file:////usr/local/serviceaccount.json", e.ApplicationProperties["camel.vault.gcp.serviceAccountKey"])
- assert.Equal(t, boolean.FalseString, e.ApplicationProperties["camel.vault.gcp.useDefaultInstance"])
-}
-
-func createEnvironment(t *testing.T, catalogGen func() (*camel.RuntimeCatalog, error)) *trait.Environment {
- t.Helper()
-
- catalog, err := catalogGen()
- require.NoError(t, err)
-
- e := trait.Environment{
- CamelCatalog: catalog,
- ApplicationProperties: make(map[string]string),
- }
-
- it := v1.Integration{
- ObjectMeta: metav1.ObjectMeta{
- Name: "test",
- },
- Status: v1.IntegrationStatus{
- Phase: v1.IntegrationPhaseDeploying,
- },
- }
- e.Integration = &it
- return &e
-}
diff --git a/addons/vault/gcp/zz_desc_generated.go b/addons/vault/gcp/zz_desc_generated.go
deleted file mode 100644
index 67580e41e..000000000
--- a/addons/vault/gcp/zz_desc_generated.go
+++ /dev/null
@@ -1 +0,0 @@
-package gcp
diff --git a/addons/vault/gcp/zz_generated_doc.go b/addons/vault/gcp/zz_generated_doc.go
deleted file mode 100644
index 67580e41e..000000000
--- a/addons/vault/gcp/zz_generated_doc.go
+++ /dev/null
@@ -1 +0,0 @@
-package gcp
diff --git a/addons/vault/hashicorp/client_test.go b/addons/vault/hashicorp/client_test.go
deleted file mode 100644
index 93c956a35..000000000
--- a/addons/vault/hashicorp/client_test.go
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
-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.
-*/
-
-// IMPORTANT: this is a clone of pkg/internal. As the addons will be moved into pkg, we are using this utility here temporarily only!
-
-package hashicorp
-
-import (
- "context"
- "fmt"
- "strings"
-
- "github.com/apache/camel-k/v2/pkg/apis"
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- "github.com/apache/camel-k/v2/pkg/client"
- fakecamelclientset "github.com/apache/camel-k/v2/pkg/client/camel/clientset/versioned/fake"
- camelv1 "github.com/apache/camel-k/v2/pkg/client/camel/clientset/versioned/typed/camel/v1"
- "github.com/apache/camel-k/v2/pkg/util"
- autoscalingv1 "k8s.io/api/autoscaling/v1"
- corev1 "k8s.io/api/core/v1"
- k8serrors "k8s.io/apimachinery/pkg/api/errors"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- "k8s.io/apimachinery/pkg/runtime"
- "k8s.io/apimachinery/pkg/runtime/schema"
- "k8s.io/client-go/discovery"
- "k8s.io/client-go/kubernetes"
- fakeclientset "k8s.io/client-go/kubernetes/fake"
- clientscheme "k8s.io/client-go/kubernetes/scheme"
- authorizationv1 "k8s.io/client-go/kubernetes/typed/authorization/v1"
- "k8s.io/client-go/rest"
- "k8s.io/client-go/scale"
- fakescale "k8s.io/client-go/scale/fake"
- "k8s.io/client-go/testing"
- controller "sigs.k8s.io/controller-runtime/pkg/client"
- "sigs.k8s.io/controller-runtime/pkg/client/fake"
- "sigs.k8s.io/controller-runtime/pkg/client/interceptor"
-)
-
-// newFakeClient ---.
-func newFakeClient(initObjs ...runtime.Object) (client.Client, error) {
- scheme := clientscheme.Scheme
-
- // Setup Scheme for all resources
- if err := apis.AddToScheme(scheme); err != nil {
- return nil, err
- }
-
- c := fake.
- NewClientBuilder().
- WithScheme(scheme).
- WithIndex(
- &corev1.Pod{},
- "status.phase",
- func(obj controller.Object) []string {
- pod, _ := obj.(*corev1.Pod)
- return []string{string(pod.Status.Phase)}
- },
- ).
- WithRuntimeObjects(initObjs...).
- WithStatusSubresource(&v1.IntegrationKit{}).
- Build()
-
- camelClientset := fakecamelclientset.NewSimpleClientset(filterObjects(scheme, initObjs, func(gvk schema.GroupVersionKind) bool {
- return strings.Contains(gvk.Group, "camel")
- })...)
- clientset := fakeclientset.NewSimpleClientset(filterObjects(scheme, initObjs, func(gvk schema.GroupVersionKind) bool {
- return !strings.Contains(gvk.Group, "camel") && !strings.Contains(gvk.Group, "knative")
- })...)
- replicasCount := make(map[string]int32)
- fakescaleclient := fakescale.FakeScaleClient{}
- fakescaleclient.AddReactor("update", "*", func(rawAction testing.Action) (bool, runtime.Object, error) {
- //nolint:forcetypeassert
- action := rawAction.(testing.UpdateAction)
-
- //nolint:forcetypeassert
- obj := action.GetObject().(*autoscalingv1.Scale)
-
- replicas := obj.Spec.Replicas
- key := fmt.Sprintf("%s:%s:%s/%s", action.GetResource().Group, action.GetResource().Resource, action.GetNamespace(), obj.GetName())
- replicasCount[key] = replicas
- return true, &autoscalingv1.Scale{
- ObjectMeta: metav1.ObjectMeta{
- Name: obj.Name,
- Namespace: action.GetNamespace(),
- },
- Spec: autoscalingv1.ScaleSpec{
- Replicas: replicas,
- },
- }, nil
- })
- fakescaleclient.AddReactor("get", "*", func(rawAction testing.Action) (bool, runtime.Object, error) {
- //nolint:forcetypeassert
- action := rawAction.(testing.GetAction)
-
- key := fmt.Sprintf("%s:%s:%s/%s", action.GetResource().Group, action.GetResource().Resource, action.GetNamespace(), action.GetName())
- obj := &autoscalingv1.Scale{
- ObjectMeta: metav1.ObjectMeta{
- Name: action.GetName(),
- Namespace: action.GetNamespace(),
- },
- Spec: autoscalingv1.ScaleSpec{
- Replicas: replicasCount[key],
- },
- }
- return true, obj, nil
- })
-
- return &FakeClient{
- Client: c,
- Interface: clientset,
- camel: camelClientset,
- scales: &fakescaleclient,
- enabledKnativeServing: true,
- enabledKnativeEventing: true,
- }, nil
-}
-
-func filterObjects(scheme *runtime.Scheme, input []runtime.Object, filter func(gvk schema.GroupVersionKind) bool) []runtime.Object {
- var res []runtime.Object
- for _, obj := range input {
- kinds, _, _ := scheme.ObjectKinds(obj)
- for _, k := range kinds {
- if filter(k) {
- res = append(res, obj)
- break
- }
- }
- }
- return res
-}
-
-// FakeClient ---.
-type FakeClient struct {
- controller.Client
- kubernetes.Interface
- camel *fakecamelclientset.Clientset
- scales *fakescale.FakeScaleClient
- disabledGroups []string
- enabledOpenshift bool
- enabledKnativeServing bool
- enabledKnativeEventing bool
-}
-
-func (c *FakeClient) Intercept(intercept *interceptor.Funcs) {
- //nolint:forcetypeassert
- cw := c.Client.(controller.WithWatch)
- c.Client = interceptor.NewClient(cw, *intercept)
-}
-
-func (c *FakeClient) AddReactor(verb, resource string, reaction testing.ReactionFunc) {
- c.camel.AddReactor(verb, resource, reaction)
-}
-
-func (c *FakeClient) CamelV1() camelv1.CamelV1Interface {
- return c.camel.CamelV1()
-}
-
-// GetScheme ---.
-func (c *FakeClient) GetScheme() *runtime.Scheme {
- return clientscheme.Scheme
-}
-
-func (c *FakeClient) GetConfig() *rest.Config {
- return &rest.Config{}
-}
-
-func (c *FakeClient) GetCurrentNamespace(kubeConfig string) (string, error) {
- return "", nil
-}
-
-// Patch mimicks patch for server-side apply and simply creates the obj.
-func (c *FakeClient) Patch(ctx context.Context, obj controller.Object, patch controller.Patch, opts ...controller.PatchOption) error {
- if err := c.Create(ctx, obj); err != nil {
- // Create fails if object already exists. Try to update it.
- return c.Update(ctx, obj)
- }
- return nil
-}
-
-func (c *FakeClient) DisableAPIGroupDiscovery(group string) {
- c.disabledGroups = append(c.disabledGroups, group)
-}
-
-func (c *FakeClient) EnableOpenshiftDiscovery() {
- c.enabledOpenshift = true
-}
-
-func (c *FakeClient) DisableKnativeServing() {
- c.enabledKnativeServing = false
-}
-
-func (c *FakeClient) DisableKnativeEventing() {
- c.enabledKnativeEventing = false
-}
-
-func (c *FakeClient) AuthorizationV1() authorizationv1.AuthorizationV1Interface {
- return &FakeAuthorization{
- AuthorizationV1Interface: c.Interface.AuthorizationV1(),
- disabledGroups: c.disabledGroups,
- enabledOpenshift: c.enabledOpenshift,
- }
-}
-
-func (c *FakeClient) Discovery() discovery.DiscoveryInterface {
- return &FakeDiscovery{
- DiscoveryInterface: c.Interface.Discovery(),
- disabledGroups: c.disabledGroups,
- enabledOpenshift: c.enabledOpenshift,
- enabledKnativeServing: c.enabledKnativeServing,
- enabledKnativeEventing: c.enabledKnativeEventing,
- }
-}
-
-func (c *FakeClient) ServerOrClientSideApplier() client.ServerOrClientSideApplier {
- return client.ServerOrClientSideApplier{
- Client: c,
- }
-}
-
-func (c *FakeClient) ScalesClient() (scale.ScalesGetter, error) {
- return c.scales, nil
-}
-
-type FakeAuthorization struct {
- authorizationv1.AuthorizationV1Interface
- disabledGroups []string
- enabledOpenshift bool
-}
-
-func (f *FakeAuthorization) SelfSubjectRulesReviews() authorizationv1.SelfSubjectRulesReviewInterface {
- return f.AuthorizationV1Interface.SelfSubjectRulesReviews()
-}
-
-type FakeDiscovery struct {
- discovery.DiscoveryInterface
- disabledGroups []string
- enabledOpenshift bool
- enabledKnativeServing bool
- enabledKnativeEventing bool
-}
-
-func (f *FakeDiscovery) ServerResourcesForGroupVersion(groupVersion string) (*metav1.APIResourceList, error) {
- // Normalize the fake discovery to behave like the real implementation when checking for openshift
- if groupVersion == "image.openshift.io/v1" {
- if f.enabledOpenshift {
- return &metav1.APIResourceList{
- GroupVersion: "image.openshift.io/v1",
- }, nil
- } else {
- return nil, k8serrors.NewNotFound(schema.GroupResource{
- Group: "image.openshift.io",
- }, "")
- }
- }
-
- // used to verify if Knative Serving is installed
- if f.enabledKnativeServing {
- if groupVersion == "serving.knative.dev/v1" && !util.StringSliceExists(f.disabledGroups, groupVersion) {
- return &metav1.APIResourceList{
- GroupVersion: "serving.knative.dev/v1",
- }, nil
- }
- }
-
- // used to verify if Knative Eventing is installed
- if f.enabledKnativeEventing {
- if groupVersion == "eventing.knative.dev/v1" && !util.StringSliceExists(f.disabledGroups, groupVersion) {
- return &metav1.APIResourceList{
- GroupVersion: "eventing.knative.dev/v1",
- }, nil
- }
- if groupVersion == "messaging.knative.dev/v1" && !util.StringSliceExists(f.disabledGroups, groupVersion) {
- return &metav1.APIResourceList{
- GroupVersion: "messaging.knative.dev/v1",
- }, nil
- }
- if groupVersion == "messaging.knative.dev/v1beta1" && !util.StringSliceExists(f.disabledGroups, groupVersion) {
- return &metav1.APIResourceList{
- GroupVersion: "messaging.knative.dev/v1beta1",
- }, nil
- }
- }
-
- return f.DiscoveryInterface.ServerResourcesForGroupVersion(groupVersion)
-}
diff --git a/addons/vault/hashicorp/hashicorp_vault.go b/addons/vault/hashicorp/hashicorp_vault.go
deleted file mode 100644
index d305f2025..000000000
--- a/addons/vault/hashicorp/hashicorp_vault.go
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
-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 hashicorp
-
-import (
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- traitv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1/trait"
- "github.com/apache/camel-k/v2/pkg/trait"
- "github.com/apache/camel-k/v2/pkg/util"
- "github.com/apache/camel-k/v2/pkg/util/kubernetes"
- corev1 "k8s.io/api/core/v1"
- "k8s.io/utils/ptr"
-)
-
-// The Hashicorp Vault trait can be used to use secrets from Hashicorp Vault
-//
-// The Hashicorp Vault trait is disabled by default.
-//
-// For more information about how to use secrets from Hashicorp vault take a look at the components docs: xref:components::hashicorp-vault-component.adoc[Hashicorp Vault component]
-//
-// A sample execution of this trait, would require
-// the following trait options:
-// -t hashicorp-vault.enabled=true -t hashicorp-vault.token="token" -t hashicorp-vault.port="port" -t hashicorp-vault.engine="engine" -t hashicorp-vault.port="port" -t hashicorp-vault.scheme="scheme"
-//
-// WARNING: The trait is **deprecated** and will removed in future release versions: configure directly the Camel properties as required by the component instead.
-//
-// +camel-k:trait=hashicorp-vault.
-// +camel-k:deprecated=2.5.0.
-type Trait struct {
- traitv1.Trait `property:",squash"`
- // Enables automatic configuration of the trait.
- Auto *bool `property:"auto" json:"auto,omitempty"`
- // The Host to use
- Host string `property:"host" json:"host,omitempty"`
- // The Port to use
- Port string `property:"port" json:"port,omitempty"`
- // The Hashicorp engine to use
- Engine string `property:"engine" json:"engine,omitempty"`
- // The token to access Hashicorp Vault. This could be a plain text or a configmap/secret
- // The content of the hashicorp vault token is expected to be a text containing a valid Hashicorp Vault Token.
- // Syntax: [configmap|secret]:name[/key], where name represents the resource name, key optionally represents the resource key to be filtered (default key value = hashicorp-vault-token).
- Token string `property:"token" json:"token,omitempty"`
- // The scheme to access Hashicorp Vault
- Scheme string `property:"scheme" json:"scheme,omitempty"`
-}
-
-type hashicorpVaultTrait struct {
- trait.BaseTrait
- Trait `property:",squash"`
-}
-
-func NewHashicorpVaultTrait() trait.Trait {
- return &hashicorpVaultTrait{
- BaseTrait: trait.NewBaseTrait("hashicorp-vault", trait.TraitOrderBeforeControllerCreation),
- }
-}
-
-func (t *hashicorpVaultTrait) Configure(environment *trait.Environment) (bool, *trait.TraitCondition, error) {
- if environment.Integration == nil || !ptr.Deref(t.Enabled, false) {
- return false, nil, nil
- }
-
- if !environment.IntegrationInPhase(v1.IntegrationPhaseInitialization) && !environment.IntegrationInRunningPhases() {
- return false, nil, nil
- }
-
- condition := trait.NewIntegrationCondition(
- "HashicorpVault",
- v1.IntegrationConditionTraitInfo,
- corev1.ConditionTrue,
- trait.TraitConfigurationReason,
- "HashicorpVault trait is deprecated and may be removed in future version: "+
- "configure directly the Camel properties as required by the component instead",
- )
-
- return true, condition, nil
-}
-
-func (t *hashicorpVaultTrait) Apply(environment *trait.Environment) error {
- if environment.IntegrationInPhase(v1.IntegrationPhaseInitialization) {
- util.StringSliceUniqueAdd(&environment.Integration.Status.Capabilities, v1.CapabilityHashicorpVault)
- }
-
- if !environment.IntegrationInRunningPhases() {
- return nil
- }
-
- hits := v1.PlainConfigSecretRegexp.FindAllStringSubmatch(t.Token, -1)
- if len(hits) >= 1 {
- var res, _ = v1.DecodeValueSource(t.Token, "hashicorp-vault-token")
-
- secretValue, err := kubernetes.ResolveValueSource(environment.Ctx, environment.Client, environment.Platform.Namespace, &res)
- if err != nil {
- return err
- }
- if secretValue != "" {
- environment.ApplicationProperties["camel.vault.hashicorp.token"] = secretValue
- }
- } else {
- environment.ApplicationProperties["camel.vault.hashicorp.token"] = t.Token
- }
-
- environment.ApplicationProperties["camel.vault.hashicorp.host"] = t.Host
- environment.ApplicationProperties["camel.vault.hashicorp.port"] = t.Port
- environment.ApplicationProperties["camel.vault.hashicorp.engine"] = t.Engine
- environment.ApplicationProperties["camel.vault.hashicorp.scheme"] = t.Scheme
-
- return nil
-}
diff --git a/addons/vault/hashicorp/hashicorp_vault_test.go b/addons/vault/hashicorp/hashicorp_vault_test.go
deleted file mode 100644
index f9415f64b..000000000
--- a/addons/vault/hashicorp/hashicorp_vault_test.go
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
-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 hashicorp
-
-import (
- "testing"
-
- corev1 "k8s.io/api/core/v1"
- "k8s.io/utils/ptr"
-
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- "github.com/apache/camel-k/v2/pkg/trait"
- "github.com/apache/camel-k/v2/pkg/util/camel"
-
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
- "k8s.io/apimachinery/pkg/runtime"
-)
-
-func TestHashicorpVaultTraitApply(t *testing.T) {
- e := createEnvironment(t, camel.QuarkusCatalog)
- hashicorp := NewHashicorpVaultTrait()
- secrets, _ := hashicorp.(*hashicorpVaultTrait)
- secrets.Enabled = ptr.To(true)
- secrets.Engine = "test"
- secrets.Token = "wwww.testx1234590"
- secrets.Host = "localhost"
- secrets.Port = "9091"
- secrets.Scheme = "http"
- ok, condition, err := secrets.Configure(e)
- require.NoError(t, err)
- assert.True(t, ok)
- assert.NotNil(t, condition)
-
- err = secrets.Apply(e)
- require.NoError(t, err)
-
- assert.Empty(t, e.ApplicationProperties["quarkus.jaeger.enabled"])
- assert.Equal(t, "test", e.ApplicationProperties["camel.vault.hashicorp.engine"])
- assert.Equal(t, "wwww.testx1234590", e.ApplicationProperties["camel.vault.hashicorp.token"])
- assert.Equal(t, "localhost", e.ApplicationProperties["camel.vault.hashicorp.host"])
- assert.Equal(t, "9091", e.ApplicationProperties["camel.vault.hashicorp.port"])
- assert.Equal(t, "http", e.ApplicationProperties["camel.vault.hashicorp.scheme"])
-}
-
-func TestHashicorpVaultTraitWithSecretApply(t *testing.T) {
- e := createEnvironment(t, camel.QuarkusCatalog, &corev1.Secret{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "test",
- Name: "my-secret1",
- },
- Data: map[string][]byte{
- "hashicorp-vault-token": []byte("my-hashicorp-vault-token"),
- },
- })
- hashicorp := NewHashicorpVaultTrait()
- secrets, _ := hashicorp.(*hashicorpVaultTrait)
- secrets.Enabled = ptr.To(true)
- secrets.Engine = "test"
- secrets.Token = "secret:my-secret1/hashicorp-vault-token"
- secrets.Host = "localhost"
- secrets.Port = "9091"
- secrets.Scheme = "http"
- ok, condition, err := secrets.Configure(e)
- require.NoError(t, err)
- assert.True(t, ok)
- assert.NotNil(t, condition)
-
- err = secrets.Apply(e)
- require.NoError(t, err)
-
- assert.Empty(t, e.ApplicationProperties["quarkus.jaeger.enabled"])
- assert.Equal(t, "test", e.ApplicationProperties["camel.vault.hashicorp.engine"])
- assert.Equal(t, "my-hashicorp-vault-token", e.ApplicationProperties["camel.vault.hashicorp.token"])
- assert.Equal(t, "localhost", e.ApplicationProperties["camel.vault.hashicorp.host"])
- assert.Equal(t, "9091", e.ApplicationProperties["camel.vault.hashicorp.port"])
- assert.Equal(t, "http", e.ApplicationProperties["camel.vault.hashicorp.scheme"])
-}
-
-func TestHashicorpVaultTraitWithConfigMapApply(t *testing.T) {
- e := createEnvironment(t, camel.QuarkusCatalog, &corev1.ConfigMap{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "test",
- Name: "my-configmap1",
- },
- Data: map[string]string{
- "hashicorp-vault-token": "my-hashicorp-vault-token",
- },
- })
- hashicorp := NewHashicorpVaultTrait()
- secrets, _ := hashicorp.(*hashicorpVaultTrait)
- secrets.Enabled = ptr.To(true)
- secrets.Engine = "test"
- secrets.Token = "configmap:my-configmap1/hashicorp-vault-token"
- secrets.Host = "localhost"
- secrets.Port = "9091"
- secrets.Scheme = "http"
- ok, condition, err := secrets.Configure(e)
- require.NoError(t, err)
- assert.True(t, ok)
- assert.NotNil(t, condition)
-
- err = secrets.Apply(e)
- require.NoError(t, err)
-
- assert.Empty(t, e.ApplicationProperties["quarkus.jaeger.enabled"])
- assert.Equal(t, "test", e.ApplicationProperties["camel.vault.hashicorp.engine"])
- assert.Equal(t, "my-hashicorp-vault-token", e.ApplicationProperties["camel.vault.hashicorp.token"])
- assert.Equal(t, "localhost", e.ApplicationProperties["camel.vault.hashicorp.host"])
- assert.Equal(t, "9091", e.ApplicationProperties["camel.vault.hashicorp.port"])
- assert.Equal(t, "http", e.ApplicationProperties["camel.vault.hashicorp.scheme"])
-}
-
-func createEnvironment(t *testing.T, catalogGen func() (*camel.RuntimeCatalog, error), objects ...runtime.Object) *trait.Environment {
- t.Helper()
-
- catalog, err := catalogGen()
- client, _ := newFakeClient(objects...)
- require.NoError(t, err)
-
- e := trait.Environment{
- CamelCatalog: catalog,
- ApplicationProperties: make(map[string]string),
- Client: client,
- }
-
- it := v1.Integration{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "test",
- Name: "test",
- },
- Status: v1.IntegrationStatus{
- Phase: v1.IntegrationPhaseDeploying,
- },
- }
- platform := v1.IntegrationPlatform{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "test",
- Name: "test",
- },
- }
- e.Integration = &it
- e.Platform = &platform
- return &e
-}
diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc
index 0a668f892..71d8db636 100644
--- a/docs/modules/ROOT/nav.adoc
+++ b/docs/modules/ROOT/nav.adoc
@@ -44,10 +44,7 @@
** xref:configuration/runtime-version.adoc[Camel version]
* 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:aws-secrets-manager.adoc[Aws Secrets Manager]
-** xref:traits:azure-key-vault.adoc[Azure Key Vault]
** xref:traits:builder.adoc[Builder]
** xref:traits:camel.adoc[Camel]
** xref:traits:container.adoc[Container]
@@ -55,8 +52,6 @@
** xref:traits:deployer.adoc[Deployer]
** xref:traits:deployment.adoc[Deployment]
** xref:traits:environment.adoc[Environment]
-** xref:traits:gcp-secret-manager.adoc[Gcp Secret Manager]
-** xref:traits:hashicorp-vault.adoc[Hashicorp Vault]
** xref:traits:health.adoc[Health]
** xref:traits:ingress.adoc[Ingress]
** xref:traits:init-containers.adoc[Init Containers]
@@ -70,7 +65,6 @@
** xref:traits:logging.adoc[Logging]
** xref:traits:master.adoc[Master]
** xref:traits:mount.adoc[Mount]
-** xref:traits:openapi.adoc[Openapi]
** xref:traits:owner.adoc[Owner]
** xref:traits:pdb.adoc[Pdb]
** xref:traits:platform.adoc[Platform]
@@ -78,7 +72,6 @@
** xref:traits:prometheus.adoc[Prometheus]
** xref:traits:pull-secret.adoc[Pull Secret]
** xref:traits:quarkus.adoc[Quarkus]
-** xref:traits:resume.adoc[Resume]
** xref:traits:route.adoc[Route]
** xref:traits:security-context.adoc[Security Context]
** xref:traits:service.adoc[Service]
diff --git a/docs/modules/ROOT/pages/languages/groovy.adoc b/docs/modules/ROOT/pages/languages/groovy.adoc
deleted file mode 100644
index 0c3eb99b9..000000000
--- a/docs/modules/ROOT/pages/languages/groovy.adoc
+++ /dev/null
@@ -1,195 +0,0 @@
-= Writing Integrations in Groovy
-
-[WARNING]
-====
-The Groovy DSL is experimental.
-====
-
-An integration written in Groovy looks very similar to a Java one except it can leverages Groovy's language enhancements over Java such as closures:
-
-[source,groovy]
-----
-from('timer:tick')
- .process { it.in.body = 'Hello Camel K!' }
- .to('log:info')
-----
-
-You can run it with the standard command:
-
-[source]
-----
-kamel run example.groovy
-----
-
-== Configuring the Application
-
-Camel K extends the Camel Java DSL making it easier to configure Camel's behavior using the top level _camel_ block
-
-[source,groovy]
-----
-camel {
- // configure camel here
-}
-----
-
-The _camel_ block allows to configure the following Camel features:
-
-- **Components**
-+
-[source,groovy]
-----
-camel {
- components {
- seda { // <1>
- queueSize = 1234
- concurrentConsumers = 12
- }
-
- log { // <2>
- exchangeFormatter = {
- 'body ==> ' + it.in.body
- } as org.apache.camel.spi.ExchangeFormatter
- }
-
- mySeda(SedaComponent) { // <3>
- queueSize = 4321
- concurrentConsumers = 21
- }
- }
-}
-----
-<1> configure the properties of the component whit name _seda_
-<2> configure the properties of the component whit name _log_
-<3> creates and configure a component of type `SedaComponent` whose name is _mySeda_
-+
-Setting the property _exchangeFormatter_ looks a little ugly as you have to declare the type of your closure. For demonstration purpose, we have created a Groovy extension module that simplifies configuring the _exchangeFormatter_ so you can rewrite your DSL as
-+
-[source,groovy]
-----
-camel {
- components {
- log {
- formatter {
- 'body ==> ' + it.in.body
- }
- }
- }
-}
-----
-+
-which is much better.
-+
-[TIP]
-====
-You can provide your custom extensions by packaging them in a dependency you declare for your integration.
-====
-
-- **Languages **
-+
-[source,groovy]
-----
-camel {
- languages {
- language("bean") { // <1>
- beanType = String.class
- method = "toUpperCase"
- }
- myBean(BeanLanguage) { // <2>
- beanType = String.class
- method = "toLowerCase"
- }
- simple { // <3>
- }
- }
-}
-----
-<1> configure the properties of the language whit name _bean_
-<2> creates and configure a language of type `BeanLanguage` whose name is _myBean_
-<3> configure the properties of the language whit name _simple_
-
-- **DataFormats**
-+
-[source,groovy]
-----
-camel {
- dataFormats {
- dataFormat("json-jackson") { // <1>
- unmarshalType = Map.class
- prettyPrint = true
- }
- myJackson(JacksonDataFormat) { // <2>
- unmarshalType = String.class
- prettyPrint = false
- }
- csv { // <3>
- }
- }
-}
-----
-<1> configure the properties of the data format whit name _json-jackson_
-<2> creates and configure a data format of type `JacksonDataFormat` whose name is _myJackson_
-<3> configure the properties of the data format whit name _csv_
-
-
-== Beans
-
-Beans can be bound to the _registry_ using a dedicated _bean DSL_ :
-
-[source,groovy]
-----
-beans {
- myCache = Caffeine.newBuilder().build() // <1>
-
- myProcessor = processor { // <2>
- it.in.body = 'Hello Camel K!'
- }
-
- myPredicate = predicate { // <3>
- it.in.body != null
- }
-
- dataSource(org.apache.commons.dbcp2.BasicDataSource) { //<4>
- driverClassName = "org.h2.Driver"
- url = "jdbc:h2:mem:camel"
- username = "sa"
- password = ""
- }
-}
-----
-<1> define a bean
-<2> define a custom processor
-<3> define a custom predicate
-<4> define a custom bean with name `dataSource` and type `org.apache.commons.dbcp2.BasicDataSource`
-
-
-== Rest Support
-
-Integrations REST endpoints can be configured using the top level _rest_ block:
-
-[source,groovy]
-----
-rest {
- configuration { // <1>
- host = 'my-host'
- port '9192'
- }
-
- path('/my/path') {
- get('/get') { // <2>
- consumes 'application/json'
- produces 'application/json'
- to 'direct:get'
- }
- }
-
- post { // <3>
- path '/post'
- consumes 'application/json'
- produces 'application/json'
- to 'direct:post'
- }
-}
-----
-<1> Configure the rest engine
-<2> Configure the behavior of the method GET for the path '/my/path/get' and invoke the endpoint 'direct:get'
-<3> Configure the behavior of the method POST for the path '/post' and invoke the endpoint 'direct:post'
diff --git a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
index a58abb7a0..97f23d04a 100644
--- a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
+++ b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
@@ -8292,6 +8292,8 @@ Deprecated: no longer available since version 2.5.
* <<#_camel_apache_org_v1_Traits, Traits>>
+WARNING: The OpenAPI trait was deprecated in version 2.5.0 and is no longer active since version 2.9.0.
+
The OpenAPI DSL trait is internally used to allow creating integrations from a OpenAPI specs.
WARNING: The Openapi trait is **deprecated** and will removed in future release versions:
diff --git a/e2e/advanced/kamelet_repo_test.go b/e2e/advanced/kamelet_repo_test.go
index 19a803014..f47713a4f 100644
--- a/e2e/advanced/kamelet_repo_test.go
+++ b/e2e/advanced/kamelet_repo_test.go
@@ -42,16 +42,23 @@ func TestKameletFromCustomRepository(t *testing.T) {
kameletName := "timer-custom-source"
removeKamelet(t, ctx, kameletName, ns)
g.Eventually(Kamelet(t, ctx, kameletName, ns)).Should(BeNil())
- g.Eventually(PlatformPhase(t, ctx, ns), TestTimeoutShort).Should(Equal(v1.IntegrationPlatformPhaseReady))
+
+ g.Eventually(Platform(t, ctx, ns)).ShouldNot(BeNil())
+ pl := Platform(t, ctx, ns)()
+ pl.Spec.Kamelet.Repositories = []v1.KameletRepositorySpec{
+ {URI: "github:squakez/ck-kamelet-test-repo/kamelets"},
+ }
+ TestClient(t).Update(ctx, pl)
+ g.Eventually(Platform(t, ctx, ns)).ShouldNot(BeNil())
+ g.Eventually(PlatformHas(t, ctx, ns, func(pl *v1.IntegrationPlatform) bool {
+ return len(pl.Status.Kamelet.Repositories) > 0 && pl.Status.Kamelet.Repositories[0].URI == "github:squakez/ck-kamelet-test-repo/kamelets"
+ }), TestTimeoutShort).Should(BeTrue())
+
// Add the custom repository
- g.Expect(Kamel(t, ctx, "kamelet", "add-repo", "github:squakez/ck-kamelet-test-repo/kamelets", "-n", ns).Execute()).To(Succeed())
g.Expect(KamelRun(t, ctx, ns, "files/TimerCustomKameletIntegration.java").Execute()).To(Succeed())
g.Eventually(IntegrationPodPhase(t, ctx, ns, "timer-custom-kamelet-integration"), TestTimeoutMedium).
Should(Equal(corev1.PodRunning))
g.Eventually(IntegrationLogs(t, ctx, ns, "timer-custom-kamelet-integration")).Should(ContainSubstring("hello world"))
-
- // Remove the custom repository
- g.Expect(Kamel(t, ctx, "kamelet", "remove-repo", "github:squakez/ck-kamelet-test-repo/kamelets", "-n", ns).Execute()).To(Succeed())
})
}
diff --git a/e2e/common/cli/config_test.go b/e2e/common/cli/config_test.go
deleted file mode 100644
index 78b8131ee..000000000
--- a/e2e/common/cli/config_test.go
+++ /dev/null
@@ -1,70 +0,0 @@
-//go:build integration
-// +build integration
-
-// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration"
-
-/*
-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 common
-
-import (
- "context"
- "os"
- "strings"
- "testing"
-
- corev1 "k8s.io/api/core/v1"
-
- . "github.com/onsi/gomega"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-
- . "github.com/apache/camel-k/v2/e2e/support"
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- "github.com/apache/camel-k/v2/pkg/cmd"
-)
-
-func TestKamelCLIConfig(t *testing.T) {
- t.Parallel()
- WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
- t.Run("check default namespace", func(t *testing.T) {
- _, err := os.Stat(cmd.DefaultConfigLocation)
- assert.True(t, os.IsNotExist(err), "No file at "+cmd.DefaultConfigLocation+" was expected")
- t.Cleanup(func() { os.Remove(cmd.DefaultConfigLocation) })
- g.Expect(Kamel(t, ctx, "config", "--default-namespace", ns).Execute()).To(Succeed())
- _, err = os.Stat(cmd.DefaultConfigLocation)
- require.NoError(t, err, "A file at "+cmd.DefaultConfigLocation+" was expected")
- g.Expect(KamelRun(t, ctx, ns, "files/yaml.yaml").Execute()).To(Succeed())
-
- g.Eventually(IntegrationPodPhase(t, ctx, ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- g.Eventually(IntegrationConditionStatus(t, ctx, ns, "yaml", v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionTrue))
- g.Eventually(IntegrationLogs(t, ctx, ns, "yaml"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-
- // first line of the integration logs
- logs := strings.Split(IntegrationLogs(t, ctx, ns, "yaml")(), "\n")[0]
- podName := IntegrationPod(t, ctx, ns, "yaml")().Name
-
- logsCLI := GetOutputStringAsync(Kamel(t, ctx, "log", "yaml"))
- g.Eventually(logsCLI).Should(ContainSubstring("Monitoring pod " + podName))
- g.Eventually(logsCLI).Should(ContainSubstring(logs))
- })
-
- g.Expect(Kamel(t, ctx, "delete", "--all", "-n", ns).Execute()).To(Succeed())
- })
-}
diff --git a/e2e/common/cli/describe_test.go b/e2e/common/cli/describe_test.go
deleted file mode 100644
index 6014ddaa4..000000000
--- a/e2e/common/cli/describe_test.go
+++ /dev/null
@@ -1,74 +0,0 @@
-//go:build integration
-// +build integration
-
-// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration"
-
-/*
-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 common
-
-import (
- "context"
- "regexp"
- "testing"
-
- . "github.com/onsi/gomega"
-
- corev1 "k8s.io/api/core/v1"
-
- . "github.com/apache/camel-k/v2/e2e/support"
- "github.com/apache/camel-k/v2/pkg/util/defaults"
-)
-
-func TestKamelCliDescribe(t *testing.T) {
- t.Parallel()
- WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
- g.Expect(KamelRun(t, ctx, ns, "files/yaml.yaml").Execute()).To(Succeed())
- g.Eventually(IntegrationPodPhase(t, ctx, ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
-
- t.Run("Test kamel describe integration", func(t *testing.T) {
- integration := GetOutputString(Kamel(t, ctx, "describe", "integration", "yaml", "-n", ns))
- r, _ := regexp.Compile("(?sm).*Name:\\s+yaml.*")
- g.Expect(integration).To(MatchRegexp(r.String()))
-
- r, _ = regexp.Compile("(?sm).*Phase:\\s+Running.*")
- g.Expect(integration).To(MatchRegexp(r.String()))
-
- g.Expect(integration).To(ContainSubstring("Dependencies:"))
- g.Expect(integration).To(ContainSubstring("Conditions:"))
- })
-
- t.Run("Test kamel describe integration kit", func(t *testing.T) {
- kitName := Integration(t, ctx, ns, "yaml")().Status.IntegrationKit.Name
- kitNamespace := Integration(t, ctx, ns, "yaml")().Status.IntegrationKit.Namespace
- kit := GetOutputString(Kamel(t, ctx, "describe", "kit", kitName, "-n", kitNamespace))
-
- r, _ := regexp.Compile("(?sm).*Namespace:\\s+" + kitNamespace + ".*")
- g.Expect(kit).To(MatchRegexp(r.String()))
-
- r, _ = regexp.Compile("(?sm).*Runtime Version:\\s+" + defaults.DefaultRuntimeVersion + ".*")
- g.Expect(kit).To(MatchRegexp(r.String()))
-
- g.Expect(kit).To(ContainSubstring("camel-quarkus-core"))
-
- g.Expect(kit).To(ContainSubstring("Artifacts:"))
- g.Expect(kit).To(ContainSubstring("Dependencies:"))
- })
-
- })
-}
diff --git a/e2e/common/languages/groovy_test.go b/e2e/common/languages/groovy_test.go
deleted file mode 100644
index 8855d4969..000000000
--- a/e2e/common/languages/groovy_test.go
+++ /dev/null
@@ -1,47 +0,0 @@
-//go:build integration
-// +build integration
-
-// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration"
-
-/*
-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 common
-
-import (
- "context"
- "testing"
-
- . "github.com/onsi/gomega"
-
- corev1 "k8s.io/api/core/v1"
-
- . "github.com/apache/camel-k/v2/e2e/support"
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
-)
-
-func TestRunSimpleGroovyExamples(t *testing.T) {
- t.Parallel()
- WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
- t.Run("run groovy", func(t *testing.T) {
- g.Expect(KamelRun(t, ctx, ns, "files/groovy.groovy").Execute()).To(Succeed())
- g.Eventually(IntegrationPodPhase(t, ctx, ns, "groovy"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- g.Eventually(IntegrationConditionStatus(t, ctx, ns, "groovy", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- g.Eventually(IntegrationLogs(t, ctx, ns, "groovy"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- })
- })
-}
diff --git a/e2e/common/traits/openapi_test.go b/e2e/common/traits/openapi_test.go
deleted file mode 100644
index b87ebee48..000000000
--- a/e2e/common/traits/openapi_test.go
+++ /dev/null
@@ -1,71 +0,0 @@
-//go:build integration
-// +build integration
-
-// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration"
-
-/*
-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 common
-
-import (
- "context"
- "fmt"
- "os"
- "testing"
- "time"
-
- . "github.com/onsi/gomega"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-
- corev1 "k8s.io/api/core/v1"
-
- . "github.com/apache/camel-k/v2/e2e/support"
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
-)
-
-func TestOpenAPITrait(t *testing.T) {
- t.Parallel()
- WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
- name := RandomizedSuffixName("petstore")
- openapiContent, err := os.ReadFile("./files/petstore-api.yaml")
- require.NoError(t, err)
- var cmDataProps = make(map[string]string)
- cmDataProps["petstore-api.yaml"] = string(openapiContent)
- CreatePlainTextConfigmap(t, ctx, ns, "my-openapi", cmDataProps)
-
- g.Expect(KamelRun(t, ctx, ns,
- "--name", name, "--open-api", "configmap:my-openapi", "files/petstore.yaml").
- Execute()).To(Succeed())
-
- g.Eventually(IntegrationConditionStatus(t, ctx, ns, name, v1.IntegrationConditionReady), TestTimeoutMedium).
- Should(Equal(corev1.ConditionTrue))
- g.Eventually(Service(t, ctx, ns, name), TestTimeoutShort).ShouldNot(BeNil())
- g.Eventually(IntegrationPodPhase(t, ctx, ns, name)).Should(Equal(corev1.PodRunning))
- // Let's make sure the Integration is ready to receive traffic
- g.Eventually(IntegrationLogs(t, ctx, ns, name)).Should(ContainSubstring("Listening on: http://0.0.0.0:8080"))
- pod := IntegrationPod(t, ctx, ns, name)()
- g.Expect(pod).NotTo(BeNil())
- response, err := TestClient(t).CoreV1().RESTClient().Get().
- Timeout(30 * time.Second).
- AbsPath(fmt.Sprintf("/api/v1/namespaces/%s/pods/%s/proxy/v1/pets", pod.Namespace, pod.Name)).
- DoRaw(ctx)
- require.NoError(t, err)
- assert.Equal(t, "listPets", string(response))
- })
-}
diff --git a/e2e/knative/openapi_test.go b/e2e/knative/openapi_test.go
index 00ea85fdf..3bb7dd107 100644
--- a/e2e/knative/openapi_test.go
+++ b/e2e/knative/openapi_test.go
@@ -29,8 +29,6 @@ import (
"testing"
"time"
- "io/ioutil"
-
. "github.com/apache/camel-k/v2/e2e/support"
v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
. "github.com/onsi/gomega"
@@ -39,35 +37,6 @@ import (
corev1 "k8s.io/api/core/v1"
)
-func TestOpenAPIKnativeTrait(t *testing.T) {
- WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
- name := RandomizedSuffixName("petstore")
- openapiContent, err := ioutil.ReadFile("./files/petstore-api.yaml")
- require.NoError(t, err)
- var cmDataProps = make(map[string]string)
- cmDataProps["petstore-api.yaml"] = string(openapiContent)
- CreatePlainTextConfigmap(t, ctx, ns, "my-openapi-knative", cmDataProps)
-
- g.Expect(KamelRun(t, ctx, ns, "--name", name, "--open-api", "configmap:my-openapi-knative", "files/petstore.yaml").Execute()).To(Succeed())
-
- g.Eventually(KnativeService(t, ctx, ns, name), TestTimeoutLong).
- Should(Not(BeNil()))
- g.Eventually(IntegrationConditionStatus(t, ctx, ns, name, v1.IntegrationConditionReady), TestTimeoutMedium).
- Should(Equal(corev1.ConditionTrue))
- g.Eventually(IntegrationPodPhase(t, ctx, ns, name)).Should(Equal(corev1.PodRunning))
- // Let's make sure the Integration is ready to receive traffic
- g.Eventually(IntegrationLogs(t, ctx, ns, name)).Should(ContainSubstring("Listening on: http://0.0.0.0:8080"))
- pod := IntegrationPod(t, ctx, ns, name)()
- g.Expect(pod).NotTo(BeNil())
- response, err := TestClient(t).CoreV1().RESTClient().Get().
- Timeout(30 * time.Second).
- AbsPath(fmt.Sprintf("/api/v1/namespaces/%s/pods/%s/proxy/v1/pets", pod.Namespace, pod.Name)).
- DoRaw(ctx)
- require.NoError(t, err)
- assert.Equal(t, "listPets", string(response))
- })
-}
-
func TestOpenAPIKnativeContractFirst(t *testing.T) {
t.Parallel()
WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
diff --git a/e2e/native/files/Groovy.groovy b/e2e/native/files/Groovy.groovy
deleted file mode 100644
index baeaa9c0c..000000000
--- a/e2e/native/files/Groovy.groovy
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * 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.
- */
-
-from('timer:tick')
- .setHeader('m').constant('string!')
- .setBody().simple('Magic${header.m}')
- .log('Groovy ${body}')
diff --git a/pkg/apis/camel/v1/common_types.go b/pkg/apis/camel/v1/common_types.go
index dd06d6337..e81d3f9c0 100644
--- a/pkg/apis/camel/v1/common_types.go
+++ b/pkg/apis/camel/v1/common_types.go
@@ -505,34 +505,18 @@ type Language string
const (
// LanguageJavaSource used for Java.
LanguageJavaSource Language = "java"
- // LanguageGroovy used for Groovy.
- // Deprecated: language no longer supported.
- LanguageGroovy Language = "groovy"
- // LanguageJavaScript used for Javascript.
- // Deprecated: language no longer supported.
- LanguageJavaScript Language = "js"
// LanguageXML used for XML.
LanguageXML Language = "xml"
- // LanguageKotlin used for Kotlin.
- // Deprecated: language no longer supported.
- LanguageKotlin Language = "kts"
// LanguageYaml used for YAML.
LanguageYaml Language = "yaml"
// LanguageKamelet used for Kamelets.
LanguageKamelet Language = "kamelet"
- // LanguageJavaShell used for Java Shell.
- // Deprecated: language no longer supported.
- LanguageJavaShell Language = "jsh"
)
// Languages is the list of all supported languages.
var Languages = []Language{
LanguageJavaSource,
- LanguageGroovy,
- LanguageJavaScript,
LanguageXML,
- LanguageKotlin,
LanguageYaml,
LanguageKamelet,
- LanguageJavaShell,
}
diff --git a/pkg/apis/camel/v1/integration_types_support_test.go b/pkg/apis/camel/v1/integration_types_support_test.go
index 1481339e0..157b2b635 100644
--- a/pkg/apis/camel/v1/integration_types_support_test.go
+++ b/pkg/apis/camel/v1/integration_types_support_test.go
@@ -30,9 +30,6 @@ import (
func TestAllLanguages(t *testing.T) {
assert.Contains(t, Languages, LanguageJavaSource)
- assert.Contains(t, Languages, LanguageJavaScript)
- assert.Contains(t, Languages, LanguageGroovy)
- assert.Contains(t, Languages, LanguageKotlin)
assert.Contains(t, Languages, LanguageXML)
assert.Contains(t, Languages, LanguageYaml)
}
@@ -59,9 +56,9 @@ func TestLanguageAlreadySet(t *testing.T) {
DataSpec: DataSpec{
Name: "Request.java",
},
- Language: LanguageJavaScript,
+ Language: LanguageJavaSource,
}
- assert.Equal(t, LanguageJavaScript, code.InferLanguage())
+ assert.Equal(t, LanguageJavaSource, code.InferLanguage())
}
func TestAddDependency(t *testing.T) {
diff --git a/pkg/apis/camel/v1/trait/openapi.go b/pkg/apis/camel/v1/trait/openapi.go
index 29499c7dd..c2acd8c36 100644
--- a/pkg/apis/camel/v1/trait/openapi.go
+++ b/pkg/apis/camel/v1/trait/openapi.go
@@ -17,13 +17,15 @@ limitations under the License.
package trait
+// WARNING: The OpenAPI trait was deprecated in version 2.5.0 and is no longer active since version 2.9.0.
+//
// The OpenAPI DSL trait is internally used to allow creating integrations from a OpenAPI specs.
//
// WARNING: The Openapi trait is **deprecated** and will removed in future release versions:
// use Camel REST contract first instead (see Camel core documentation).
//
// +camel-k:trait=openapi.
-// +camel-k:deprecated=2.5.0.
+// +camel-k:internal.
type OpenAPITrait struct {
PlatformBaseTrait `property:",squash" json:",inline"`
// The configmaps holding the spec of the OpenAPI (compatible with > 3.0 spec only).
diff --git a/pkg/cmd/completion_bash.go b/pkg/cmd/completion_bash.go
index b4e684c09..28970ca07 100644
--- a/pkg/cmd/completion_bash.go
+++ b/pkg/cmd/completion_bash.go
@@ -71,7 +71,7 @@ __kamel_dependency_type() {
}
__kamel_languages() {
- local type_list="js groovy kotlin java xml"
+ local type_list="java xml yaml"
COMPREPLY=( $( compgen -W "${type_list}" -- "$cur") )
}
diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go
deleted file mode 100644
index 99d1f5ed9..000000000
--- a/pkg/cmd/config.go
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
-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 cmd
-
-import (
- "errors"
- "fmt"
- "os"
- "path/filepath"
-
- "github.com/spf13/cobra"
- "github.com/spf13/viper"
- "gopkg.in/yaml.v2"
-)
-
-// ConfigFolder defines the different types of folder containing the configuration file.
-type ConfigFolder string
-
-const (
- // The path of the folder containing the configuration file is retrieved from the environment
- // variable KAMEL_CONFIG_PATH.
- ConfigFolderEnvVar ConfigFolder = "env"
- // The path of the folder containing the configuration file is $HOME/.kamel.
- ConfigFolderHome ConfigFolder = "home"
- // The folder containing the configuration file is .kamel located in the working directory.
- ConfigFolderSubDirectory ConfigFolder = "sub"
- // The folder containing the configuration file is the working directory.
- ConfigFolderWorking ConfigFolder = "working"
- // The folder containing the configuration file is the directory currently used by Kamel.
- ConfigFolderUsed ConfigFolder = "used"
-)
-
-func newCmdConfig(rootCmdOptions *RootCmdOptions) (*cobra.Command, *configCmdOptions) {
- options := configCmdOptions{}
- cmd := cobra.Command{
- Use: "config",
- Short: "Configure the default settings",
- Deprecated: "no longer supported.",
- PreRunE: decode(&options, rootCmdOptions.Flags),
- Args: options.validateArgs,
- RunE: options.run,
- }
-
- cmd.Flags().String("folder", "used", "The type of folder containing the configuration file to read/write. The supported values are 'env', 'home', 'sub', 'working' and 'used' for respectively $KAMEL_CONFIG_PATH, $HOME/.kamel, .kamel, . and the folder used by kamel")
- cmd.Flags().String("default-namespace", "", "The name of the namespace to use by default")
- cmd.Flags().BoolP("list", "l", false, "List all existing settings")
- return &cmd, &options
-}
-
-type configCmdOptions struct {
- DefaultNamespace string `mapstructure:"default-namespace"`
-}
-
-func (o *configCmdOptions) validateArgs(cmd *cobra.Command, args []string) error {
- if len(args) > 0 {
- return errors.New("no arguments are expected")
- }
- return nil
-}
-
-func (o *configCmdOptions) run(cmd *cobra.Command, args []string) error {
- path, err := getConfigLocation(cmd)
- if err != nil {
- return err
- }
- if cmd.Flags().Lookup("default-namespace").Changed {
- err = o.saveConfiguration(cmd, path)
- if err != nil {
- return err
- }
- }
- if cmd.Flags().Lookup("list").Changed {
- err = printConfiguration(cmd, path)
- if err != nil {
- return err
- }
- }
- return nil
-}
-
-// Save the configuration at the given location.
-func (o *configCmdOptions) saveConfiguration(cmd *cobra.Command, path string) error {
- cfg, err := LoadConfigurationFrom(path)
- if err != nil {
- return err
- }
-
- cfg.Update(cmd, pathToRoot(cmd), o, true)
-
- err = cfg.Save()
- if err != nil {
- return err
- }
- return nil
-}
-
-// Gives the location of the configuration file.
-func getConfigLocation(cmd *cobra.Command) (string, error) {
- var folder ConfigFolder
- if s, err := cmd.Flags().GetString("folder"); err == nil {
- folder = ConfigFolder(s)
- } else {
- return "", err
- }
- var path string
- switch folder {
- case ConfigFolderUsed:
- path = viper.ConfigFileUsed()
- if path != "" {
- return path, nil
- }
- case ConfigFolderEnvVar:
- path = os.Getenv("KAMEL_CONFIG_PATH")
- case ConfigFolderHome:
- home, err := os.UserHomeDir()
- cobra.CheckErr(err)
- path = filepath.Join(home, ".kamel")
- case ConfigFolderSubDirectory:
- path = ".kamel"
- case ConfigFolderWorking:
- path = "."
- default:
- return "", fmt.Errorf("unsupported type of folder: %s", folder)
- }
- configName := os.Getenv("KAMEL_CONFIG_NAME")
- if configName == "" {
- configName = DefaultConfigName
- }
- return filepath.Join(path, fmt.Sprintf("%s.yaml", configName)), nil
-}
-
-// Print the content of the configuration file located at the given path.
-func printConfiguration(cmd *cobra.Command, path string) error {
- cfg, err := LoadConfigurationFrom(path)
- if err != nil {
- return err
- }
- if len(cfg.content) == 0 {
- fmt.Fprintf(cmd.OutOrStdout(), "No settings could be found in %s\n", cfg.location)
- } else {
- bs, err := yaml.Marshal(cfg.content)
- if err != nil {
- return fmt.Errorf("unable to marshal config to YAML: %w", err)
- }
- fmt.Fprintf(cmd.OutOrStdout(), "The configuration file is read from %s\n", cfg.location)
- fmt.Fprintln(cmd.OutOrStdout(), string(bs))
- }
- return nil
-}
diff --git a/pkg/cmd/config_test.go b/pkg/cmd/config_test.go
deleted file mode 100644
index 0fe09fb08..000000000
--- a/pkg/cmd/config_test.go
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
-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 cmd
-
-import (
- "fmt"
- "os"
- "path/filepath"
- "strings"
- "testing"
-
- "github.com/spf13/cobra"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-)
-
-const cmdConfig = "config"
-
-// nolint: unparam
-func initializeConfigCmdOptions(t *testing.T, mock bool) (*configCmdOptions, *cobra.Command, RootCmdOptions) {
- t.Helper()
-
- options, rootCmd := kamelTestPreAddCommandInit()
- configCmdOptions := addTestConfigCmd(*options, rootCmd, mock)
- kamelTestPostAddCommandInit(t, rootCmd, options)
-
- return configCmdOptions, rootCmd, *options
-}
-
-func addTestConfigCmd(options RootCmdOptions, rootCmd *cobra.Command, mock bool) *configCmdOptions {
- // add a testing version of config Command
- configCmd, configOptions := newCmdConfig(&options)
- if mock {
- configCmd.RunE = func(c *cobra.Command, args []string) error {
- return nil
- }
- }
- configCmd.Args = ArbitraryArgs
- rootCmd.AddCommand(configCmd)
- return configOptions
-}
-
-func TestConfigNonExistingFlag(t *testing.T) {
- _, rootCmd, _ := initializeConfigCmdOptions(t, true)
- _, err := ExecuteCommand(rootCmd, cmdConfig, "--nonExistingFlag")
- require.Error(t, err)
-}
-
-func TestConfigDefaultNamespaceFlag(t *testing.T) {
- configCmdOptions, rootCmd, _ := initializeConfigCmdOptions(t, true)
- _, err := ExecuteCommand(rootCmd, cmdConfig, "--default-namespace", "foo")
- require.NoError(t, err)
- assert.Equal(t, "foo", configCmdOptions.DefaultNamespace)
-}
-
-func TestConfigListFlag(t *testing.T) {
- _, rootCmd, _ := initializeConfigCmdOptions(t, false)
- output, err := ExecuteCommand(rootCmd, cmdConfig, "--list")
- require.NoError(t, err)
- assert.True(t, strings.Contains(output, "No settings"), "The output is unexpected: "+output)
-}
-
-func TestConfigFolderFlagToUsed(t *testing.T) {
- _, rootCmd, _ := initializeConfigCmdOptions(t, false)
- output, err := ExecuteCommand(rootCmd, cmdConfig, "--list", "--folder", "used")
- require.NoError(t, err)
- assert.True(t, strings.Contains(output, fmt.Sprintf(" %s", DefaultConfigLocation)), "The output is unexpected: "+output)
-}
-
-func TestConfigFolderFlagToSub(t *testing.T) {
- _, rootCmd, _ := initializeConfigCmdOptions(t, false)
- output, err := ExecuteCommand(rootCmd, cmdConfig, "--list", "--folder", "sub")
- require.NoError(t, err)
- assert.True(t, strings.Contains(output, filepath.FromSlash(fmt.Sprintf(".kamel/%s", DefaultConfigLocation))), "The output is unexpected: "+output)
-}
-
-func TestConfigFolderFlagToHome(t *testing.T) {
- _, rootCmd, _ := initializeConfigCmdOptions(t, false)
- output, err := ExecuteCommand(rootCmd, cmdConfig, "--list", "--folder", "home")
- require.NoError(t, err)
- assert.True(t, strings.Contains(output, filepath.FromSlash(fmt.Sprintf(".kamel/%s", DefaultConfigLocation))), "The output is unexpected: "+output)
-}
-
-func TestConfigFolderFlagToEnv(t *testing.T) {
- os.Setenv("KAMEL_CONFIG_PATH", "/foo/bar")
- t.Cleanup(func() { os.Unsetenv("KAMEL_CONFIG_PATH") })
- _, rootCmd, _ := initializeConfigCmdOptions(t, false)
- output, err := ExecuteCommand(rootCmd, cmdConfig, "--list", "--folder", "env")
- require.NoError(t, err)
- assert.True(t, strings.Contains(output, filepath.FromSlash(fmt.Sprintf("foo/bar/%s", DefaultConfigLocation))), "The output is unexpected: "+output)
-}
-
-func TestConfigFolderFlagToEnvWithConfigName(t *testing.T) {
- os.Setenv("KAMEL_CONFIG_NAME", "config")
- os.Setenv("KAMEL_CONFIG_PATH", "/foo/bar")
- t.Cleanup(func() {
- os.Unsetenv("KAMEL_CONFIG_NAME")
- os.Unsetenv("KAMEL_CONFIG_PATH")
- })
- _, rootCmd, _ := initializeConfigCmdOptions(t, false)
- output, err := ExecuteCommand(rootCmd, cmdConfig, "--list", "--folder", "env")
- require.NoError(t, err)
- assert.True(t, strings.Contains(output, filepath.FromSlash("/foo/bar/config.yaml")), "The output is unexpected: "+output)
-}
-
-func TestConfigDefaultNamespace(t *testing.T) {
- _, err := os.Stat(DefaultConfigLocation)
- assert.True(t, os.IsNotExist(err), "No file at "+DefaultConfigLocation+" was expected")
- _, rootCmd, _ := initializeConfigCmdOptions(t, false)
- t.Cleanup(func() { os.Remove(DefaultConfigLocation) })
- _, err = ExecuteCommand(rootCmd, cmdConfig, "--default-namespace", "foo")
- require.NoError(t, err)
- _, err = os.Stat(DefaultConfigLocation)
- require.NoError(t, err, "A file at "+DefaultConfigLocation+" was expected")
- output, err := ExecuteCommand(rootCmd, cmdConfig, "--list")
- require.NoError(t, err)
- assert.True(t, strings.Contains(output, "foo"), "The output is unexpected: "+output)
-}
diff --git a/pkg/cmd/describe.go b/pkg/cmd/describe.go
deleted file mode 100644
index 54a6d355f..000000000
--- a/pkg/cmd/describe.go
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
-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 cmd
-
-import (
- "strings"
- "time"
-
- "golang.org/x/text/cases"
- "golang.org/x/text/language"
-
- "github.com/spf13/cobra"
-
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-
- "github.com/apache/camel-k/v2/pkg/trait"
- "github.com/apache/camel-k/v2/pkg/util/indentedwriter"
-)
-
-func describeObjectMeta(w *indentedwriter.Writer, om metav1.ObjectMeta) {
- w.Writef(0, "Name:\t%s\n", om.Name)
- w.Writef(0, "Namespace:\t%s\n", om.Namespace)
-
- if len(om.GetLabels()) > 0 {
- w.Writef(0, "Labels:")
- for k, v := range om.Labels {
- w.Writef(0, "\t%s=%s\n", k, strings.TrimSpace(v))
- }
- }
-
- if len(om.GetAnnotations()) > 0 {
- w.Writef(0, "Annotations:")
- for k, v := range om.Annotations {
- w.Writef(0, "\t%s=%s\n", k, strings.TrimSpace(v))
- }
- }
-
- w.Writef(0, "Creation Timestamp:\t%s\n", om.CreationTimestamp.Format(time.RFC1123Z))
-}
-
-func describeTraits(w *indentedwriter.Writer, traits interface{}) error {
- traitMap, err := trait.ToTraitMap(traits)
- if err != nil {
- return err
- }
-
- if len(traitMap) > 0 {
- w.Writef(0, "Traits:\n")
-
- for id, trait := range traitMap {
- w.Writef(1, "%s:\n", cases.Title(language.English).String(id))
- // TODO: print the whole TraitSpec as Yaml
- for k, v := range trait {
- w.Writef(2, "%s:\t%v\n", cases.Title(language.English).String(k), v)
- }
- }
- }
- return nil
-}
-
-func newCmdDescribe(rootCmdOptions *RootCmdOptions) *cobra.Command {
- cmd := cobra.Command{
- Use: "describe",
- Deprecated: "consider using kubectl (or oc) custom resource describe command instead.",
- Short: "Describe a resource",
- Long: `Describe a Camel K resource.`,
- }
-
- cmd.AddCommand(cmdOnly(newDescribeKitCmd(rootCmdOptions)))
- cmd.AddCommand(cmdOnly(newDescribeIntegrationCmd(rootCmdOptions)))
- cmd.AddCommand(cmdOnly(newDescribePlatformCmd(rootCmdOptions)))
- cmd.AddCommand(cmdOnly(newDescribeKameletCmd(rootCmdOptions)))
-
- return &cmd
-}
diff --git a/pkg/cmd/describe_integration.go b/pkg/cmd/describe_integration.go
deleted file mode 100644
index 0da07b947..000000000
--- a/pkg/cmd/describe_integration.go
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
-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 cmd
-
-import (
- "errors"
- "fmt"
- "io"
- "strings"
-
- "github.com/spf13/cobra"
-
- k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
-
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- "github.com/apache/camel-k/v2/pkg/util/indentedwriter"
-)
-
-func newDescribeIntegrationCmd(rootCmdOptions *RootCmdOptions) (*cobra.Command, *describeIntegrationCommandOptions) {
- options := describeIntegrationCommandOptions{
- RootCmdOptions: rootCmdOptions,
- }
-
- cmd := cobra.Command{
- Use: "integration",
- Aliases: []string{"it"},
- Short: "Describe an Integration",
- Long: `Describe an Integration.`,
- Deprecated: "consider using kubectl (or oc) custom resource describe command instead.",
- PreRunE: decode(&options, options.Flags),
- RunE: func(cmd *cobra.Command, args []string) error {
- if err := options.validate(cmd, args); err != nil {
- return err
- }
- if err := options.run(cmd, args); err != nil {
- fmt.Fprintln(cmd.ErrOrStderr(), err.Error())
- }
-
- return nil
- },
- }
-
- cmd.Flags().BoolVar(&options.showSourceContent, "show-source-content", false, "Print source content")
-
- return &cmd, &options
-}
-
-type describeIntegrationCommandOptions struct {
- *RootCmdOptions
- showSourceContent bool `mapstructure:"show-source-content"`
-}
-
-func (command *describeIntegrationCommandOptions) validate(_ *cobra.Command, args []string) error {
- if len(args) != 1 {
- return errors.New("describe expects an integration name argument")
- }
- return nil
-}
-
-func (command *describeIntegrationCommandOptions) run(cmd *cobra.Command, args []string) error {
- c, err := command.GetCmdClient()
- if err != nil {
- return err
- }
-
- ctx := v1.NewIntegration(command.Namespace, args[0])
- key := k8sclient.ObjectKey{
- Namespace: command.Namespace,
- Name: args[0],
- }
-
- if err := c.Get(command.Context, key, &ctx); err == nil {
- if desc, err := command.describeIntegration(cmd, ctx); err == nil {
- fmt.Fprint(cmd.OutOrStdout(), desc)
- } else {
- fmt.Fprintln(cmd.ErrOrStderr(), err)
- }
- } else {
- fmt.Fprintf(cmd.OutOrStdout(), "Integration '%s' does not exist.\n", args[0])
- }
-
- return nil
-}
-
-func (command *describeIntegrationCommandOptions) describeIntegration(cmd *cobra.Command, i v1.Integration) (string, error) {
- return indentedwriter.IndentedString(func(out io.Writer) error {
- w := indentedwriter.NewWriter(cmd.OutOrStdout())
-
- describeObjectMeta(w, i.ObjectMeta)
-
- w.Writef(0, "Phase:\t%s\n", i.Status.Phase)
- w.Writef(0, "Runtime Version:\t%s\n", i.Status.RuntimeVersion)
- kit := ""
- if i.Status.IntegrationKit != nil {
- ns := i.GetIntegrationKitNamespace(nil)
- kit = fmt.Sprintf("%s/%s", ns, i.Status.IntegrationKit.Name)
- }
- w.Writef(0, "Kit:\t%s\n", kit)
- w.Writef(0, "Image:\t%s\n", i.Status.Image)
- w.Writef(0, "Version:\t%s\n", i.Status.Version)
-
- if len(i.Spec.Configuration) > 0 {
- w.Writef(0, "Configuration:\n")
- for _, config := range i.Spec.Configuration {
- w.Writef(1, "Type:\t%s\n", config.Type)
- w.Writef(1, "Value:\t%s\n", config.Value)
- }
- }
-
- if len(i.Status.Dependencies) > 0 {
- w.Writef(0, "Dependencies:\n")
- for _, dependency := range i.Status.Dependencies {
- w.Writef(1, "%s\n", dependency)
- }
- }
-
- if len(i.Spec.Repositories) > 0 {
- w.Writef(0, "Repositories:\n")
- for _, repository := range i.Spec.Repositories {
- w.Writef(1, "%s\n", repository)
- }
- }
-
- if len(i.AllSources()) > 0 {
- w.Writef(0, "Sources:\n")
- if command.showSourceContent {
- for _, s := range i.AllSources() {
- w.Writef(1, "Name:\t%s\n", s.Name)
- w.Writef(1, "Language:\t%s\n", s.InferLanguage())
- w.Writef(1, "Compression:\t%t\n", s.Compression)
- w.Writef(1, "Content:\n")
-
- if s.ContentRef == "" {
- w.Writef(2, "%s\n", strings.TrimSpace(s.Content))
- } else {
- w.Writef(2, "Ref:\t%s\n", s.ContentRef)
- w.Writef(2, "Ref Key:\t%s\n", s.ContentKey)
- }
- }
- } else {
- //nolint:dupword
- w.Writef(1, "Name\tLanguage\tCompression\tRef\tRef Key\n")
- for _, s := range i.AllSources() {
- w.Writef(1, "%s\t%s\t%t\t%s\t%s\n",
- s.Name,
- s.InferLanguage(),
- s.Compression,
- s.ContentRef,
- s.ContentKey)
- }
- }
- }
-
- if len(i.Status.Conditions) > 0 {
- w.Writef(0, "Conditions:\n")
- w.Writef(1, "Type\tStatus\tReason\tMessage\n")
- for _, condition := range i.Status.Conditions {
- w.Writef(1, "%s\t%s\t%s\t%s\n",
- condition.Type,
- condition.Status,
- condition.Reason,
- condition.Message)
- }
- }
-
- return describeTraits(w, i.Spec.Traits)
- })
-}
diff --git a/pkg/cmd/describe_kamelet.go b/pkg/cmd/describe_kamelet.go
deleted file mode 100644
index 691719b57..000000000
--- a/pkg/cmd/describe_kamelet.go
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
-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 cmd
-
-import (
- "errors"
- "fmt"
- "io"
- "strings"
-
- "github.com/spf13/cobra"
-
- k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
-
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
-
- "github.com/apache/camel-k/v2/pkg/util/indentedwriter"
-)
-
-func newDescribeKameletCmd(rootCmdOptions *RootCmdOptions) (*cobra.Command, *describeKameletCommandOptions) {
- options := describeKameletCommandOptions{
- rootCmdOptions,
- }
-
- cmd := cobra.Command{
- Use: "kamelet",
- Aliases: []string{"kl"},
- Short: "Describe a Kamelet",
- Long: `Describe a Kamelet.`,
- Deprecated: "consider using kubectl (or oc) custom resource describe command instead.",
- PreRunE: decode(&options, options.Flags),
- RunE: func(cmd *cobra.Command, args []string) error {
- if err := options.validate(cmd, args); err != nil {
- return err
- }
- if err := options.run(cmd, args); err != nil {
- fmt.Fprintln(cmd.ErrOrStderr(), err.Error())
- }
-
- return nil
- },
- }
-
- return &cmd, &options
-}
-
-type describeKameletCommandOptions struct {
- *RootCmdOptions
-}
-
-func (command *describeKameletCommandOptions) validate(_ *cobra.Command, args []string) error {
- if len(args) != 1 {
- return errors.New("describe expects a Kamelet name argument")
- }
- return nil
-}
-
-func (command *describeKameletCommandOptions) run(cmd *cobra.Command, args []string) error {
- c, err := command.GetCmdClient()
- if err != nil {
- return err
- }
-
- kamelet := v1.NewKamelet(command.Namespace, args[0])
- kameletKey := k8sclient.ObjectKey{
- Namespace: command.Namespace,
- Name: args[0],
- }
-
- if err := c.Get(command.Context, kameletKey, &kamelet); err == nil {
- if desc, err := command.describeKamelet(cmd, kamelet); err == nil {
- fmt.Fprint(cmd.OutOrStdout(), desc)
- } else {
- fmt.Fprintln(cmd.ErrOrStderr(), err)
- }
- } else {
- fmt.Fprintln(cmd.OutOrStdout(), "Kamelet '"+args[0]+"' does not exist.")
- }
-
- return nil
-}
-
-func (command *describeKameletCommandOptions) describeKamelet(cmd *cobra.Command, kamelet v1.Kamelet) (string, error) {
- return indentedwriter.IndentedString(func(out io.Writer) error {
- w := indentedwriter.NewWriter(cmd.OutOrStdout())
-
- describeObjectMeta(w, kamelet.ObjectMeta)
- // Definition
- def := kamelet.Spec.Definition
- if def != nil {
- w.Writef(0, "Definition:\n")
- w.Writef(1, "Title:\t%s\n", def.Title)
- w.Writef(1, "Description:\n")
- for _, s := range strings.Split(def.Description, "\n") {
- w.Writef(2, "%s\n", s)
- }
- if len(def.Required) > 0 {
- w.Writef(1, "Required:\n")
- for _, req := range def.Required {
- w.Writef(2, "%s\n", req)
- }
- }
- if len(def.Properties) > 0 {
- w.Writef(1, "Properties:\n")
- for _, k := range kamelet.SortedDefinitionPropertiesKeys() {
- p := def.Properties[k]
- w.Writef(2, "%s:\n", k)
- w.Writef(3, "Title:\t%s\n", p.Title)
- w.Writef(3, "Description:\t%s\n", p.Description)
- w.Writef(3, "Type:\t%s\n", p.Type)
- if p.Default != nil {
- w.Writef(3, "Default:\t%s\n", p.Default)
- }
- }
- }
- }
-
- // Types
- if len(kamelet.Spec.DataTypes) > 0 {
- w.Writef(0, "Types:\n")
- for _, k := range kamelet.SortedTypesKeys() {
- t := kamelet.Spec.DataTypes[k]
- w.Writef(1, "%s:\n", k)
- w.Writef(2, "Default:\t%s\n", t.Default)
- w.Writef(2, "Types:\t\n")
- w.Writef(3, "Format\tScheme\tMediaType\tDescription\n")
- for _, dt := range t.Types {
- w.Writef(3, "%s\t%s\t%s\t%s", dt.Format, dt.Scheme, dt.MediaType, dt.Description)
- }
- }
- }
-
- // Template
- // TODO pretty print template data
- template := kamelet.Spec.Template
- if template != nil {
- w.Writef(0, "Template:\n")
- w.Writef(1, "%s\n", string(template.RawMessage))
- }
-
- // Dependencies
- if len(kamelet.Spec.Dependencies) > 0 {
- w.Writef(0, "Dependencies:\t\n")
- for _, d := range kamelet.Spec.Dependencies {
- w.Writef(1, "%s\n", d)
- }
- }
-
- // Sources
- if len(kamelet.Spec.Sources) > 0 {
- w.Writef(0, "Sources:\t\n")
- //nolint:dupword
- w.Writef(1, "Name\tLanguage\tCompression\tRef\tRef Key\n")
- for _, s := range kamelet.Spec.Sources {
- w.Writef(1, "%s\t%s\t%t\t%s\t%s\n",
- s.Name,
- s.InferLanguage(),
- s.Compression,
- s.ContentRef,
- s.ContentKey)
- }
- }
-
- return nil
- })
-}
diff --git a/pkg/cmd/describe_kit.go b/pkg/cmd/describe_kit.go
deleted file mode 100644
index d5abffced..000000000
--- a/pkg/cmd/describe_kit.go
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
-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 cmd
-
-import (
- "errors"
- "fmt"
- "io"
-
- "github.com/spf13/cobra"
-
- ctrl "sigs.k8s.io/controller-runtime/pkg/client"
-
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- "github.com/apache/camel-k/v2/pkg/util/indentedwriter"
-)
-
-func newDescribeKitCmd(rootCmdOptions *RootCmdOptions) (*cobra.Command, *describeKitCommandOptions) {
- options := describeKitCommandOptions{
- rootCmdOptions,
- }
-
- cmd := cobra.Command{
- Use: "kit",
- Aliases: []string{"ik"},
- Short: "Describe an Integration Kit",
- Long: `Describe an Integration Kit.`,
- Deprecated: "consider using kubectl (or oc) custom resource describe command instead.",
- PreRunE: decode(&options, options.Flags),
- RunE: func(cmd *cobra.Command, args []string) error {
- if err := options.validate(cmd, args); err != nil {
- return err
- }
- if err := options.run(cmd, args); err != nil {
- fmt.Fprintln(cmd.ErrOrStderr(), err.Error())
- }
-
- return nil
- },
- }
-
- return &cmd, &options
-}
-
-type describeKitCommandOptions struct {
- *RootCmdOptions
-}
-
-func (command *describeKitCommandOptions) validate(_ *cobra.Command, args []string) error {
- if len(args) != 1 {
- return errors.New("describe expects a kit name argument")
- }
- return nil
-}
-
-func (command *describeKitCommandOptions) run(cmd *cobra.Command, args []string) error {
- c, err := command.GetCmdClient()
- if err != nil {
- return err
- }
-
- kit := v1.NewIntegrationKit(command.Namespace, args[0])
- kitKey := ctrl.ObjectKey{
- Namespace: command.Namespace,
- Name: args[0],
- }
-
- if err := c.Get(command.Context, kitKey, kit); err == nil {
- if desc, err := command.describeIntegrationKit(cmd, kit); err == nil {
- fmt.Fprint(cmd.OutOrStdout(), desc)
- } else {
- fmt.Fprintln(cmd.ErrOrStderr(), err)
- }
- } else {
- fmt.Fprintln(cmd.OutOrStdout(), "IntegrationKit '"+args[0]+"' does not exist")
- }
-
- return nil
-}
-
-func (command *describeKitCommandOptions) describeIntegrationKit(cmd *cobra.Command, kit *v1.IntegrationKit) (string, error) {
- return indentedwriter.IndentedString(func(out io.Writer) error {
- w := indentedwriter.NewWriter(cmd.OutOrStdout())
-
- describeObjectMeta(w, kit.ObjectMeta)
-
- w.Writef(0, "Phase:\t%s\n", kit.Status.Phase)
- w.Writef(0, "Runtime Version:\t%s\n", kit.Status.RuntimeVersion)
- w.Writef(0, "Image:\t%s\n", kit.Status.Image)
- w.Writef(0, "Version:\t%s\n", kit.Status.Version)
-
- if len(kit.Status.Artifacts) > 0 {
- w.Writef(0, "Artifacts:\t\n")
- for _, artifact := range kit.Status.Artifacts {
- w.Writef(1, "%s\n", artifact.ID)
- }
- }
-
- if len(kit.Spec.Configuration) > 0 {
- w.Writef(0, "Configuration:\n")
- for _, config := range kit.Spec.Configuration {
- w.Writef(1, "Type:\t%s\n", config.Type)
- w.Writef(1, "Value:\t%s\n", config.Value)
- }
- }
-
- if len(kit.Spec.Dependencies) > 0 {
- w.Writef(0, "Dependencies:\t\n")
- for _, dependency := range kit.Spec.Dependencies {
- w.Writef(1, "%s\n", dependency)
- }
- }
-
- if len(kit.Spec.Repositories) > 0 {
- w.Writef(0, "Repositories:\n")
- for _, repository := range kit.Spec.Repositories {
- w.Writef(1, "%s\n", repository)
- }
- }
-
- return describeTraits(w, kit.Spec.Traits)
- })
-}
diff --git a/pkg/cmd/describe_platform.go b/pkg/cmd/describe_platform.go
deleted file mode 100644
index 2979dee74..000000000
--- a/pkg/cmd/describe_platform.go
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
-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 cmd
-
-import (
- "errors"
- "fmt"
- "io"
-
- "github.com/spf13/cobra"
-
- k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
-
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- "github.com/apache/camel-k/v2/pkg/util/indentedwriter"
-)
-
-func newDescribePlatformCmd(rootCmdOptions *RootCmdOptions) (*cobra.Command, *describePlatformCommandOptions) {
- options := describePlatformCommandOptions{
- rootCmdOptions,
- }
-
- cmd := cobra.Command{
- Use: "platform",
- Aliases: []string{"ip"},
- Short: "Describe an Integration Platform",
- Long: `Describe an Integration Platform.`,
- Deprecated: "consider using kubectl (or oc) custom resource describe command instead.",
- PreRunE: decode(&options, options.Flags),
- RunE: func(cmd *cobra.Command, args []string) error {
- if err := options.validate(cmd, args); err != nil {
- return err
- }
- if err := options.run(cmd, args); err != nil {
- fmt.Fprintln(cmd.OutOrStderr(), err.Error())
- }
-
- return nil
- },
- }
-
- return &cmd, &options
-}
-
-type describePlatformCommandOptions struct {
- *RootCmdOptions
-}
-
-func (command *describePlatformCommandOptions) validate(_ *cobra.Command, args []string) error {
- if len(args) != 1 {
- return errors.New("describe expects a platform name argument")
- }
- return nil
-}
-
-func (command *describePlatformCommandOptions) run(cmd *cobra.Command, args []string) error {
- c, err := command.GetCmdClient()
- if err != nil {
- return err
- }
-
- platform := v1.NewIntegrationPlatform(command.Namespace, args[0])
- platformKey := k8sclient.ObjectKey{
- Namespace: command.Namespace,
- Name: args[0],
- }
-
- if err := c.Get(command.Context, platformKey, &platform); err == nil {
- if desc, err := command.describeIntegrationPlatform(cmd, platform); err == nil {
- fmt.Fprint(cmd.OutOrStdout(), desc)
- } else {
- fmt.Fprintln(cmd.ErrOrStderr(), err)
- }
- } else {
- fmt.Fprintf(cmd.OutOrStdout(), "IntegrationPlatform '%s' does not exist.\n", args[0])
- }
-
- return nil
-}
-
-func (command *describePlatformCommandOptions) describeIntegrationPlatform(cmd *cobra.Command, platform v1.IntegrationPlatform) (string, error) {
- return indentedwriter.IndentedString(func(out io.Writer) error {
- w := indentedwriter.NewWriter(cmd.OutOrStdout())
- describeObjectMeta(w, platform.ObjectMeta)
- w.Writef(0, "Phase:\t%s\n", platform.Status.Phase)
- w.Writef(0, "Version:\t%s\n", platform.Status.Version)
- w.Writef(0, "Base Image:\t%s\n", platform.GetActualValue(getPlatformBaseImage))
- w.Writef(0, "Runtime Version:\t%s\n", platform.GetActualValue(getPlatformRuntimeVersion))
- w.Writef(0, "Local Repository:\t%s\n", platform.GetActualValue(getPlatformMavenLocalRepository))
- w.Writef(0, "Publish Strategy:\t%s\n", platform.GetActualValue(getPlatformPublishStrategy))
-
- return nil
- })
-}
-
-func getPlatformBaseImage(spec v1.IntegrationPlatformSpec) string {
- return spec.Build.BaseImage
-}
-
-func getPlatformRuntimeVersion(spec v1.IntegrationPlatformSpec) string {
- return spec.Build.RuntimeVersion
-}
-
-func getPlatformMavenLocalRepository(spec v1.IntegrationPlatformSpec) string {
- return spec.Build.Maven.LocalRepository
-}
-
-func getPlatformPublishStrategy(spec v1.IntegrationPlatformSpec) string {
- return string(spec.Build.PublishStrategy)
-}
diff --git a/pkg/cmd/kamelet.go b/pkg/cmd/kamelet.go
deleted file mode 100644
index fbe14f20b..000000000
--- a/pkg/cmd/kamelet.go
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
-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 cmd
-
-import (
- "github.com/spf13/cobra"
-)
-
-func newCmdKamelet(rootCmdOptions *RootCmdOptions) *cobra.Command {
- cmd := cobra.Command{
- Use: "kamelet",
- Short: "Configure a Kamelet",
- Long: `Configure a Kamelet.`,
- Deprecated: "consider using kubectl (or oc) command instead.",
- }
-
- cmd.AddCommand(cmdOnly(newKameletGetCmd(rootCmdOptions)))
- cmd.AddCommand(cmdOnly(newKameletDeleteCmd(rootCmdOptions)))
- cmd.AddCommand(cmdOnly(newKameletAddRepoCmd(rootCmdOptions)))
- cmd.AddCommand(cmdOnly(newKameletRemoveRepoCmd(rootCmdOptions)))
-
- return &cmd
-}
diff --git a/pkg/cmd/kamelet_add_repo.go b/pkg/cmd/kamelet_add_repo.go
deleted file mode 100644
index 3ccf7e062..000000000
--- a/pkg/cmd/kamelet_add_repo.go
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
-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 cmd
-
-import (
- "errors"
- "fmt"
- "regexp"
-
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- platformutil "github.com/apache/camel-k/v2/pkg/platform"
- "github.com/spf13/cobra"
- k8serrors "k8s.io/apimachinery/pkg/api/errors"
- "sigs.k8s.io/controller-runtime/pkg/client"
-)
-
-// kameletRepositoryURIRegexp is the regular expression used to validate the URI of a Kamelet repository.
-var kameletRepositoryURIRegexp = regexp.MustCompile(`^github:[^/]+/[^/]+((/[^/]+)*)?$`)
-
-func newKameletAddRepoCmd(rootCmdOptions *RootCmdOptions) (*cobra.Command, *kameletAddRepoCommandOptions) {
- options := kameletAddRepoCommandOptions{
- kameletUpdateRepoCommandOptions: &kameletUpdateRepoCommandOptions{
- RootCmdOptions: rootCmdOptions,
- },
- }
-
- cmd := cobra.Command{
- Use: "add-repo github:owner/repo[/path_to_kamelets_folder][@version] ...",
- Short: "Add a Kamelet repository",
- Long: `Add a Kamelet repository.`,
- Deprecated: "consider using kubectl (or oc) command instead.",
- PreRunE: decode(&options, options.Flags),
- RunE: func(cmd *cobra.Command, args []string) error {
- if err := options.validate(args); err != nil {
- return err
- }
- return options.run(cmd, args)
- },
- }
-
- cmd.Flags().StringP("operator-id", "x", "", "Id of the Operator to update. If not set, the default active Integration Platform is updated.")
-
- return &cmd, &options
-}
-
-type kameletUpdateRepoCommandOptions struct {
- *RootCmdOptions
- OperatorID string `mapstructure:"operator-id" yaml:",omitempty"`
-}
-
-type kameletAddRepoCommandOptions struct {
- *kameletUpdateRepoCommandOptions
-}
-
-func (o *kameletAddRepoCommandOptions) validate(args []string) error {
- if len(args) == 0 {
- return errors.New("at least one Kamelet repository is expected")
- }
- return nil
-}
-
-func (o *kameletAddRepoCommandOptions) run(cmd *cobra.Command, args []string) error {
- c, err := o.GetCmdClient()
- if err != nil {
- return err
- }
- var platform *v1.IntegrationPlatform
- if o.OperatorID == "" {
- o.OperatorID = platformutil.DefaultPlatformName
- }
-
- platform, err = o.getIntegrationPlatform(cmd, c)
-
- if err != nil {
- return err
- } else if platform == nil {
- return nil
- }
- for _, uri := range args {
- if err := checkURI(uri, platform.Spec.Kamelet.Repositories); err != nil {
- return err
- }
- platform.Spec.Kamelet.Repositories = append(platform.Spec.Kamelet.Repositories, v1.KameletRepositorySpec{
- URI: uri,
- })
- }
- return c.Update(o.Context, platform)
-}
-
-// getIntegrationPlatform gives the integration platform matching with the operator id in the provided namespace.
-func (o *kameletUpdateRepoCommandOptions) getIntegrationPlatform(cmd *cobra.Command, c client.Client) (*v1.IntegrationPlatform, error) {
- key := client.ObjectKey{
- Namespace: o.Namespace,
- Name: o.OperatorID,
- }
- platform := v1.IntegrationPlatform{}
- if err := c.Get(o.Context, key, &platform); err != nil {
- if k8serrors.IsNotFound(err) {
- // IntegrationPlatform may be in the operator namespace, but we currently don't have a way to determine it: we just warn
- fmt.Fprintf(cmd.ErrOrStderr(), "Warning: IntegrationPlatform %q not found in namespace %q\n", key.Name, key.Namespace)
- return nil, nil
- }
- return nil, err
- }
- return &platform, nil
-}
-
-// findIntegrationPlatform gives the integration platform that could be found in the provided namespace.
-func (o *kameletUpdateRepoCommandOptions) findIntegrationPlatform(cmd *cobra.Command, c client.Client) (*v1.IntegrationPlatform, error) {
- platforms, err := platformutil.ListPlatforms(o.Context, c, o.Namespace)
- if err != nil {
- return nil, err
- }
- for i := range platforms.Items {
- p := platforms.Items[i]
- if platformutil.IsActive(&p) {
- return &p, nil
- }
- }
- fmt.Fprintf(cmd.ErrOrStderr(), "Warning: No active IntegrationPlatform could be found in namespace %q\n", o.Namespace)
- return nil, nil
-}
-
-func checkURI(uri string, repositories []v1.KameletRepositorySpec) error {
- if !kameletRepositoryURIRegexp.MatchString(uri) {
- return fmt.Errorf("malformed Kamelet repository uri %s, the expected format is github:owner/repo[/path_to_kamelets_folder][@version]", uri)
- }
- for _, repo := range repositories {
- if repo.URI == uri {
- return fmt.Errorf("duplicate Kamelet repository uri %s", uri)
- }
- }
- return nil
-}
diff --git a/pkg/cmd/kamelet_add_repo_test.go b/pkg/cmd/kamelet_add_repo_test.go
deleted file mode 100644
index faa663dc7..000000000
--- a/pkg/cmd/kamelet_add_repo_test.go
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
-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 cmd
-
-import (
- "testing"
-
- "github.com/spf13/cobra"
- "github.com/stretchr/testify/require"
-
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
-)
-
-const cmdKameletAddRepo = "add-repo"
-
-// nolint: unparam
-func initializeKameletAddRepoCmdOptions(t *testing.T) (*kameletAddRepoCommandOptions, *cobra.Command, RootCmdOptions) {
- t.Helper()
-
- options, rootCmd := kamelTestPreAddCommandInit()
- kameletAddRepoCommandOptions := addTestKameletAddRepoCmd(*options, rootCmd)
- kamelTestPostAddCommandInit(t, rootCmd, options)
-
- return kameletAddRepoCommandOptions, rootCmd, *options
-}
-
-func addTestKameletAddRepoCmd(options RootCmdOptions, rootCmd *cobra.Command) *kameletAddRepoCommandOptions {
- // Add a testing version of kamelet add-repo Command
- kameletAddRepoCmd, kameletAddRepoOptions := newKameletAddRepoCmd(&options)
- kameletAddRepoCmd.RunE = func(c *cobra.Command, args []string) error {
- return nil
- }
- kameletAddRepoCmd.PostRunE = func(c *cobra.Command, args []string) error {
- return nil
- }
- kameletAddRepoCmd.Args = ArbitraryArgs
- rootCmd.AddCommand(kameletAddRepoCmd)
- return kameletAddRepoOptions
-}
-
-func TestKameletAddRepoNoFlag(t *testing.T) {
- _, rootCmd, _ := initializeKameletAddRepoCmdOptions(t)
- _, err := ExecuteCommand(rootCmd, cmdKameletAddRepo, "foo")
- require.NoError(t, err)
-}
-
-func TestKameletAddRepoNonExistingFlag(t *testing.T) {
- _, rootCmd, _ := initializeKameletAddRepoCmdOptions(t)
- _, err := ExecuteCommand(rootCmd, cmdKameletAddRepo, "--nonExistingFlag", "foo")
- require.Error(t, err)
-}
-
-func TestKameletAddRepoInvalidRepositoryURI(t *testing.T) {
- repositories := []v1.KameletRepositorySpec{}
- require.Error(t, checkURI("foo", repositories))
- require.Error(t, checkURI("github", repositories))
- require.Error(t, checkURI("github:", repositories))
- require.Error(t, checkURI("github:foo", repositories))
- require.Error(t, checkURI("github:foo/", repositories))
-}
-
-func TestKameletAddRepoValidRepositoryURI(t *testing.T) {
- repositories := []v1.KameletRepositorySpec{}
- require.NoError(t, checkURI("github:foo/bar", repositories))
- require.NoError(t, checkURI("github:foo/bar/some/path", repositories))
- require.NoError(t, checkURI("github:foo/bar@1.0", repositories))
- require.NoError(t, checkURI("github:foo/bar/some/path@1.0", repositories))
-}
-
-func TestKameletAddRepoDuplicateRepositoryURI(t *testing.T) {
- repositories := []v1.KameletRepositorySpec{{URI: "github:foo/bar"}}
- require.Error(t, checkURI("github:foo/bar", repositories))
- require.NoError(t, checkURI("github:foo/bar2", repositories))
-}
diff --git a/pkg/cmd/kamelet_delete.go b/pkg/cmd/kamelet_delete.go
deleted file mode 100644
index ee83f558a..000000000
--- a/pkg/cmd/kamelet_delete.go
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
-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 cmd
-
-import (
- "errors"
- "fmt"
-
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
-
- "github.com/spf13/cobra"
- k8errors "k8s.io/apimachinery/pkg/api/errors"
-
- k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
-)
-
-func newKameletDeleteCmd(rootCmdOptions *RootCmdOptions) (*cobra.Command, *kameletDeleteCommandOptions) {
- options := kameletDeleteCommandOptions{
- RootCmdOptions: rootCmdOptions,
- }
-
- cmd := cobra.Command{
- Use: "delete [Kamelet1] [Kamelet2] ...",
- Short: "Delete Kamelets deployed on Kubernetes",
- Deprecated: "consider using kubectl (or oc) command instead.",
- PreRunE: decode(&options, options.Flags),
- RunE: func(cmd *cobra.Command, args []string) error {
- if err := options.validate(args); err != nil {
- return err
- }
- return options.run(cmd, args)
- },
- }
-
- cmd.Flags().Bool("all", false, "Delete all Kamelets")
-
- return &cmd, &options
-}
-
-type kameletDeleteCommandOptions struct {
- *RootCmdOptions
- All bool `mapstructure:"all"`
-}
-
-func (command *kameletDeleteCommandOptions) validate(args []string) error {
- if command.All && len(args) > 0 {
- return errors.New("invalid combination: --all flag is set and at least one kamelet name is provided")
- }
- if !command.All && len(args) == 0 {
- return errors.New("invalid combination: provide one or several kamelet names or set --all flag for all kamelets")
- }
-
- return nil
-}
-
-func (command *kameletDeleteCommandOptions) run(cmd *cobra.Command, args []string) error {
- names := args
-
- c, err := command.GetCmdClient()
- if err != nil {
- return err
- }
-
- if command.All {
- klList := v1.NewKameletList()
- if err := c.List(command.Context, &klList, k8sclient.InNamespace(command.Namespace)); err != nil {
- return err
- }
- names = make([]string, 0, len(klList.Items))
- for _, kl := range klList.Items {
- // only include non-bundled, non-readonly kamelets
- if kl.Labels[v1.KameletBundledLabel] != "true" && kl.Labels[v1.KameletReadOnlyLabel] != "true" {
- names = append(names, kl.Name)
- }
- }
- }
-
- for _, name := range names {
- if err := command.delete(cmd, name); err != nil {
- return err
- }
- }
-
- return nil
-}
-
-func (command *kameletDeleteCommandOptions) delete(cmd *cobra.Command, name string) error {
- c, err := command.GetCmdClient()
- if err != nil {
- return err
- }
-
- kl := v1.NewKamelet(command.Namespace, name)
- key := k8sclient.ObjectKey{
- Namespace: command.Namespace,
- Name: name,
- }
- err = c.Get(command.Context, key, &kl)
- if err != nil {
- if k8errors.IsNotFound(err) {
- return fmt.Errorf("no kamelet found with name \"%s\"", name)
- }
- return err
- }
-
- // check that it is not a bundled nor read-only one which is supposed to belong to platform
- // thus not managed by the end user
- if kl.Labels[v1.KameletBundledLabel] == "true" || kl.Labels[v1.KameletReadOnlyLabel] == "true" {
- // skip platform Kamelets while deleting all Kamelets
- if command.All {
- return nil
- }
- return fmt.Errorf("kamelet \"%s\" is not editable", name)
- }
-
- err = c.Delete(command.Context, &kl)
- if err != nil {
- if k8errors.IsNotFound(err) {
- return fmt.Errorf("no kamelet found with name \"%s\"", name)
- }
- return fmt.Errorf("error deleting kamelet \"%s\": %w", name, err)
- }
- fmt.Fprintln(cmd.OutOrStdout(), `kamelet "`+name+`" has been deleted`)
- return nil
-}
diff --git a/pkg/cmd/kamelet_get.go b/pkg/cmd/kamelet_get.go
deleted file mode 100644
index ce5a31bf4..000000000
--- a/pkg/cmd/kamelet_get.go
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
-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 cmd
-
-import (
- "errors"
- "fmt"
- "strings"
- "text/tabwriter"
-
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
-
- "github.com/spf13/cobra"
-
- k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
-)
-
-func newKameletGetCmd(rootCmdOptions *RootCmdOptions) (*cobra.Command, *kameletGetCommandOptions) {
- options := kameletGetCommandOptions{
- RootCmdOptions: rootCmdOptions,
- }
-
- cmd := cobra.Command{
- Use: "get",
- Short: "Get defined Kamelet",
- Long: `Get defined Kamelet.`,
- Deprecated: "consider using kubectl (or oc) command instead.",
- PreRunE: decode(&options, options.Flags),
- RunE: func(cmd *cobra.Command, args []string) error {
- if err := options.validate(); err != nil {
- return err
- }
-
- return options.run(cmd)
- },
- }
-
- cmd.Flags().Bool("sink", false, "Show only sink Kamelets")
- cmd.Flags().Bool("source", false, "Show only source Kamelets")
- cmd.Flags().Bool("action", false, "Show only action Kamelets")
- cmd.Flags().String("group", "", "Filters Kamelets by group")
- cmd.Flags().Bool("bundled", true, "Includes bundled Kamelets")
- cmd.Flags().Bool("read-only", true, "Includes read-only Kamelets")
-
- return &cmd, &options
-}
-
-type kameletGetCommandOptions struct {
- *RootCmdOptions
- Sink bool `mapstructure:"sink"`
- Source bool `mapstructure:"source"`
- Action bool `mapstructure:"action"`
- Group string `mapstructure:"group"`
- Bundled bool `mapstructure:"bundled"`
- ReadOnly bool `mapstructure:"read-only"`
-}
-
-func (command *kameletGetCommandOptions) validate() error {
- count := 0
- for _, b := range []bool{command.Sink, command.Source, command.Action} {
- if b {
- count++
- }
- }
-
- if count > 1 {
- return errors.New("invalid combination: flags --sink, --source, and --action are mutually exclusive")
- }
- return nil
-}
-
-func (command *kameletGetCommandOptions) run(cmd *cobra.Command) error {
- c, err := command.GetCmdClient()
- if err != nil {
- return err
- }
-
- klList := v1.NewKameletList()
- if err := c.List(command.Context, &klList, k8sclient.InNamespace(command.Namespace)); err != nil {
- return err
- }
-
- w := tabwriter.NewWriter(cmd.OutOrStdout(), 0, 8, 1, '\t', 0)
- fmt.Fprintln(w, "NAME\tPHASE\tTYPE\tGROUP\tBUNDLED\tREAD ONLY\tTITLE")
- for _, kl := range klList.Items {
- klType := kl.Labels[v1.KameletTypeLabel]
- group := kl.Annotations[v1.KameletGroupLabel]
- bundled := kl.Labels[v1.KameletBundledLabel]
- readOnly := kl.Labels[v1.KameletReadOnlyLabel]
-
- if command.Sink && klType != v1.KameletTypeSink {
- continue
- }
- if command.Source && klType != v1.KameletTypeSource {
- continue
- }
- if command.Action && klType != v1.KameletTypeAction {
- continue
- }
- if command.Group != "" && !strings.EqualFold(command.Group, group) {
- continue
- }
- if !command.Bundled && bundled == "true" {
- continue
- }
- if !command.ReadOnly && readOnly == "true" {
- continue
- }
-
- fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\n",
- kl.Name,
- klType,
- group,
- bundled,
- readOnly,
- kl.Spec.Definition.Title)
- }
-
- return w.Flush()
-}
diff --git a/pkg/cmd/kamelet_remove_repo.go b/pkg/cmd/kamelet_remove_repo.go
deleted file mode 100644
index 869c21414..000000000
--- a/pkg/cmd/kamelet_remove_repo.go
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
-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 cmd
-
-import (
- "errors"
- "fmt"
-
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- "github.com/spf13/cobra"
-)
-
-func newKameletRemoveRepoCmd(rootCmdOptions *RootCmdOptions) (*cobra.Command, *kameletRemoveRepoCommandOptions) {
- options := kameletRemoveRepoCommandOptions{
- kameletUpdateRepoCommandOptions: &kameletUpdateRepoCommandOptions{
- RootCmdOptions: rootCmdOptions,
- },
- }
-
- cmd := cobra.Command{
- Use: "remove-repo github:owner/repo[/path_to_kamelets_folder][@version] ...",
- Short: "Remove a Kamelet repository",
- Long: `Remove a Kamelet repository.`,
- Deprecated: "consider using kubectl (or oc) command instead.",
- PreRunE: decode(&options, options.Flags),
- RunE: func(cmd *cobra.Command, args []string) error {
- if err := options.validate(args); err != nil {
- return err
- }
- return options.run(cmd, args)
- },
- }
-
- cmd.Flags().StringP("operator-id", "x", "", "Id of the Operator to update. If not set, the default active Integration Platform is updated.")
-
- return &cmd, &options
-}
-
-type kameletRemoveRepoCommandOptions struct {
- *kameletUpdateRepoCommandOptions
-}
-
-func (o *kameletRemoveRepoCommandOptions) validate(args []string) error {
- if len(args) == 0 {
- return errors.New("at least one Kamelet repository is expected")
- }
- return nil
-}
-
-func (o *kameletRemoveRepoCommandOptions) run(cmd *cobra.Command, args []string) error {
- c, err := o.GetCmdClient()
- if err != nil {
- return err
- }
- var platform *v1.IntegrationPlatform
- if o.OperatorID == "" {
- platform, err = o.findIntegrationPlatform(cmd, c)
- } else {
- platform, err = o.getIntegrationPlatform(cmd, c)
- }
- if err != nil {
- return err
- } else if platform == nil {
- return nil
- }
- for _, uri := range args {
- i, err := getURIIndex(uri, platform.Spec.Kamelet.Repositories)
- if err != nil {
- return err
- }
- platform.Spec.Kamelet.Repositories[i] = platform.Spec.Kamelet.Repositories[len(platform.Spec.Kamelet.Repositories)-1]
- platform.Spec.Kamelet.Repositories = platform.Spec.Kamelet.Repositories[:len(platform.Spec.Kamelet.Repositories)-1]
- }
- return c.Update(o.Context, platform)
-}
-
-func getURIIndex(uri string, repositories []v1.KameletRepositorySpec) (int, error) {
- for i, repo := range repositories {
- if repo.URI == uri {
- return i, nil
- }
- }
- return 0, fmt.Errorf("non existing Kamelet repository uri %s", uri)
-}
diff --git a/pkg/cmd/kamelet_remove_repo_test.go b/pkg/cmd/kamelet_remove_repo_test.go
deleted file mode 100644
index 10957ef6a..000000000
--- a/pkg/cmd/kamelet_remove_repo_test.go
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
-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 cmd
-
-import (
- "testing"
-
- "github.com/spf13/cobra"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
-)
-
-const cmdKameletRemoveRepo = "remove-repo"
-
-// nolint: unparam
-func initializeKameletRemoveRepoCmdOptions(t *testing.T) (*kameletRemoveRepoCommandOptions, *cobra.Command, RootCmdOptions) {
- t.Helper()
-
- options, rootCmd := kamelTestPreAddCommandInit()
- kameletRemoveRepoCommandOptions := addTestKameletRemoveRepoCmd(*options, rootCmd)
- kamelTestPostAddCommandInit(t, rootCmd, options)
-
- return kameletRemoveRepoCommandOptions, rootCmd, *options
-}
-
-func addTestKameletRemoveRepoCmd(options RootCmdOptions, rootCmd *cobra.Command) *kameletRemoveRepoCommandOptions {
- // Add a testing version of kamelet remove-repo Command
- kameletRemoveRepoCmd, kameletRemoveRepoOptions := newKameletRemoveRepoCmd(&options)
- kameletRemoveRepoCmd.RunE = func(c *cobra.Command, args []string) error {
- return nil
- }
- kameletRemoveRepoCmd.PostRunE = func(c *cobra.Command, args []string) error {
- return nil
- }
- kameletRemoveRepoCmd.Args = ArbitraryArgs
- rootCmd.AddCommand(kameletRemoveRepoCmd)
- return kameletRemoveRepoOptions
-}
-
-func TestKameletRemoveRepoNoFlag(t *testing.T) {
- _, rootCmd, _ := initializeKameletRemoveRepoCmdOptions(t)
- _, err := ExecuteCommand(rootCmd, cmdKameletRemoveRepo, "foo")
- require.NoError(t, err)
-}
-
-func TestKameletRemoveRepoNonExistingFlag(t *testing.T) {
- _, rootCmd, _ := initializeKameletRemoveRepoCmdOptions(t)
- _, err := ExecuteCommand(rootCmd, cmdKameletRemoveRepo, "--nonExistingFlag", "foo")
- require.Error(t, err)
-}
-
-func TestKameletRemoveRepoURINotFoundEmpty(t *testing.T) {
- repositories := []v1.KameletRepositorySpec{}
- _, err := getURIIndex("foo", repositories)
- require.Error(t, err)
-}
-
-func TestKameletRemoveRepoURINotFoundNotEmpty(t *testing.T) {
- repositories := []v1.KameletRepositorySpec{{URI: "github:foo/bar"}}
- _, err := getURIIndex("foo", repositories)
- require.Error(t, err)
-}
-
-func TestKameletRemoveRepoURIFound(t *testing.T) {
- repositories := []v1.KameletRepositorySpec{{URI: "github:foo/bar1"}, {URI: "github:foo/bar2"}, {URI: "github:foo/bar3"}}
- i, err := getURIIndex("github:foo/bar2", repositories)
- require.NoError(t, err)
- assert.Equal(t, 1, i)
-}
diff --git a/pkg/cmd/modeline_test.go b/pkg/cmd/modeline_test.go
index 66e1e2753..479d62c96 100644
--- a/pkg/cmd/modeline_test.go
+++ b/pkg/cmd/modeline_test.go
@@ -35,7 +35,7 @@ func TestModelineRunSimple(t *testing.T) {
file := `
// camel-k: dependency=mvn:org.my:lib:1.0
`
- fileName := filepath.Join(dir, "simple.groovy")
+ fileName := filepath.Join(dir, "simple.java")
err := os.WriteFile(fileName, []byte(file), 0o400)
require.NoError(t, err)
@@ -53,7 +53,7 @@ func TestModelineRunSimple(t *testing.T) {
func TestModelineRunHelp(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
// no file created
- fileName := filepath.Join(dir, "simple.groovy")
+ fileName := filepath.Join(dir, "simple.java")
cmd, flags, err := NewKamelWithModelineCommand(context.TODO(), []string{"kamel", "run", fileName, "--help"})
require.NoError(t, err)
@@ -71,7 +71,7 @@ func TestModelineRunChain(t *testing.T) {
file := `
// camel-k: dependency=mvn:org.my:lib:2.0
`
- fileName := filepath.Join(dir, "simple.groovy")
+ fileName := filepath.Join(dir, "simple.java")
err := os.WriteFile(fileName, []byte(file), 0o400)
require.NoError(t, err)
@@ -91,14 +91,14 @@ func TestModelineRunMultipleFiles(t *testing.T) {
file := `
// camel-k: dependency=mvn:org.my:lib1:3.0
`
- fileName := filepath.Join(dir, "simple.groovy")
+ fileName := filepath.Join(dir, "simple.java")
err := os.WriteFile(fileName, []byte(file), 0o400)
require.NoError(t, err)
file2 := `
// camel-k: dependency=mvn:org.my:lib2:3.0
`
- fileName2 := filepath.Join(dir, "ext.groovy")
+ fileName2 := filepath.Join(dir, "ext.java")
err = os.WriteFile(fileName2, []byte(file2), 0o400)
require.NoError(t, err)
@@ -122,7 +122,7 @@ func TestModelineRunProperty(t *testing.T) {
file := `
// camel-k: property=my-prop=my-val
`
- fileName := filepath.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.java")
err = os.WriteFile(fileName, []byte(file), 0o400)
require.NoError(t, err)
@@ -148,7 +148,7 @@ func TestModelineRunDuplicatedProperties(t *testing.T) {
// camel-k: property=prop2=false
// camel-k: property=foo=bar
`
- fileName := filepath.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.java")
err = os.WriteFile(fileName, []byte(file), 0o400)
require.NoError(t, err)
@@ -174,7 +174,7 @@ func TestModelineRunDuplicatedBuildProperties(t *testing.T) {
// camel-k: build-property=prop2=false
// camel-k: build-property=foo=bar
`
- fileName := filepath.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.java")
err = os.WriteFile(fileName, []byte(file), 0o400)
require.NoError(t, err)
@@ -204,7 +204,7 @@ func TestModelineRunPropertyFiles(t *testing.T) {
file := `
// camel-k: property=file:application.properties
`
- fileName := filepath.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.java")
err = os.WriteFile(fileName, []byte(file), 0o400)
require.NoError(t, err)
@@ -235,7 +235,7 @@ func TestModelineRunBuildProperty(t *testing.T) {
file := `
// camel-k: build-property=my-build-prop=my-val
`
- fileName := filepath.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.java")
err = os.WriteFile(fileName, []byte(file), 0o400)
require.NoError(t, err)
@@ -259,7 +259,7 @@ func TestModelineRunBuildPropertyFiles(t *testing.T) {
file := `
// camel-k: build-property=file:application.properties
`
- fileName := filepath.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.java")
err = os.WriteFile(fileName, []byte(file), 0o400)
require.NoError(t, err)
@@ -292,7 +292,7 @@ func TestModelineRunDuplicateTraits(t *testing.T) {
// camel-k: trait=trait2=false
// camel-k: trait=foo=bar
`
- fileName := filepath.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.java")
err = os.WriteFile(fileName, []byte(file), 0o400)
require.NoError(t, err)
@@ -316,7 +316,7 @@ func TestModelineRunConfigConfigmap(t *testing.T) {
file := `
// camel-k: config=configmap:my-cm
`
- fileName := filepath.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.java")
err = os.WriteFile(fileName, []byte(file), 0o400)
require.NoError(t, err)
@@ -340,7 +340,7 @@ func TestModelineRunConfigSecret(t *testing.T) {
file := `
// camel-k: config=secret:my-secret
`
- fileName := filepath.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.java")
err = os.WriteFile(fileName, []byte(file), 0o400)
require.NoError(t, err)
@@ -364,7 +364,7 @@ func TestModelineRunResourceConfigmap(t *testing.T) {
file := `
// camel-k: resource=configmap:my-cm
`
- fileName := filepath.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.java")
err = os.WriteFile(fileName, []byte(file), 0o400)
require.NoError(t, err)
@@ -388,7 +388,7 @@ func TestModelineRunResourceSecret(t *testing.T) {
file := `
// camel-k: resource=secret:my-secret
`
- fileName := filepath.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.java")
err = os.WriteFile(fileName, []byte(file), 0o400)
require.NoError(t, err)
@@ -409,7 +409,7 @@ func TestModelineQuotedPodTemplate(t *testing.T) {
file := `
// camel-k: pod-template='{ "containers": [], "securityContext": { "supplementalGroups": [ 553 ] }, "volumes": [] } }'
`
- fileName := filepath.Join(dir, "simple.groovy")
+ fileName := filepath.Join(dir, "simple.java")
err := os.WriteFile(fileName, []byte(file), 0o400)
require.NoError(t, err)
diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go
index fb1488d3e..53bb32ec4 100644
--- a/pkg/cmd/root.go
+++ b/pkg/cmd/root.go
@@ -142,7 +142,6 @@ func addKamelSubcommands(cmd *cobra.Command, options *RootCmdOptions) {
cmd.AddCommand(cmdOnly(newCmdLog(options)))
cmd.AddCommand(newCmdKit(options))
cmd.AddCommand(cmdOnly(newCmdReset(options)))
- cmd.AddCommand(newCmdDescribe(options))
cmd.AddCommand(cmdOnly(newCmdRebuild(options)))
cmd.AddCommand(cmdOnly(newCmdOperator(options)))
cmd.AddCommand(cmdOnly(newCmdBuilder(options)))
@@ -150,8 +149,6 @@ func addKamelSubcommands(cmd *cobra.Command, options *RootCmdOptions) {
cmd.AddCommand(cmdOnly(newCmdDump(options)))
cmd.AddCommand(cmdOnly(newCmdBind(options)))
cmd.AddCommand(cmdOnly(newCmdPromote(options)))
- cmd.AddCommand(newCmdKamelet(options))
- cmd.AddCommand(cmdOnly(newCmdConfig(options)))
}
func addHelpSubCommands(cmd *cobra.Command) error {
diff --git a/pkg/cmd/util_config.go b/pkg/cmd/util_config.go
index fd40eaf99..f8b748d0b 100644
--- a/pkg/cmd/util_config.go
+++ b/pkg/cmd/util_config.go
@@ -59,11 +59,6 @@ func LoadConfiguration() (*Config, error) {
return loadConfiguration(viper.ConfigFileUsed())
}
-// LoadConfigurationFrom loads a kamel configuration file from a specific location.
-func LoadConfigurationFrom(location string) (*Config, error) {
- return loadConfiguration(location)
-}
-
func loadConfiguration(location string) (*Config, error) {
config := Config{
location: location,
diff --git a/pkg/controller/integration/kits_test.go b/pkg/controller/integration/kits_test.go
index a501e1a8c..961d2a4ee 100644
--- a/pkg/controller/integration/kits_test.go
+++ b/pkg/controller/integration/kits_test.go
@@ -341,7 +341,7 @@ func TestHasMatchingSources(t *testing.T) {
integration := &v1.Integration{
Spec: v1.IntegrationSpec{
Sources: []v1.SourceSpec{
- v1.NewSourceSpec("test", "some content", v1.LanguageJavaShell),
+ v1.NewSourceSpec("test", "some content", v1.LanguageJavaSource),
},
},
}
@@ -349,7 +349,7 @@ func TestHasMatchingSources(t *testing.T) {
kit := &v1.IntegrationKit{
Spec: v1.IntegrationKitSpec{
Sources: []v1.SourceSpec{
- v1.NewSourceSpec("test", "some content", v1.LanguageJavaShell),
+ v1.NewSourceSpec("test", "some content", v1.LanguageJavaSource),
},
},
}
@@ -360,8 +360,8 @@ func TestHasMatchingSources(t *testing.T) {
kit2 := &v1.IntegrationKit{
Spec: v1.IntegrationKitSpec{
Sources: []v1.SourceSpec{
- v1.NewSourceSpec("test", "some content 2", v1.LanguageJavaShell),
- v1.NewSourceSpec("test", "some content", v1.LanguageJavaShell),
+ v1.NewSourceSpec("test", "some content 2", v1.LanguageJavaSource),
+ v1.NewSourceSpec("test", "some content", v1.LanguageJavaSource),
},
},
}
@@ -374,8 +374,8 @@ func TestHasMatchingMultipleSources(t *testing.T) {
integration := &v1.Integration{
Spec: v1.IntegrationSpec{
Sources: []v1.SourceSpec{
- v1.NewSourceSpec("test", "some content", v1.LanguageJavaShell),
- v1.NewSourceSpec("test", "some content 2", v1.LanguageJavaShell),
+ v1.NewSourceSpec("test", "some content", v1.LanguageJavaSource),
+ v1.NewSourceSpec("test", "some content 2", v1.LanguageJavaSource),
},
},
}
@@ -383,8 +383,8 @@ func TestHasMatchingMultipleSources(t *testing.T) {
kit := &v1.IntegrationKit{
Spec: v1.IntegrationKitSpec{
Sources: []v1.SourceSpec{
- v1.NewSourceSpec("test", "some content 2", v1.LanguageJavaShell),
- v1.NewSourceSpec("test", "some content", v1.LanguageJavaShell),
+ v1.NewSourceSpec("test", "some content 2", v1.LanguageJavaSource),
+ v1.NewSourceSpec("test", "some content", v1.LanguageJavaSource),
},
},
}
@@ -395,7 +395,7 @@ func TestHasMatchingMultipleSources(t *testing.T) {
integration2 := &v1.Integration{
Spec: v1.IntegrationSpec{
Sources: []v1.SourceSpec{
- v1.NewSourceSpec("test", "some content", v1.LanguageJavaShell),
+ v1.NewSourceSpec("test", "some content", v1.LanguageJavaSource),
},
},
}
@@ -408,7 +408,7 @@ func TestHasNotMatchingSources(t *testing.T) {
integration := &v1.Integration{
Spec: v1.IntegrationSpec{
Sources: []v1.SourceSpec{
- v1.NewSourceSpec("test", "some content", v1.LanguageJavaShell),
+ v1.NewSourceSpec("test", "some content", v1.LanguageJavaSource),
},
},
}
@@ -416,7 +416,7 @@ func TestHasNotMatchingSources(t *testing.T) {
kit := &v1.IntegrationKit{
Spec: v1.IntegrationKitSpec{
Sources: []v1.SourceSpec{
- v1.NewSourceSpec("test", "some content 2", v1.LanguageJavaShell),
+ v1.NewSourceSpec("test", "some content 2", v1.LanguageJavaSource),
},
},
}
diff --git a/pkg/metadata/metadata_dependencies_test.go b/pkg/metadata/metadata_dependencies_test.go
index 762bc34f4..18532aab6 100644
--- a/pkg/metadata/metadata_dependencies_test.go
+++ b/pkg/metadata/metadata_dependencies_test.go
@@ -62,75 +62,6 @@ func TestDependenciesJavaSource(t *testing.T) {
meta.Dependencies.List())
}
-func TestDependenciesJavaScript(t *testing.T) {
- code := v1.SourceSpec{
- DataSpec: v1.DataSpec{
- Name: "source.js",
- Content: `
- var component = Java.type("org.apache.camel.component.kafka.KafkaComponent");
-
- from('telegram:bots/cippa').to("log:stash");
- from('timer:tick').to("amqp:queue");
- '"'
- `,
- },
- Language: v1.LanguageJavaScript,
- }
-
- catalog, err := camel.DefaultCatalog()
- require.NoError(t, err)
-
- meta, err := extract(catalog, code)
- require.NoError(t, err)
-
- assert.ElementsMatch(
- t,
- []string{
- "camel:kafka",
- "camel:amqp",
- "camel:log",
- "camel:telegram",
- "camel:timer",
- },
- meta.Dependencies.List())
-}
-
-func TestDependenciesGroovy(t *testing.T) {
- code := v1.SourceSpec{
- DataSpec: v1.DataSpec{
- Name: "source.groovy",
- Content: `
- import org.apache.camel.component.kafka.KafkaComponent;
-
- from('telegram:bots/cippa').to("log:stash");
- from('timer:tick').to("amqp:queue");
- from('twitter-search:{{twitterKeywords}}'
- + '?delay={{twitterDelayMs}}');
- '"
- `,
- },
- Language: v1.LanguageGroovy,
- }
-
- catalog, err := camel.DefaultCatalog()
- require.NoError(t, err)
-
- meta, err := extract(catalog, code)
- require.NoError(t, err)
-
- assert.ElementsMatch(
- t,
- []string{
- "camel:kafka",
- "camel:amqp",
- "camel:log",
- "camel:telegram",
- "camel:timer",
- "camel:twitter",
- },
- meta.Dependencies.List())
-}
-
func TestDependencies(t *testing.T) {
code := v1.SourceSpec{
DataSpec: v1.DataSpec{
@@ -249,14 +180,14 @@ func TestJacksonDependency(t *testing.T) {
func TestJacksonImplicitDependency(t *testing.T) {
code := v1.SourceSpec{
DataSpec: v1.DataSpec{
- Name: "Request.groovy",
+ Name: "Request.java",
Content: `
from("http:test")
.unmarshal().json()
.to("log:end")
`,
},
- Language: v1.LanguageGroovy,
+ Language: v1.LanguageJavaSource,
}
catalog, err := camel.DefaultCatalog()
@@ -348,7 +279,7 @@ func TestLanguageDependenciesTransformExpression(t *testing.T) {
func TestCircuitBreakerDependency(t *testing.T) {
code := v1.SourceSpec{
DataSpec: v1.DataSpec{
- Name: "Request.groovy",
+ Name: "Request.java",
Content: `
from("http:test")
.circuitBreaker()
@@ -357,7 +288,7 @@ func TestCircuitBreakerDependency(t *testing.T) {
.to("log:fallback")
`,
},
- Language: v1.LanguageGroovy,
+ Language: v1.LanguageJavaSource,
}
catalog, err := camel.DefaultCatalog()
@@ -379,7 +310,7 @@ func TestCircuitBreakerDependency(t *testing.T) {
func TestRestDependency(t *testing.T) {
code := v1.SourceSpec{
DataSpec: v1.DataSpec{
- Name: "Request.groovy",
+ Name: "Request.java",
Content: `
rest()
.get("/api")
@@ -388,7 +319,7 @@ func TestRestDependency(t *testing.T) {
.to("log:info")
`,
},
- Language: v1.LanguageGroovy,
+ Language: v1.LanguageJavaSource,
}
catalog, err := camel.DefaultCatalog()
@@ -412,7 +343,7 @@ func TestRestDependency(t *testing.T) {
func TestRestWithPathDependency(t *testing.T) {
code := v1.SourceSpec{
DataSpec: v1.DataSpec{
- Name: "Request.groovy",
+ Name: "Request.java",
Content: `
rest("/test")
.get("/api")
@@ -421,7 +352,7 @@ func TestRestWithPathDependency(t *testing.T) {
.to("log:info")
`,
},
- Language: v1.LanguageGroovy,
+ Language: v1.LanguageJavaSource,
}
catalog, err := camel.DefaultCatalog()
@@ -444,7 +375,7 @@ func TestRestWithPathDependency(t *testing.T) {
func TestRestConfigurationDependency(t *testing.T) {
code := v1.SourceSpec{
DataSpec: v1.DataSpec{
- Name: "Request.groovy",
+ Name: "Request.java",
Content: `
restConfiguration()
.component("netty-http")
@@ -452,7 +383,7 @@ func TestRestConfigurationDependency(t *testing.T) {
.to("log:info")
`,
},
- Language: v1.LanguageGroovy,
+ Language: v1.LanguageJavaSource,
}
catalog, err := camel.DefaultCatalog()
@@ -471,68 +402,6 @@ func TestRestConfigurationDependency(t *testing.T) {
meta.Dependencies.List())
}
-func TestRestClosureDependencyGroovy(t *testing.T) {
- code := v1.SourceSpec{
- DataSpec: v1.DataSpec{
- Name: "Request.groovy",
- Content: `
- rest {
- }
- from("http:test")
- .to("log:info")
- `,
- },
- Language: v1.LanguageGroovy,
- }
-
- catalog, err := camel.DefaultCatalog()
- require.NoError(t, err)
-
- meta, err := extract(catalog, code)
- require.NoError(t, err)
-
- assert.ElementsMatch(
- t,
- []string{
- "camel:http",
- "camel:log",
- "mvn:org.apache.camel.quarkus:camel-quarkus-rest",
- "mvn:org.apache.camel.quarkus:camel-quarkus-platform-http",
- },
- meta.Dependencies.List())
-}
-
-func TestRestClosureDependencyKotlin(t *testing.T) {
- code := v1.SourceSpec{
- DataSpec: v1.DataSpec{
- Name: "Request.groovy",
- Content: `
- rest {
- }
- from("http:test")
- .to("log:info")
- `,
- },
- Language: v1.LanguageKotlin,
- }
-
- catalog, err := camel.DefaultCatalog()
- require.NoError(t, err)
-
- meta, err := extract(catalog, code)
- require.NoError(t, err)
-
- assert.ElementsMatch(
- t,
- []string{
- "camel:http",
- "camel:log",
- "mvn:org.apache.camel.quarkus:camel-quarkus-rest",
- "mvn:org.apache.camel.quarkus:camel-quarkus-platform-http",
- },
- meta.Dependencies.List())
-}
-
func TestXMLCircuitBreakerDependency(t *testing.T) {
code := v1.SourceSpec{
diff --git a/pkg/metadata/metadata_http_test.go b/pkg/metadata/metadata_http_test.go
index 07d563a97..0388257e0 100644
--- a/pkg/metadata/metadata_http_test.go
+++ b/pkg/metadata/metadata_http_test.go
@@ -118,52 +118,6 @@ func TestHttpOnlyJavaSourceRest2(t *testing.T) {
assert.True(t, meta.PassiveEndpoints)
}
-func TestNoHttpGroovySource(t *testing.T) {
- code := v1.SourceSpec{
- DataSpec: v1.DataSpec{
- Name: "Request.groovy",
- Content: `
- from('direct:bots/cippa').to("log:stash");
- from('telegram:uri').to("log:stash");
- from('seda:path').to("log:stash");
- `,
- },
- Language: v1.LanguageGroovy,
- }
-
- catalog, err := camel.DefaultCatalog()
- require.NoError(t, err)
-
- meta, err := extract(catalog, code)
- require.NoError(t, err)
-
- assert.False(t, meta.ExposesHTTPServices)
- assert.False(t, meta.PassiveEndpoints)
-}
-
-func TestHttpOnlyGroovySource(t *testing.T) {
- code := v1.SourceSpec{
- DataSpec: v1.DataSpec{
- Name: "Request.groovy",
- Content: `
- from('direct:bots/cippa').to("log:stash");
- from('netty-http:uri').to("log:stash");
- from('seda:path').to("log:stash");
- `,
- },
- Language: v1.LanguageGroovy,
- }
-
- catalog, err := camel.DefaultCatalog()
- require.NoError(t, err)
-
- meta, err := extract(catalog, code)
- require.NoError(t, err)
-
- assert.True(t, meta.ExposesHTTPServices)
- assert.True(t, meta.PassiveEndpoints)
-}
-
func TestHttpXMLSource(t *testing.T) {
code := v1.SourceSpec{
DataSpec: v1.DataSpec{
@@ -227,12 +181,12 @@ func TestMultilangHTTPOnlySource(t *testing.T) {
{
DataSpec: v1.DataSpec{
- Name: "routes2.groovy",
+ Name: "routes2.java",
Content: `
- from('seda:in').to('seda:out')
+ from("seda:in").to("seda:out");
`,
},
- Language: v1.LanguageGroovy,
+ Language: v1.LanguageJavaSource,
},
}
@@ -263,13 +217,13 @@ func TestMultilangHTTPSource(t *testing.T) {
{
DataSpec: v1.DataSpec{
- Name: "routes2.groovy",
+ Name: "routes2.java",
Content: `
- from('seda:in').to('seda:out')
- from('timer:tick').to('log:info')
+ from("seda:in").to("seda:out")
+ from("timer:tick").to("log:info")
`,
},
- Language: v1.LanguageGroovy,
+ Language: v1.LanguageJavaSource,
},
}
diff --git a/pkg/metadata/metadata_uri_test.go b/pkg/metadata/metadata_uri_test.go
index 8ac841334..e72d681ac 100644
--- a/pkg/metadata/metadata_uri_test.go
+++ b/pkg/metadata/metadata_uri_test.go
@@ -99,71 +99,6 @@ func TestJava2(t *testing.T) {
assert.Len(t, metadata.ToURIs, 3)
}
-func TestGroovy1(t *testing.T) {
- source := v1.SourceSpec{
- DataSpec: v1.DataSpec{
- Name: "test",
- Content: `
-
- from( "timer:tick")
- .setBody().constant("aa")
- .to ('log:info?skipBodyLineSeparator=false').to(
- 'http://url' )
-
- from("direct:2")
- .setBody().constant("aa")
- .to('direct:3')
- `,
- },
- Language: v1.LanguageGroovy,
- }
-
- catalog, err := camel.DefaultCatalog()
- require.NoError(t, err)
-
- metadata, err := extract(catalog, source)
- require.NoError(t, err)
-
- assert.Contains(t, metadata.FromURIs, "timer:tick")
- assert.Contains(t, metadata.FromURIs, "direct:2")
- assert.Len(t, metadata.FromURIs, 2)
- assert.Contains(t, metadata.ToURIs, "log:info?skipBodyLineSeparator=false")
- assert.Contains(t, metadata.ToURIs, "http://url")
- assert.Contains(t, metadata.ToURIs, "direct:3")
- assert.Len(t, metadata.ToURIs, 3)
-}
-
-func TestGroovy2(t *testing.T) {
- source := v1.SourceSpec{
- DataSpec: v1.DataSpec{
- Name: "test",
- Content: `
- rest().get("/")
- .to ('log:info?skipBodyLineSeparator=false').to( 'http://url' )
- .toD('seda:1')
- .tony('thisisnot:anuri')
- .toD( "seda:2")
- .toF( "file:%s", "2")
- `,
- },
- Language: v1.LanguageGroovy,
- }
-
- catalog, err := camel.DefaultCatalog()
- require.NoError(t, err)
-
- metadata, err := extract(catalog, source)
- require.NoError(t, err)
-
- assert.Empty(t, metadata.FromURIs)
- assert.Contains(t, metadata.ToURIs, "log:info?skipBodyLineSeparator=false")
- assert.Contains(t, metadata.ToURIs, "http://url")
- assert.Contains(t, metadata.ToURIs, "seda:1")
- assert.Contains(t, metadata.ToURIs, "seda:2")
- assert.Contains(t, metadata.ToURIs, "file:%s") // resolution not supported yet
- assert.Len(t, metadata.ToURIs, 5)
-}
-
func TestXml1(t *testing.T) {
source := v1.SourceSpec{
DataSpec: v1.DataSpec{
@@ -199,73 +134,6 @@ func TestXml1(t *testing.T) {
assert.Len(t, metadata.ToURIs, 3)
}
-func TestKotlin1(t *testing.T) {
- source := v1.SourceSpec{
- DataSpec: v1.DataSpec{
- Name: "test",
- Content: `
-
- from( "timer:tick")
- .setBody().constant("aa")
- .to ("log:info?skipBodyLineSeparator=false").to(
- "http://url" )
-
- from("direct:2")
- .setBody().constant("aa")
- .to("direct:3")
- .toD("direct:4")
- .toF("direct:%s", 5)
- `,
- },
- Language: v1.LanguageKotlin,
- }
-
- catalog, err := camel.DefaultCatalog()
- require.NoError(t, err)
-
- metadata, err := extract(catalog, source)
- require.NoError(t, err)
-
- assert.Contains(t, metadata.FromURIs, "timer:tick")
- assert.Contains(t, metadata.FromURIs, "direct:2")
- assert.Len(t, metadata.FromURIs, 2)
- assert.Contains(t, metadata.ToURIs, "log:info?skipBodyLineSeparator=false")
- assert.Contains(t, metadata.ToURIs, "http://url")
- assert.Contains(t, metadata.ToURIs, "direct:3")
- assert.Contains(t, metadata.ToURIs, "direct:4")
- assert.Contains(t, metadata.ToURIs, "direct:%s") // resolution not supported yet
- assert.Len(t, metadata.ToURIs, 5)
-}
-
-func TestJavascript1(t *testing.T) {
- source := v1.SourceSpec{
- DataSpec: v1.DataSpec{
- Name: "test",
- Content: `
-
- rest().get("/")
- .to ('log:info?skipBodyLineSeparator=false').to( 'http://url' )
- .toD("direct:2")
- .toF("direct:%s", "3")
- `,
- },
- Language: v1.LanguageJavaScript,
- }
-
- catalog, err := camel.DefaultCatalog()
- require.NoError(t, err)
-
- metadata, err := extract(catalog, source)
- require.NoError(t, err)
-
- assert.Empty(t, metadata.FromURIs)
- assert.Contains(t, metadata.ToURIs, "log:info?skipBodyLineSeparator=false")
- assert.Contains(t, metadata.ToURIs, "http://url")
- assert.Contains(t, metadata.ToURIs, "direct:2")
- assert.Contains(t, metadata.ToURIs, "direct:%s") // resolution not supported yet
- assert.Len(t, metadata.ToURIs, 4)
-}
-
const yaml = `
- from:
uri: "timer:tick"
diff --git a/pkg/trait/kamelets_support_test.go b/pkg/trait/kamelets_support_test.go
index 26188f530..ac53a0e2c 100644
--- a/pkg/trait/kamelets_support_test.go
+++ b/pkg/trait/kamelets_support_test.go
@@ -90,24 +90,24 @@ func kamelet(ns, name string) *v1.Kamelet {
Sources: []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "mykamelet.groovy",
- Content: `from("timer1").to("log:info")
- from("timer2").to("log:info")
- from("timer3").to("log:info")
- from("timer4").to("log:info")
- from("timer5").to("log:info")
- from("timer6").to("log:info")
- from("timer7").to("log:info")
- from("timer8").to("log:info")
- from("timer9").to("log:info")
- from("timer10").to("log:info")
- from("timer11").to("log:info")
- from("timer12").to("log:info")
- from("timer13").to("log:info")
- from("timer14").to("log:info")
- from("timer15").to("log:info")
- from("timer16").to("log:info")
- from("timer17").to("log:info")`,
+ Name: "mykamelet.java",
+ Content: `from("timer1").to("log:info");
+ from("timer2").to("log:info");
+ from("timer3").to("log:info");
+ from("timer4").to("log:info");
+ from("timer5").to("log:info");
+ from("timer6").to("log:info");
+ from("timer7").to("log:info");
+ from("timer8").to("log:info");
+ from("timer9").to("log:info");
+ from("timer10").to("log:info");
+ from("timer11").to("log:info");
+ from("timer12").to("log:info");
+ from("timer13").to("log:info");
+ from("timer14").to("log:info");
+ from("timer15").to("log:info");
+ from("timer16").to("log:info");
+ from("timer17").to("log:info");`,
},
Type: v1.SourceTypeTemplate,
},
diff --git a/pkg/trait/kamelets_test.go b/pkg/trait/kamelets_test.go
index 43275de86..bc59b47be 100644
--- a/pkg/trait/kamelets_test.go
+++ b/pkg/trait/kamelets_test.go
@@ -139,10 +139,10 @@ func TestKameletSecondarySourcesLookup(t *testing.T) {
Sources: []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "support.groovy",
+ Name: "support.java",
Content: "from('xxx:xxx').('to:log:info')",
},
- Language: v1.LanguageGroovy,
+ Language: v1.LanguageJavaSource,
},
},
},
@@ -170,7 +170,7 @@ func TestKameletSecondarySourcesLookup(t *testing.T) {
assert.Equal(t, "content", flowSource.ContentKey)
supportSource := environment.Integration.Status.GeneratedSources[1]
- assert.Equal(t, "support.groovy", supportSource.Name)
+ assert.Equal(t, "support.java", supportSource.Name)
assert.Equal(t, "", string(supportSource.Type))
assert.Equal(t, "it-kamelet-timer-000", supportSource.ContentRef)
assert.Equal(t, "content", supportSource.ContentKey)
@@ -192,8 +192,8 @@ func TestNonYAMLKameletLookup(t *testing.T) {
Sources: []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "mykamelet.groovy",
- Content: `from("timer").to("log:info")`,
+ Name: "mykamelet.java",
+ Content: `from("timer").to("log:info");`,
},
Type: v1.SourceTypeTemplate,
},
@@ -216,7 +216,7 @@ func TestNonYAMLKameletLookup(t *testing.T) {
assert.Len(t, environment.Integration.Status.GeneratedSources, 1)
source := environment.Integration.Status.GeneratedSources[0]
- assert.Equal(t, "timer.groovy", source.Name)
+ assert.Equal(t, "timer.java", source.Name)
assert.Equal(t, "template", string(source.Type))
}
@@ -248,10 +248,10 @@ func TestMultipleKamelets(t *testing.T) {
Sources: []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "support.groovy",
+ Name: "support.java",
Content: "from('xxx:xxx').('to:log:info')",
},
- Language: v1.LanguageGroovy,
+ Language: v1.LanguageJavaSource,
},
},
Dependencies: []string{
@@ -331,11 +331,11 @@ func TestMultipleKamelets(t *testing.T) {
expectedFlowSourceTimerV1 := v1.SourceSpec{
DataSpec: v1.DataSpec{
- Name: "support.groovy",
+ Name: "support.java",
ContentRef: "it-kamelet-timer-000",
ContentKey: "content",
},
- Language: v1.LanguageGroovy,
+ Language: v1.LanguageJavaSource,
FromKamelet: true,
}
diff --git a/pkg/trait/knative_service_test.go b/pkg/trait/knative_service_test.go
index bb8cbc71a..27c460730 100644
--- a/pkg/trait/knative_service_test.go
+++ b/pkg/trait/knative_service_test.go
@@ -54,7 +54,7 @@ func TestKnativeService(t *testing.T) {
client, _ := internal.NewFakeClient()
traitCatalog := NewCatalog(nil)
- compressedRoute, err := gzip.CompressBase64([]byte(`from("platform-http:test").log("hello")`))
+ compressedRoute, err := gzip.CompressBase64([]byte(`from("platform-http:test").log("hello");`))
require.NoError(t, err)
environment := Environment{
@@ -74,11 +74,11 @@ func TestKnativeService(t *testing.T) {
Sources: []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "routes.js",
+ Name: "routes.java",
Content: string(compressedRoute),
Compression: true,
},
- Language: v1.LanguageJavaScript,
+ Language: v1.LanguageJavaSource,
},
},
Traits: v1.Traits{
@@ -183,8 +183,8 @@ func TestKnativeService(t *testing.T) {
}
})
- assert.Equal(t, "file:/etc/camel/sources/routes.js", environment.ApplicationProperties["camel.k.sources[0].location"])
- assert.Equal(t, "js", environment.ApplicationProperties["camel.k.sources[0].language"])
+ assert.Equal(t, "file:/etc/camel/sources/routes.java", environment.ApplicationProperties["camel.k.sources[0].location"])
+ assert.Equal(t, "java", environment.ApplicationProperties["camel.k.sources[0].language"])
assert.Equal(t, boolean.TrueString, environment.ApplicationProperties["camel.k.sources[0].compressed"])
envVarHasValue(t, spec.Containers[0].Env, "CAMEL_K_CONF", filepath.FromSlash("/etc/camel/application.properties"))
envVarHasValue(t, spec.Containers[0].Env, "CAMEL_K_CONF_D", filepath.FromSlash("/etc/camel/conf.d"))
@@ -307,10 +307,10 @@ func TestKnativeServiceWithRest(t *testing.T) {
Sources: []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "routes.js",
- Content: `from("direct:test").log("hello")`,
+ Name: "routes.java",
+ Content: `from("direct:test").log("hello");`,
},
- Language: v1.LanguageJavaScript,
+ Language: v1.LanguageJavaSource,
},
{
DataSpec: v1.DataSpec{
@@ -382,10 +382,10 @@ func TestKnativeServiceNotApplicable(t *testing.T) {
Sources: []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "routes.js",
- Content: `from("timer:tick").log("hello")`,
+ Name: "routes.java",
+ Content: `from("timer:tick").log("hello");`,
},
- Language: v1.LanguageJavaScript,
+ Language: v1.LanguageJavaSource,
},
},
},
@@ -457,10 +457,10 @@ func TestKnativeServiceNoServingAvailable(t *testing.T) {
Sources: []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "routes.js",
- Content: `from("platform-http:test").log("hello")`,
+ Name: "routes.java",
+ Content: `from("platform-http:test").log("hello");`,
},
- Language: v1.LanguageJavaScript,
+ Language: v1.LanguageJavaSource,
},
},
},
@@ -575,10 +575,10 @@ func createKnativeServiceTestEnvironment(t *testing.T, trait *traitv1.KnativeSer
Sources: []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "routes.js",
- Content: `from("direct:test").log("hello")`,
+ Name: "routes.java",
+ Content: `from("direct:test").log("hello");`,
},
- Language: v1.LanguageJavaScript,
+ Language: v1.LanguageJavaSource,
},
{
DataSpec: v1.DataSpec{
@@ -668,11 +668,11 @@ func TestKnativeServiceAuto(t *testing.T) {
Sources: []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "routes.js",
+ Name: "routes.java",
Content: string(compressedRoute),
Compression: true,
},
- Language: v1.LanguageJavaScript,
+ Language: v1.LanguageJavaSource,
},
},
},
diff --git a/pkg/trait/knative_test.go b/pkg/trait/knative_test.go
index 47d0aacc2..2e64168a3 100644
--- a/pkg/trait/knative_test.go
+++ b/pkg/trait/knative_test.go
@@ -1146,24 +1146,24 @@ func TestKnativePlatformHttpConfig(t *testing.T) {
sources := []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "source-endpoint.groovy",
- Content: `from('knative:endpoint/ep').log('${body}')`,
+ Name: "source-endpoint.java",
+ Content: `from("knative:endpoint/ep").log("${body}");`,
},
- Language: v1.LanguageGroovy,
+ Language: v1.LanguageJavaSource,
},
{
DataSpec: v1.DataSpec{
- Name: "source-channel.groovy",
- Content: `from('knative:channel/channel-source-1').log('${body}')`,
+ Name: "source-channel.java",
+ Content: `from("knative:channel/channel-source-1").log("${body}");`,
},
- Language: v1.LanguageGroovy,
+ Language: v1.LanguageJavaSource,
},
{
DataSpec: v1.DataSpec{
- Name: "source-event.groovy",
- Content: `from('knative:event/event-source-1').log('${body}')`,
+ Name: "source-event.java",
+ Content: `from("knative:event/event-source-1").log("${body}")`,
},
- Language: v1.LanguageGroovy,
+ Language: v1.LanguageJavaSource,
},
}
@@ -1191,24 +1191,24 @@ func TestKnativePlatformHttpDependencies(t *testing.T) {
sources := []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "source-endpoint.groovy",
- Content: `from('knative:endpoint/ep').log('${body}')`,
+ Name: "source-endpoint.java",
+ Content: `from("knative:endpoint/ep").log("${body}");`,
},
- Language: v1.LanguageGroovy,
+ Language: v1.LanguageJavaSource,
},
{
DataSpec: v1.DataSpec{
- Name: "source-channel.groovy",
- Content: `from('knative:channel/channel-source-1').log('${body}')`,
+ Name: "source-channel.java",
+ Content: `from("knative:channel/channel-source-1").log("${body}");`,
},
- Language: v1.LanguageGroovy,
+ Language: v1.LanguageJavaSource,
},
{
DataSpec: v1.DataSpec{
- Name: "source-event.groovy",
- Content: `from('knative:event/event-source-1').log('${body}')`,
+ Name: "source-event.java",
+ Content: `from("knative:event/event-source-1").log("${body}")`,
},
- Language: v1.LanguageGroovy,
+ Language: v1.LanguageJavaSource,
},
}
@@ -1261,10 +1261,10 @@ func TestKnativeEnabled(t *testing.T) {
Sources: []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "route.groovy",
- Content: `from('timer:foo').to('knative:channel/channel-source-1')`,
+ Name: "route.java",
+ Content: `from("timer:foo").to("knative:channel/channel-source-1")`,
},
- Language: v1.LanguageGroovy,
+ Language: v1.LanguageJavaSource,
},
},
},
@@ -1332,10 +1332,10 @@ func TestKnativeNotEnabled(t *testing.T) {
Sources: []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "route.groovy",
- Content: `from('timer:foo').to('log:info')`,
+ Name: "route.java",
+ Content: `from("timer:foo").to("log:info");`,
},
- Language: v1.LanguageGroovy,
+ Language: v1.LanguageJavaSource,
},
},
},
@@ -1637,10 +1637,10 @@ func newFakeClient(namespace string) (client.Client, error) {
func TestKnativeSinkBinding(t *testing.T) {
source := v1.SourceSpec{
DataSpec: v1.DataSpec{
- Name: "sink.groovy",
- Content: `from('timer:foo').to('knative:channel/channel-sink-1?apiVersion=messaging.knative.dev%2Fv1&kind=Channel')`,
+ Name: "sink.java",
+ Content: `from("timer:foo").to("knative:channel/channel-sink-1?apiVersion=messaging.knative.dev%2Fv1&kind=Channel");`,
},
- Language: v1.LanguageGroovy,
+ Language: v1.LanguageJavaSource,
}
environment := NewFakeEnvironment(t, source)
diff --git a/pkg/trait/mount_test.go b/pkg/trait/mount_test.go
index bbef83522..9ef153564 100644
--- a/pkg/trait/mount_test.go
+++ b/pkg/trait/mount_test.go
@@ -246,7 +246,7 @@ func getNominalEnv(t *testing.T, traitCatalog *Catalog) *Environment {
}
fakeClient, _ := internal.NewFakeClient(&pvc)
catalog, _ := camel.DefaultCatalog()
- compressedRoute, _ := gzip.CompressBase64([]byte(`from("platform-http:test").log("hello")`))
+ compressedRoute, _ := gzip.CompressBase64([]byte(`from("platform-http:test").log("hello");`))
return &Environment{
CamelCatalog: catalog,
@@ -265,11 +265,11 @@ func getNominalEnv(t *testing.T, traitCatalog *Catalog) *Environment {
Sources: []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "routes.js",
+ Name: "routes.java",
Content: string(compressedRoute),
Compression: true,
},
- Language: v1.LanguageJavaScript,
+ Language: v1.LanguageJavaSource,
},
},
Traits: v1.Traits{
diff --git a/pkg/trait/openapi.go b/pkg/trait/openapi.go
deleted file mode 100644
index cad9d0c63..000000000
--- a/pkg/trait/openapi.go
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
-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 trait
-
-import (
- "context"
- "fmt"
- "os"
- "path/filepath"
- "strconv"
- "strings"
-
- "github.com/apache/camel-k/v2/pkg/util/boolean"
- "github.com/apache/camel-k/v2/pkg/util/io"
-
- corev1 "k8s.io/api/core/v1"
- k8serrors "k8s.io/apimachinery/pkg/api/errors"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-
- ctrl "sigs.k8s.io/controller-runtime/pkg/client"
-
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- traitv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1/trait"
- "github.com/apache/camel-k/v2/pkg/util"
- "github.com/apache/camel-k/v2/pkg/util/defaults"
- "github.com/apache/camel-k/v2/pkg/util/digest"
- "github.com/apache/camel-k/v2/pkg/util/gzip"
- "github.com/apache/camel-k/v2/pkg/util/jvm"
- "github.com/apache/camel-k/v2/pkg/util/kubernetes"
- "github.com/apache/camel-k/v2/pkg/util/maven"
-)
-
-const (
- openapiTraitID = "openapi"
- openapiTraitOrder = 300
-)
-
-type openAPITrait struct {
- BasePlatformTrait
- traitv1.OpenAPITrait `property:",squash"`
-}
-
-func newOpenAPITrait() Trait {
- return &openAPITrait{
- BasePlatformTrait: NewBasePlatformTrait(openapiTraitID, openapiTraitOrder),
- }
-}
-
-func (t *openAPITrait) Configure(e *Environment) (bool, *TraitCondition, error) {
- if t.Configmaps != nil {
- if e.IntegrationInPhase(v1.IntegrationPhaseInitialization) {
- condition := NewIntegrationCondition(
- "OpenApi",
- v1.IntegrationConditionTraitInfo,
- corev1.ConditionTrue,
- TraitConfigurationReason,
- "OpenApi trait is deprecated and may be removed in future version: "+
- "use Camel REST contract first instead, https://camel.apache.org/manual/rest-dsl-openapi.html",
- )
-
- return true, condition, nil
- }
- }
-
- return false, nil, nil
-}
-
-func (t *openAPITrait) Apply(e *Environment) error {
- util.StringSliceUniqueAdd(&e.Integration.Status.Capabilities, v1.CapabilityRest)
-
- root := os.TempDir()
- tmpDir, err := os.MkdirTemp(root, "openapi")
- if err != nil {
- return err
- }
- defer os.RemoveAll(tmpDir)
-
- generatedFromConfigmaps, err := t.generateFromConfigmaps(e, tmpDir)
- if err != nil {
- return err
- }
- e.Integration.Status.GeneratedSources = generatedFromConfigmaps
-
- return nil
-}
-
-func (t *openAPITrait) generateFromConfigmaps(e *Environment, tmpDir string) ([]v1.SourceSpec, error) {
- dataSpecs := make([]v1.DataSpec, 0, len(t.Configmaps))
- for _, configmap := range t.Configmaps {
- cm := kubernetes.LookupConfigmap(e.Ctx, e.Client, e.Integration.Namespace, configmap)
- if cm == nil {
- return nil, fmt.Errorf("configmap %s does not exist in namespace %s", configmap, e.Integration.Namespace)
- }
- // Iterate over each configmap key which may hold a different OpenAPI spec
- for k, v := range cm.Data {
- dataSpecs = append(dataSpecs, v1.DataSpec{
- Name: k,
- Content: v,
- Compression: false,
- })
-
- }
- }
-
- return t.generateFromDataSpecs(e, tmpDir, dataSpecs)
-}
-
-func (t *openAPITrait) generateFromDataSpecs(e *Environment, tmpDir string, specs []v1.DataSpec) ([]v1.SourceSpec, error) {
- generatedSources := make([]v1.SourceSpec, 0, len(e.Integration.Status.GeneratedSources))
- for i, resource := range specs {
- generatedContentName := fmt.Sprintf("%s-openapi-%03d", e.Integration.Name, i)
- generatedSourceName := strings.TrimSuffix(resource.Name, filepath.Ext(resource.Name)) + ".xml"
- // Generate configmap or reuse existing one
- if err := t.generateOpenAPIConfigMap(e, resource, tmpDir, generatedContentName); err != nil {
- return nil, fmt.Errorf("cannot generate configmap for openapi resource %s: %w", resource.Name, err)
- }
- if e.Integration.Status.GeneratedSources != nil {
- // Filter out the previously generated source
- for _, x := range e.Integration.Status.GeneratedSources {
- if x.Name != generatedSourceName {
- generatedSources = append(generatedSources, x)
- }
- }
- }
-
- // Add a source that references the config map
- generatedSources = append(generatedSources, v1.SourceSpec{
- DataSpec: v1.DataSpec{
- Name: generatedSourceName,
- ContentRef: generatedContentName,
- Compression: resource.Compression,
- },
- Language: v1.LanguageXML,
- })
- }
-
- return generatedSources, nil
-}
-
-func (t *openAPITrait) generateOpenAPIConfigMap(e *Environment, resource v1.DataSpec, tmpDir, generatedContentName string) error {
- cm := corev1.ConfigMap{}
- key := ctrl.ObjectKey{
- Namespace: e.Integration.Namespace,
- Name: generatedContentName,
- }
- err := t.Client.Get(e.Ctx, key, &cm)
- if err != nil && k8serrors.IsNotFound(err) {
- return t.createNewOpenAPIConfigMap(e, resource, tmpDir, generatedContentName)
- } else if err != nil {
- return err
- }
-
- // ConfigMap already present, let's check if the source has not changed
- foundDigest := cm.Annotations["camel.apache.org/source.digest"]
-
- // Compute the new digest
- newDigest, err := digest.ComputeForResource(resource)
- if err != nil {
- return err
- }
-
- if foundDigest == newDigest {
- // ConfigMap already exists and matches the source
- // Re-adding it to update its revision
- cm.ResourceVersion = ""
- // Clear the managed fields to support server-side apply
- cm.ManagedFields = nil
- e.Resources.Add(&cm)
- return nil
- }
- return t.createNewOpenAPIConfigMap(e, resource, tmpDir, generatedContentName)
-}
-
-func (t *openAPITrait) createNewOpenAPIConfigMap(e *Environment, resource v1.DataSpec, tmpDir, generatedContentName string) error {
- tmpDir = filepath.Join(tmpDir, generatedContentName)
- err := os.MkdirAll(tmpDir, os.ModePerm)
- if err != nil {
- return err
- }
-
- content := []byte(resource.Content)
- if resource.Compression {
- content, err = gzip.UncompressBase64(content)
- if err != nil {
- return err
- }
- }
-
- in := filepath.Join(tmpDir, resource.Name)
- out := filepath.Join(tmpDir, "openapi-dsl.xml")
-
- err = os.WriteFile(in, content, io.FilePerm400)
- if err != nil {
- return err
- }
-
- project := t.generateMavenProject(e.CamelCatalog.Runtime.Version)
- mc := maven.NewContext(tmpDir)
- mc.LocalRepository = e.Platform.Status.Build.Maven.LocalRepository
- mc.AdditionalArguments = e.Platform.Status.Build.Maven.CLIOptions
- mc.AddArgument("-Dopenapi.spec=" + in)
- mc.AddArgument("-Ddsl.out=" + out)
-
- if settings, err := kubernetes.ResolveValueSource(e.Ctx, e.Client, e.Platform.Namespace, &e.Platform.Status.Build.Maven.Settings); err != nil {
- return err
- } else if settings != "" {
- mc.UserSettings = []byte(settings)
- }
-
- settings, err := maven.NewSettings(maven.DefaultRepositories, maven.ProxyFromEnvironment)
- if err != nil {
- return err
- }
- data, err := settings.MarshalBytes()
- if err != nil {
- return err
- }
- mc.GlobalSettings = data
- secrets := e.Platform.Status.Build.Maven.CASecrets
-
- if secrets != nil {
- certsData, err := kubernetes.GetSecretsRefData(e.Ctx, e.Client, e.Platform.Namespace, secrets)
- if err != nil {
- return err
- }
- trustStoreName := "trust.jks"
- trustStorePass := jvm.NewKeystorePassword()
- err = jvm.GenerateKeystore(e.Ctx, tmpDir, trustStoreName, trustStorePass, certsData)
- if err != nil {
- return err
- }
- mc.ExtraMavenOpts = append(mc.ExtraMavenOpts,
- "-Djavax.net.ssl.trustStore="+trustStoreName,
- "-Djavax.net.ssl.trustStorePassword="+trustStorePass,
- )
- }
-
- ctx, cancel := context.WithTimeout(e.Ctx, e.Platform.Status.Build.GetTimeout().Duration)
- defer cancel()
-
- if err := project.Command(mc).DoSettings(ctx); err != nil {
- return err
- }
- if err := project.Command(mc).DoPom(ctx); err != nil {
- return err
- }
- if err := project.Command(mc).Do(ctx); err != nil {
- return err
- }
-
- content, err = util.ReadFile(out)
- if err != nil {
- return err
- }
-
- if resource.Compression {
- c, err := gzip.CompressBase64(content)
- if err != nil {
- return err
- }
-
- content = c
- }
-
- // Compute the input digest and store it along with the configmap
- hash, err := digest.ComputeForResource(resource)
- if err != nil {
- return err
- }
-
- // Store the generated rest xml in a separate config map in order
- // not to pollute the integration with generated data
- cm := corev1.ConfigMap{
- TypeMeta: metav1.TypeMeta{
- Kind: "ConfigMap",
- APIVersion: "v1",
- },
- ObjectMeta: metav1.ObjectMeta{
- Name: generatedContentName,
- Namespace: e.Integration.Namespace,
- Labels: map[string]string{
- v1.IntegrationLabel: e.Integration.Name,
- },
- Annotations: map[string]string{
- sourceLanguageAnnotation: string(v1.LanguageXML),
- sourceNameAnnotation: resource.Name,
- sourceCompressionAnnotation: strconv.FormatBool(resource.Compression),
- "camel.apache.org/source.generated": boolean.TrueString,
- "camel.apache.org/source.type": "openapi",
- "camel.apache.org/source.digest": hash,
- },
- },
- Data: map[string]string{
- "content": string(content),
- },
- }
-
- e.Resources.Add(&cm)
- return nil
-}
-
-func (t *openAPITrait) generateMavenProject(runtimeVersion string) maven.Project {
- p := maven.NewProjectWithGAV("org.apache.camel.k.integration", "camel-k-rest-dsl-generator", defaults.Version)
- p.Build = &maven.Build{
- DefaultGoal: "generate-resources",
- Plugins: []maven.Plugin{
- {
- GroupID: "org.apache.camel.k",
- ArtifactID: "camel-k-maven-plugin",
- Version: runtimeVersion,
- Executions: []maven.Execution{
- {
- Phase: "generate-resources",
- Goals: []string{
- "generate-rest-xml",
- },
- },
- },
- },
- },
- }
-
- return p
-}
diff --git a/pkg/trait/openapi_test.go b/pkg/trait/openapi_test.go
deleted file mode 100644
index 0cb6d5f13..000000000
--- a/pkg/trait/openapi_test.go
+++ /dev/null
@@ -1,359 +0,0 @@
-/*
-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 trait
-
-import (
- "context"
- "os"
- "testing"
- "time"
-
- "github.com/apache/camel-k/v2/pkg/util"
- "github.com/apache/camel-k/v2/pkg/util/boolean"
- "github.com/apache/camel-k/v2/pkg/util/camel"
- "github.com/apache/camel-k/v2/pkg/util/kubernetes"
- "github.com/apache/camel-k/v2/pkg/util/maven"
- corev1 "k8s.io/api/core/v1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
-
- "github.com/apache/camel-k/v2/pkg/internal"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-)
-
-func TestRestDslTraitApplicability(t *testing.T) {
- catalog, err := camel.DefaultCatalog()
- require.NoError(t, err)
-
- e := &Environment{
- CamelCatalog: catalog,
- }
-
- trait, _ := newOpenAPITrait().(*openAPITrait)
- enabled, condition, err := trait.Configure(e)
- require.NoError(t, err)
- assert.False(t, enabled)
- assert.Nil(t, condition)
-
- e.Integration = &v1.Integration{
- Status: v1.IntegrationStatus{
- Phase: v1.IntegrationPhaseNone,
- },
- }
- enabled, condition, err = trait.Configure(e)
- require.NoError(t, err)
- assert.False(t, enabled)
- assert.Nil(t, condition)
-
- trait.Configmaps = []string{"my-configmap"}
-
- enabled, condition, err = trait.Configure(e)
- require.NoError(t, err)
- assert.False(t, enabled)
- assert.Nil(t, condition)
-
- e.Integration.Status.Phase = v1.IntegrationPhaseInitialization
- enabled, condition, err = trait.Configure(e)
- require.NoError(t, err)
- assert.True(t, enabled)
- assert.NotNil(t, condition)
- assert.Equal(t, "OpenApi trait is deprecated and may be removed in future version: "+
- "use Camel REST contract first instead, https://camel.apache.org/manual/rest-dsl-openapi.html",
- condition.message,
- )
-}
-
-func TestRestDslTraitApplyError(t *testing.T) {
- catalog, err := camel.DefaultCatalog()
- require.NoError(t, err)
- fakeClient, _ := internal.NewFakeClient()
-
- e := &Environment{
- CamelCatalog: catalog,
- Client: fakeClient,
- }
-
- trait, _ := newOpenAPITrait().(*openAPITrait)
- enabled, condition, err := trait.Configure(e)
- require.NoError(t, err)
- assert.False(t, enabled)
- assert.Nil(t, condition)
-
- e.Integration = &v1.Integration{
- ObjectMeta: metav1.ObjectMeta{
- Name: "hello",
- Namespace: "default",
- },
- Status: v1.IntegrationStatus{
- Phase: v1.IntegrationPhaseInitialization,
- },
- }
-
- trait.Configmaps = []string{"my-configmap"}
-
- err = trait.Apply(e)
- require.Error(t, err)
- assert.Equal(t, "configmap my-configmap does not exist in namespace default", err.Error())
-}
-
-var openapi = `
-openapi: "3.0.0"
-info:
- version: 1.0.0
- title: Swagger Petstore
- license:
- name: MIT
-servers:
- - url: http://petstore.swagger.io/v1
-paths:
- /pets:
- get:
- summary: List all pets
- operationId: listPets
- tags:
- - pets
- parameters:
- - name: limit
- in: query
- description: How many items to return at one time (max 100)
- required: false
- schema:
- type: integer
- format: int32
- responses:
- '200':
- description: A paged array of pets
- headers:
- x-next:
- description: A link to the next page of responses
- schema:
- type: string
- content:
- application/json:
- schema:
- $ref: "#/components/schemas/Pets"
- default:
- description: unexpected error
- content:
- application/json:
- schema:
- $ref: "#/components/schemas/Error"
- post:
- summary: Create a pet
- operationId: createPets
- tags:
- - pets
- responses:
- '201':
- description: Null response
- default:
- description: unexpected error
- content:
- application/json:
- schema:
- $ref: "#/components/schemas/Error"
- /pets/{petId}:
- get:
- summary: Info for a specific pet
- operationId: showPetById
- tags:
- - pets
- parameters:
- - name: petId
- in: path
- required: true
- description: The id of the pet to retrieve
- schema:
- type: string
- responses:
- '200':
- description: Expected response to a valid request
- content:
- application/json:
- schema:
- $ref: "#/components/schemas/Pet"
- default:
- description: unexpected error
- content:
- application/json:
- schema:
- $ref: "#/components/schemas/Error"
-components:
- schemas:
- Pet:
- type: object
- required:
- - id
- - name
- properties:
- id:
- type: integer
- format: int64
- name:
- type: string
- tag:
- type: string
- Pets:
- type: array
- items:
- $ref: "#/components/schemas/Pet"
- Error:
- type: object
- required:
- - code
- - message
- properties:
- code:
- type: integer
- format: int32
- message:
- type: string
-`
-
-func TestRestDslTraitApplyWorks(t *testing.T) {
- settings, err := maven.NewSettings(
- maven.Repositories(
- "https://repository.apache.org/content/groups/snapshots-group@id=apache@snapshots@noreleases",
- ),
- )
- require.NoError(t, err)
- content, err := util.EncodeXML(settings)
- require.NoError(t, err)
- cm := newConfigMap("default", "maven-settings", "settings.xml", "settings.xml", string(content), nil)
- catalog, err := camel.DefaultCatalog()
- require.NoError(t, err)
- fakeClient, _ := internal.NewFakeClient(&corev1.ConfigMap{
- ObjectMeta: metav1.ObjectMeta{
- Name: "my-configmap",
- Namespace: "default",
- },
- Data: map[string]string{
- "pets.yaml": openapi,
- },
- },
- cm,
- )
-
- e := &Environment{
- Ctx: context.Background(),
- CamelCatalog: catalog,
- Client: fakeClient,
- Platform: &v1.IntegrationPlatform{
- ObjectMeta: metav1.ObjectMeta{
- Name: "camel-k",
- Namespace: "default",
- },
- Spec: v1.IntegrationPlatformSpec{
- Cluster: v1.IntegrationPlatformClusterKubernetes,
- },
- Status: v1.IntegrationPlatformStatus{
- IntegrationPlatformSpec: v1.IntegrationPlatformSpec{
- Cluster: v1.IntegrationPlatformClusterKubernetes,
- Build: v1.IntegrationPlatformBuildSpec{
- PublishStrategy: v1.IntegrationPlatformBuildPublishStrategyJib,
- Registry: v1.RegistrySpec{Address: "registry"},
- RuntimeVersion: catalog.Runtime.Version,
- Maven: v1.MavenSpec{
- Settings: v1.ValueSource{
- ConfigMapKeyRef: &corev1.ConfigMapKeySelector{
- LocalObjectReference: corev1.LocalObjectReference{
- Name: cm.Name,
- },
- Key: "settings.xml",
- },
- },
- },
- Timeout: &metav1.Duration{Duration: time.Minute},
- },
- },
- Phase: v1.IntegrationPlatformPhaseReady,
- },
- },
- Resources: kubernetes.NewCollection(),
- }
-
- trait, _ := newOpenAPITrait().(*openAPITrait)
- trait.Client = fakeClient
- enabled, condition, err := trait.Configure(e)
- require.NoError(t, err)
- assert.False(t, enabled)
- assert.Nil(t, condition)
-
- e.Integration = &v1.Integration{
- ObjectMeta: metav1.ObjectMeta{
- Name: "hello",
- Namespace: "default",
- },
- Status: v1.IntegrationStatus{
- Phase: v1.IntegrationPhaseInitialization,
- },
- }
-
- trait.Configmaps = []string{"my-configmap"}
-
- // use local Maven executable in tests
- t.Setenv("MAVEN_WRAPPER", boolean.FalseString)
- _, ok := os.LookupEnv("MAVEN_CMD")
- if !ok {
- t.Setenv("MAVEN_CMD", "mvn")
- }
-
- err = trait.Apply(e)
- require.NoError(t, err)
-
- assert.Equal(t, 1, e.Resources.Size())
- sourceCm := e.Resources.GetConfigMap(func(cm *corev1.ConfigMap) bool {
- return cm.Name == "hello-openapi-000"
- })
- assert.NotNil(t, sourceCm)
- assert.Contains(t, sourceCm.Data["content"], "get id=\"showPetById\" path=\"/pets/{petId}\"")
-}
-
-// newConfigMap will create a ConfigMap.
-func newConfigMap(namespace, cmName, originalFilename string, generatedKey string,
- textData string, binaryData []byte) *corev1.ConfigMap {
- immutable := true
- cm := corev1.ConfigMap{
- TypeMeta: metav1.TypeMeta{
- Kind: "ConfigMap",
- APIVersion: "v1",
- },
- ObjectMeta: metav1.ObjectMeta{
- Name: cmName,
- Namespace: namespace,
- Labels: map[string]string{
- kubernetes.ConfigMapOriginalFileNameLabel: originalFilename,
- kubernetes.ConfigMapAutogenLabel: "true",
- },
- },
- Immutable: &immutable,
- }
- if textData != "" {
- cm.Data = map[string]string{
- generatedKey: textData,
- }
- }
- if binaryData != nil {
- cm.BinaryData = map[string][]byte{
- generatedKey: binaryData,
- }
- }
- return &cm
-}
diff --git a/pkg/trait/quarkus_test.go b/pkg/trait/quarkus_test.go
index 7852f5ac2..a12440286 100644
--- a/pkg/trait/quarkus_test.go
+++ b/pkg/trait/quarkus_test.go
@@ -59,7 +59,7 @@ func TestConfigureQuarkusTraitBuildSubmitted(t *testing.T) {
func TestConfigureQuarkusTraitNativeNotSupported(t *testing.T) {
quarkusTrait, environment := createNominalQuarkusTest()
// Set a source not supporting Quarkus native
- environment.Integration.Spec.Sources[0].Language = v1.LanguageJavaScript
+ environment.Integration.Spec.Sources[0].Language = v1.Language("js")
environment.Integration.Status.Phase = v1.IntegrationPhaseBuildingKit
quarkusTrait.Modes = []traitv1.QuarkusMode{traitv1.NativeQuarkusMode}
@@ -148,10 +148,6 @@ func TestGetLanguageSettingsWithoutLoaders(t *testing.T) {
},
}
assert.Equal(t, languageSettings{native: false, sourcesRequiredAtBuildTime: false}, getLanguageSettings(environment, v1.LanguageJavaSource))
- assert.Equal(t, languageSettings{native: false, sourcesRequiredAtBuildTime: false}, getLanguageSettings(environment, v1.LanguageGroovy))
- assert.Equal(t, languageSettings{native: false, sourcesRequiredAtBuildTime: false}, getLanguageSettings(environment, v1.LanguageJavaScript))
- assert.Equal(t, languageSettings{native: false, sourcesRequiredAtBuildTime: false}, getLanguageSettings(environment, v1.LanguageKotlin))
- assert.Equal(t, languageSettings{native: false, sourcesRequiredAtBuildTime: false}, getLanguageSettings(environment, v1.LanguageJavaShell))
assert.Equal(t, languageSettings{native: true, sourcesRequiredAtBuildTime: false}, getLanguageSettings(environment, v1.LanguageKamelet))
assert.Equal(t, languageSettings{native: true, sourcesRequiredAtBuildTime: false}, getLanguageSettings(environment, v1.LanguageXML))
assert.Equal(t, languageSettings{native: true, sourcesRequiredAtBuildTime: false}, getLanguageSettings(environment, v1.LanguageYaml))
@@ -163,10 +159,6 @@ func TestGetLanguageSettingsWithoutMetadata(t *testing.T) {
CamelCatalogSpec: v1.CamelCatalogSpec{
Loaders: map[string]v1.CamelLoader{
"java": {},
- "groovy": {},
- "js": {},
- "kts": {},
- "jsh": {},
"kamelet": {},
"xml": {},
"yaml": {},
@@ -175,10 +167,6 @@ func TestGetLanguageSettingsWithoutMetadata(t *testing.T) {
},
}
assert.Equal(t, languageSettings{native: false, sourcesRequiredAtBuildTime: false}, getLanguageSettings(environment, v1.LanguageJavaSource))
- assert.Equal(t, languageSettings{native: false, sourcesRequiredAtBuildTime: false}, getLanguageSettings(environment, v1.LanguageGroovy))
- assert.Equal(t, languageSettings{native: false, sourcesRequiredAtBuildTime: false}, getLanguageSettings(environment, v1.LanguageJavaScript))
- assert.Equal(t, languageSettings{native: false, sourcesRequiredAtBuildTime: false}, getLanguageSettings(environment, v1.LanguageKotlin))
- assert.Equal(t, languageSettings{native: false, sourcesRequiredAtBuildTime: false}, getLanguageSettings(environment, v1.LanguageJavaShell))
assert.Equal(t, languageSettings{native: true, sourcesRequiredAtBuildTime: false}, getLanguageSettings(environment, v1.LanguageKamelet))
assert.Equal(t, languageSettings{native: true, sourcesRequiredAtBuildTime: false}, getLanguageSettings(environment, v1.LanguageXML))
assert.Equal(t, languageSettings{native: true, sourcesRequiredAtBuildTime: false}, getLanguageSettings(environment, v1.LanguageYaml))
@@ -195,38 +183,11 @@ func TestGetLanguageSettingsWithLoaders(t *testing.T) {
"sources-required-at-build-time": boolean.TrueString,
},
},
- "groovy": {
- Metadata: map[string]string{
- "native": boolean.FalseString,
- "sources-required-at-build-time": boolean.FalseString,
- },
- },
- "js": {
- Metadata: map[string]string{
- "native": boolean.TrueString,
- "sources-required-at-build-time": boolean.FalseString,
- },
- },
- "kts": {
- Metadata: map[string]string{
- "native": boolean.FalseString,
- "sources-required-at-build-time": boolean.TrueString,
- },
- },
- "jsh": {
- Metadata: map[string]string{
- "native": boolean.TrueString,
- },
- },
},
},
},
}
assert.Equal(t, languageSettings{native: true, sourcesRequiredAtBuildTime: true}, getLanguageSettings(environment, v1.LanguageJavaSource))
- assert.Equal(t, languageSettings{native: false, sourcesRequiredAtBuildTime: false}, getLanguageSettings(environment, v1.LanguageGroovy))
- assert.Equal(t, languageSettings{native: true, sourcesRequiredAtBuildTime: false}, getLanguageSettings(environment, v1.LanguageJavaScript))
- assert.Equal(t, languageSettings{native: false, sourcesRequiredAtBuildTime: true}, getLanguageSettings(environment, v1.LanguageKotlin))
- assert.Equal(t, languageSettings{native: true, sourcesRequiredAtBuildTime: false}, getLanguageSettings(environment, v1.LanguageJavaShell))
}
func TestQuarkusMatches(t *testing.T) {
diff --git a/pkg/trait/service_test.go b/pkg/trait/service_test.go
index e21930b9e..18d5048e7 100644
--- a/pkg/trait/service_test.go
+++ b/pkg/trait/service_test.go
@@ -49,7 +49,7 @@ func TestServiceWithDefaults(t *testing.T) {
client, _ := internal.NewFakeClient()
traitCatalog := NewCatalog(nil)
- compressedRoute, err := gzip.CompressBase64([]byte(`from("netty-http:test").log("hello")`))
+ compressedRoute, err := gzip.CompressBase64([]byte(`from("netty-http:test").log("hello");`))
require.NoError(t, err)
environment := Environment{
@@ -69,11 +69,11 @@ func TestServiceWithDefaults(t *testing.T) {
Sources: []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "routes.js",
+ Name: "routes.java",
Content: string(compressedRoute),
Compression: true,
},
- Language: v1.LanguageJavaScript,
+ Language: v1.LanguageJavaSource,
},
},
Traits: v1.Traits{
@@ -168,11 +168,11 @@ func TestService(t *testing.T) {
Sources: []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "routes.js",
+ Name: "routes.java",
Content: string(compressedRoute),
Compression: true,
},
- Language: v1.LanguageJavaScript,
+ Language: v1.LanguageJavaSource,
},
},
Traits: v1.Traits{
@@ -353,11 +353,11 @@ func TestServiceWithNodePort(t *testing.T) {
Sources: []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "routes.js",
+ Name: "routes.java",
Content: string(compressedRoute),
Compression: true,
},
- Language: v1.LanguageJavaScript,
+ Language: v1.LanguageJavaSource,
},
},
Traits: v1.Traits{
@@ -449,11 +449,11 @@ func TestServiceWithKnativeServiceEnabled(t *testing.T) {
Sources: []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "routes.js",
+ Name: "routes.java",
Content: string(compressedRoute),
Compression: true,
},
- Language: v1.LanguageJavaScript,
+ Language: v1.LanguageJavaSource,
},
},
Traits: v1.Traits{
@@ -543,11 +543,11 @@ func TestServicesWithKnativeProfile(t *testing.T) {
Sources: []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "routes.js",
+ Name: "routes.java",
Content: string(compressedRoute),
Compression: true,
},
- Language: v1.LanguageJavaScript,
+ Language: v1.LanguageJavaSource,
},
},
},
@@ -625,11 +625,11 @@ func TestServiceWithKnativeServiceDisabledInIntegrationPlatform(t *testing.T) {
Sources: []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "routes.js",
+ Name: "routes.java",
Content: string(compressedRoute),
Compression: true,
},
- Language: v1.LanguageJavaScript,
+ Language: v1.LanguageJavaSource,
},
},
},
@@ -704,11 +704,11 @@ func TestServiceAutoConfiguration(t *testing.T) {
Sources: []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "routes.js",
+ Name: "routes.java",
Content: string(compressedRoute),
Compression: true,
},
- Language: v1.LanguageJavaScript,
+ Language: v1.LanguageJavaSource,
},
},
},
@@ -769,11 +769,11 @@ func TestServiceAnnotationsAndLables(t *testing.T) {
Sources: []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "routes.js",
+ Name: "routes.java",
Content: string(compressedRoute),
Compression: true,
},
- Language: v1.LanguageJavaScript,
+ Language: v1.LanguageJavaSource,
},
},
Traits: v1.Traits{
@@ -860,11 +860,11 @@ func TestServicePorts(t *testing.T) {
Sources: []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "routes.js",
+ Name: "routes.java",
Content: string(compressedRoute),
Compression: true,
},
- Language: v1.LanguageJavaScript,
+ Language: v1.LanguageJavaSource,
},
},
Traits: v1.Traits{
diff --git a/pkg/trait/trait_register.go b/pkg/trait/trait_register.go
index e268a6e4c..e253cdf93 100644
--- a/pkg/trait/trait_register.go
+++ b/pkg/trait/trait_register.go
@@ -44,7 +44,6 @@ func init() {
AddToTraits(newLoggingTraitTrait)
AddToTraits(NewMasterTrait)
AddToTraits(newMountTrait)
- AddToTraits(newOpenAPITrait)
AddToTraits(newOwnerTrait)
AddToTraits(newPdbTrait)
AddToTraits(newPlatformTrait)
diff --git a/pkg/trait/trait_test.go b/pkg/trait/trait_test.go
index 13c92a304..b8c1770d4 100644
--- a/pkg/trait/trait_test.go
+++ b/pkg/trait/trait_test.go
@@ -47,7 +47,7 @@ const (
)
func TestOpenShiftTraits(t *testing.T) {
- env := createTestEnv(t, v1.IntegrationPlatformClusterOpenShift, "from('timer:my-timer').to('log:info')")
+ env := createTestEnv(t, v1.IntegrationPlatformClusterOpenShift, `from("timer:my-timer").to("log:info");`)
res := processTestEnv(t, env)
assert.NotEmpty(t, env.ExecutedTraits)
@@ -61,7 +61,7 @@ func TestOpenShiftTraits(t *testing.T) {
}
func TestOpenShiftTraitsWithWeb(t *testing.T) {
- env := createTestEnv(t, v1.IntegrationPlatformClusterOpenShift, "from('netty-http:http').to('log:info')")
+ env := createTestEnv(t, v1.IntegrationPlatformClusterOpenShift, `from("netty-http:http").to("log:info");`)
res := processTestEnv(t, env)
assert.NotNil(t, env.GetTrait("deployment"))
assert.NotNil(t, env.GetTrait("service"))
@@ -79,7 +79,7 @@ func TestOpenShiftTraitsWithWeb(t *testing.T) {
}
func TestOpenShiftTraitsWithWebAndConfig(t *testing.T) {
- env := createTestEnv(t, v1.IntegrationPlatformClusterOpenShift, "from('netty-http:http').to('log:info')")
+ env := createTestEnv(t, v1.IntegrationPlatformClusterOpenShift, `from("netty-http:http").to("log:info");`)
res := processTestEnv(t, env)
assert.NotNil(t, env.GetTrait("service"))
assert.NotNil(t, env.GetTrait("route"))
@@ -89,7 +89,7 @@ func TestOpenShiftTraitsWithWebAndConfig(t *testing.T) {
}
func TestOpenShiftTraitsWithWebAndDisabledTrait(t *testing.T) {
- env := createTestEnv(t, v1.IntegrationPlatformClusterOpenShift, "from('netty-http:http').to('log:info')")
+ env := createTestEnv(t, v1.IntegrationPlatformClusterOpenShift, `from("netty-http:http").to("log:info");`)
env.Integration.Spec.Traits.Service = &traitv1.ServiceTrait{
Trait: traitv1.Trait{
Enabled: ptr.To(false),
@@ -104,7 +104,7 @@ func TestOpenShiftTraitsWithWebAndDisabledTrait(t *testing.T) {
}
func TestKubernetesTraits(t *testing.T) {
- env := createTestEnv(t, v1.IntegrationPlatformClusterKubernetes, "from('timer:tick').to('log:info')")
+ env := createTestEnv(t, v1.IntegrationPlatformClusterKubernetes, `from("timer:tick").to("log:info");`)
res := processTestEnv(t, env)
assert.NotNil(t, env.GetTrait("deployment"))
assert.Nil(t, env.GetTrait("service"))
@@ -116,7 +116,7 @@ func TestKubernetesTraits(t *testing.T) {
}
func TestKubernetesTraitsWithWeb(t *testing.T) {
- env := createTestEnv(t, v1.IntegrationPlatformClusterKubernetes, "from('servlet:http').to('log:info')")
+ env := createTestEnv(t, v1.IntegrationPlatformClusterKubernetes, `from("servlet:http").to("log:info");`)
res := processTestEnv(t, env)
assert.NotNil(t, env.GetTrait("deployment"))
assert.NotNil(t, env.GetTrait("service"))
@@ -269,10 +269,10 @@ func createTestEnv(t *testing.T, cluster v1.IntegrationPlatformCluster, script s
Sources: []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "file.groovy",
+ Name: "file.java",
Content: script,
},
- Language: v1.LanguageGroovy,
+ Language: v1.LanguageJavaSource,
},
},
},
@@ -334,10 +334,10 @@ func testDefaultIntegrationPhaseTraitsSetting(t *testing.T, phase v1.Integration
Sources: []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "file.groovy",
- Content: "from('timer:test').to('log:info')",
+ Name: "file.java",
+ Content: `from("timer:test").to("log:info")`,
},
- Language: v1.LanguageGroovy,
+ Language: v1.LanguageJavaSource,
},
},
},
@@ -425,10 +425,10 @@ func TestIntegrationTraitsSetting(t *testing.T) {
Sources: []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "file.groovy",
- Content: "from('timer:test').to('log:info')",
+ Name: "file.java",
+ Content: `from("timer:test").to("log:info")`,
},
- Language: v1.LanguageGroovy,
+ Language: v1.LanguageJavaSource,
},
},
Traits: v1.Traits{
diff --git a/pkg/trait/trait_types_test.go b/pkg/trait/trait_types_test.go
index 7d3acdc45..e8a533ca5 100644
--- a/pkg/trait/trait_types_test.go
+++ b/pkg/trait/trait_types_test.go
@@ -219,10 +219,10 @@ func createTestEnvironment(t *testing.T, profile v1.TraitProfile) *Environment {
Sources: []v1.SourceSpec{
{
DataSpec: v1.DataSpec{
- Name: "routes.js",
- Content: `from("direct:test").log("hello")`,
+ Name: "routes.java",
+ Content: `from("direct:test").log("hello");`,
},
- Language: v1.LanguageJavaScript,
+ Language: v1.LanguageJavaSource,
},
{
DataSpec: v1.DataSpec{
diff --git a/pkg/util/camel/camel_runtime_catalog_test.go b/pkg/util/camel/camel_runtime_catalog_test.go
index fef51fd0d..7f25a072f 100644
--- a/pkg/util/camel/camel_runtime_catalog_test.go
+++ b/pkg/util/camel/camel_runtime_catalog_test.go
@@ -27,10 +27,7 @@ import (
func TestLoaderByArtifact(t *testing.T) {
catalog, err := DefaultCatalog()
require.NoError(t, err)
- assert.Equal(t, "groovy", catalog.loaderByArtifact["camel-quarkus-groovy-dsl"])
assert.Equal(t, "java", catalog.loaderByArtifact["camel-quarkus-java-joor-dsl"])
- assert.Equal(t, "js", catalog.loaderByArtifact["camel-quarkus-js-dsl"])
- assert.Equal(t, "kts", catalog.loaderByArtifact["camel-quarkus-kotlin-dsl"])
assert.Equal(t, "xml", catalog.loaderByArtifact["camel-quarkus-xml-io-dsl"])
assert.Equal(t, "yaml", catalog.loaderByArtifact["camel-quarkus-yaml-dsl"])
}
@@ -38,10 +35,7 @@ func TestLoaderByArtifact(t *testing.T) {
func TestHasLoaderByArtifact(t *testing.T) {
catalog, err := DefaultCatalog()
require.NoError(t, err)
- assert.True(t, catalog.HasLoaderByArtifact("groovy-dsl"))
assert.True(t, catalog.HasLoaderByArtifact("java-joor-dsl"))
- assert.True(t, catalog.HasLoaderByArtifact("js-dsl"))
- assert.True(t, catalog.HasLoaderByArtifact("kotlin-dsl"))
assert.True(t, catalog.HasLoaderByArtifact("xml-io-dsl"))
assert.True(t, catalog.HasLoaderByArtifact("yaml-dsl"))
assert.False(t, catalog.HasLoaderByArtifact("python-dsl"))
diff --git a/pkg/util/digest/digest.go b/pkg/util/digest/digest.go
index 3f91f95fb..c2319e766 100644
--- a/pkg/util/digest/digest.go
+++ b/pkg/util/digest/digest.go
@@ -267,35 +267,6 @@ func ComputeForIntegrationKit(kit *v1.IntegrationKit) (string, error) {
return digest, nil
}
-// ComputeForResource returns a digest for the specific resource.
-func ComputeForResource(res v1.DataSpec) (string, error) {
- hash := sha256.New()
- // Operator version is relevant
- if _, err := hash.Write([]byte(defaults.Version)); err != nil {
- return "", err
- }
-
- if _, err := hash.Write([]byte(res.Content)); err != nil {
- return "", err
- }
- if _, err := hash.Write([]byte(res.Name)); err != nil {
- return "", err
- }
- if _, err := hash.Write([]byte(res.ContentKey)); err != nil {
- return "", err
- }
- if _, err := hash.Write([]byte(res.ContentRef)); err != nil {
- return "", err
- }
- if _, err := hash.Write([]byte(strconv.FormatBool(res.Compression))); err != nil {
- return "", err
- }
-
- // Add a letter at the beginning and use URL safe encoding
- digest := "v" + base64.RawURLEncoding.EncodeToString(hash.Sum(nil))
- return digest, nil
-}
-
// ComputeForSource returns a digest for the specific source.
func ComputeForSource(s v1.SourceSpec) (string, error) {
hash := sha256.New()
diff --git a/pkg/util/indentedwriter/writer.go b/pkg/util/indentedwriter/writer.go
deleted file mode 100644
index c8419dde1..000000000
--- a/pkg/util/indentedwriter/writer.go
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
-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 indentedwriter
-
-import (
- "bytes"
- "fmt"
- "io"
- "strings"
- "text/tabwriter"
-)
-
-// Flusher --.
-type Flusher interface {
- Flush()
-}
-
-// Writer --.
-type Writer struct {
- out io.Writer
-}
-
-// NewWriter --.
-func NewWriter(out io.Writer) *Writer {
- return &Writer{out: out}
-}
-
-// Writef --.
-func (iw *Writer) Writef(indentLevel int, format string, i ...interface{}) {
- fmt.Fprint(iw.out, strings.Repeat(" ", indentLevel))
- fmt.Fprintf(iw.out, format, i...)
-}
-
-// IndentedString --.
-func IndentedString(f func(io.Writer) error) (string, error) {
- var out tabwriter.Writer
- buf := &bytes.Buffer{}
- out.Init(buf, 0, 8, 2, ' ', 0)
-
- err := f(&out)
- if err != nil {
- return "", err
- }
-
- err = out.Flush()
- if err != nil {
- return "", err
- }
-
- return buf.String(), nil
-}
diff --git a/pkg/util/kubernetes/sanitize_test.go b/pkg/util/kubernetes/sanitize_test.go
index 93bcac937..79b608f04 100644
--- a/pkg/util/kubernetes/sanitize_test.go
+++ b/pkg/util/kubernetes/sanitize_test.go
@@ -28,7 +28,7 @@ func TestSanitizeName(t *testing.T) {
{"input": "/path/to/abc.js", "expect": "abc"},
{"input": "abc.xml", "expect": "abc"},
{"input": "./path/to/abc.kts", "expect": "abc"},
- {"input": "fooToBar.groovy", "expect": "foo-to-bar"},
+ {"input": "fooToBar.java", "expect": "foo-to-bar"},
{"input": "foo-to-bar", "expect": "foo-to-bar"},
{"input": "http://foo.bar.com/cheese/wine/beer/abc.java", "expect": "abc"},
{"input": "http://foo.bar.com/cheese", "expect": "cheese"},
diff --git a/pkg/util/modeline/parser_test.go b/pkg/util/modeline/parser_test.go
index 557cc9edd..a3513fa42 100644
--- a/pkg/util/modeline/parser_test.go
+++ b/pkg/util/modeline/parser_test.go
@@ -24,38 +24,6 @@ import (
"github.com/stretchr/testify/require"
)
-func TestParseGroovyFile(t *testing.T) {
- it := `
- // camel-k: pippo=pluto paperino ciao=1
- // camel-k : ciao
-
- from("timer:tick").log("Ciao")
- `
- opts, err := Parse("simple.groovy", it)
- require.NoError(t, err)
- assert.Len(t, opts, 4)
- assert.Contains(t, opts, Option{Name: "pippo", Value: "pluto"})
- assert.Contains(t, opts, Option{Name: "paperino"})
- assert.Contains(t, opts, Option{Name: "ciao", Value: "1"})
- assert.Contains(t, opts, Option{Name: "ciao"})
-}
-
-func TestParseKotlinFile(t *testing.T) {
- it := `
- // camel-k: pippo=pluto paperino ciao=1
- // camel-k : ciao
-
- from("timer:tick").log("Ciao")
- `
- opts, err := Parse("example.kts", it)
- require.NoError(t, err)
- assert.Len(t, opts, 4)
- assert.Contains(t, opts, Option{Name: "pippo", Value: "pluto"})
- assert.Contains(t, opts, Option{Name: "paperino"})
- assert.Contains(t, opts, Option{Name: "ciao", Value: "1"})
- assert.Contains(t, opts, Option{Name: "ciao"})
-}
-
func TestParseJavaFile(t *testing.T) {
it := `
// camel-k: pippo=pluto paperino ciao=1
@@ -86,26 +54,6 @@ func TestParseJavaFile(t *testing.T) {
assert.Contains(t, opts, Option{Name: "ciao"})
}
-func TestParseJSFile(t *testing.T) {
- it := `
- // camel-k: pippo=pluto paperino ciao=1
- // camel-k : ciao
- // Write your routes here, for example:
- from('timer:js?period=1000')
- .routeId('js')
- .setBody()
- .simple('Hello Camel K from ${routeId}')
- .to('log:info')
- `
- opts, err := Parse("example.js", it)
- require.NoError(t, err)
- assert.Len(t, opts, 4)
- assert.Contains(t, opts, Option{Name: "pippo", Value: "pluto"})
- assert.Contains(t, opts, Option{Name: "paperino"})
- assert.Contains(t, opts, Option{Name: "ciao", Value: "1"})
- assert.Contains(t, opts, Option{Name: "ciao"})
-}
-
func TestParseYAMLFile(t *testing.T) {
it := `
# camel-k: pippo=pluto paperino ciao=1
diff --git a/pkg/util/source/inspector.go b/pkg/util/source/inspector.go
index f73d7cb25..0d1cbe979 100644
--- a/pkg/util/source/inspector.go
+++ b/pkg/util/source/inspector.go
@@ -35,14 +35,8 @@ const (
)
var (
- singleQuotedFrom = regexp.MustCompile(`from\s*\(\s*'([a-zA-Z0-9-]+:[^']+)'`)
- singleQuotedFromF = regexp.MustCompile(`fromF\s*\(\s*'([a-zA-Z0-9-]+:[^']+)'`)
doubleQuotedFrom = regexp.MustCompile(`from\s*\(\s*"([a-zA-Z0-9-]+:[^"]+)"`)
doubleQuotedFromF = regexp.MustCompile(`fromF\s*\(\s*"([a-zA-Z0-9-]+:[^"]+)"`)
- singleQuotedTo = regexp.MustCompile(`\.to\s*\(\s*'([a-zA-Z0-9-]+:[^']+)'`)
- singleQuotedToD = regexp.MustCompile(`\.toD\s*\(\s*'([a-zA-Z0-9-]+:[^']+)'`)
- singleQuotedToF = regexp.MustCompile(`\.toF\s*\(\s*'([a-zA-Z0-9-]+:[^']+)'`)
- singleQuotedWireTap = regexp.MustCompile(`\.wireTap\s*\(\s*'([a-zA-Z0-9-]+:[^']+)'`)
doubleQuotedTo = regexp.MustCompile(`\.to\s*\(\s*"([a-zA-Z0-9-]+:[^"]+)"`)
doubleQuotedToD = regexp.MustCompile(`\.toD\s*\(\s*"([a-zA-Z0-9-]+:[^"]+)"`)
doubleQuotedToF = regexp.MustCompile(`\.toF\s*\(\s*"([a-zA-Z0-9-]+:[^"]+)"`)
@@ -65,7 +59,6 @@ var (
xqueryRegexp = regexp.MustCompile(`.*\.xquery\s*\(.*\).*`)
xpathRegexp = regexp.MustCompile(`.*\.?xpath\s*\(.*\).*`)
xtokenizeRegexp = regexp.MustCompile(`.*\.xtokenize\s*\(.*\).*`)
- singleQuotedKameletEip = regexp.MustCompile(`kamelet\s*\(\s*'(?://)?([a-z0-9-.]+(/[a-z0-9-.]+)?)(?:$|[^a-z0-9-.].*)'`)
doubleQuotedKameletEip = regexp.MustCompile(`kamelet\s*\(\s*"(?://)?([a-z0-9-.]+(/[a-z0-9-.]+)?)(?:$|[^a-z0-9-.].*)"`)
sourceCapabilities = map[*regexp.Regexp][]string{
@@ -203,36 +196,12 @@ func InspectorForLanguage(catalog *camel.RuntimeCatalog, language v1.Language) I
catalog: catalog,
},
}
- case v1.LanguageGroovy:
- return &GroovyInspector{
- baseInspector: baseInspector{
- catalog: catalog,
- },
- }
- case v1.LanguageJavaScript:
- return &JavaScriptInspector{
- baseInspector: baseInspector{
- catalog: catalog,
- },
- }
- case v1.LanguageKotlin:
- return &KotlinInspector{
- baseInspector: baseInspector{
- catalog: catalog,
- },
- }
case v1.LanguageYaml:
return &YAMLInspector{
baseInspector: baseInspector{
catalog: catalog,
},
}
- case v1.LanguageJavaShell:
- return &JavaSourceInspector{
- baseInspector: baseInspector{
- catalog: catalog,
- },
- }
}
return &baseInspector{}
}
diff --git a/pkg/util/source/inspector_groovy.go b/pkg/util/source/inspector_groovy.go
deleted file mode 100644
index bd85c53a4..000000000
--- a/pkg/util/source/inspector_groovy.go
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
-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 source
-
-import (
- "fmt"
- "regexp"
-
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- "github.com/apache/camel-k/v2/pkg/util"
-)
-
-var (
- replaceURISingleQuotedFrom = regexp.MustCompile(`from\s*\(\s*'(?:timer|cron|quartz)[^']*'\s*\)`)
- replaceURISingleQuotedFromF = regexp.MustCompile(`fromF\s*\(\s*'(?:timer|cron|quartz)[^']*'\s*\)`)
- replaceURIDoubleQuotedFrom = regexp.MustCompile(`from\s*\(\s*"(?:timer|cron|quartz)[^"]*"\s*\)`)
- replaceURIDoubleQuotedFromF = regexp.MustCompile(`fromF\s*\(\s*"(?:timer|cron|quartz)[^"]*"\s*\)`)
-)
-
-// GroovyInspector inspects Groovy DSL spec.
-type GroovyInspector struct {
- baseInspector
-}
-
-// Extract extracts all metadata from source spec.
-func (i GroovyInspector) Extract(source v1.SourceSpec, meta *Metadata) error {
- from := util.FindAllDistinctStringSubmatch(
- source.Content,
- singleQuotedFrom,
- doubleQuotedFrom,
- singleQuotedFromF,
- doubleQuotedFromF,
- )
- to := util.FindAllDistinctStringSubmatch(
- source.Content,
- singleQuotedTo,
- doubleQuotedTo,
- singleQuotedToD,
- doubleQuotedToD,
- singleQuotedToF,
- doubleQuotedToF,
- singleQuotedWireTap,
- doubleQuotedWireTap,
- )
- kameletEips := util.FindAllDistinctStringSubmatch(
- source.Content,
- singleQuotedKameletEip,
- doubleQuotedKameletEip)
-
- hasRest := restRegexp.MatchString(source.Content) || restClosureRegexp.MatchString(source.Content)
-
- return i.extract(source, meta, from, to, kameletEips, hasRest)
-}
-
-// ReplaceFromURI parses the source content and replace the `from` URI configuration with the a new URI. Returns true if it applies a replacement.
-func (i GroovyInspector) ReplaceFromURI(source *v1.SourceSpec, newFromURI string) (bool, error) {
- return replaceFromURI(source, newFromURI)
-}
-
-func replaceFromURI(source *v1.SourceSpec, newFromURI string) (bool, error) {
- originalContent := source.Content
-
- source.Content = replaceURISingleQuotedFrom.ReplaceAllString(source.Content, fmt.Sprintf("from('%s')", newFromURI))
- source.Content = replaceURISingleQuotedFromF.ReplaceAllString(source.Content, fmt.Sprintf("fromF('%s')", newFromURI))
- source.Content = replaceURIDoubleQuotedFrom.ReplaceAllString(source.Content, fmt.Sprintf(`from("%s")`, newFromURI))
- source.Content = replaceURIDoubleQuotedFromF.ReplaceAllString(source.Content, fmt.Sprintf(`fromF('%s')`, newFromURI))
-
- return originalContent != source.Content, nil
-}
-
-func replaceFromURIDoubleQuotesOnly(source *v1.SourceSpec, newFromURI string) (bool, error) {
- originalContent := source.Content
-
- source.Content = replaceURIDoubleQuotedFrom.ReplaceAllString(source.Content, fmt.Sprintf(`from("%s")`, newFromURI))
- source.Content = replaceURIDoubleQuotedFromF.ReplaceAllString(source.Content, fmt.Sprintf(`fromF('%s')`, newFromURI))
-
- return originalContent != source.Content, nil
-}
diff --git a/pkg/util/source/inspector_groovy_test.go b/pkg/util/source/inspector_groovy_test.go
deleted file mode 100644
index f595936fc..000000000
--- a/pkg/util/source/inspector_groovy_test.go
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
-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 source
-
-import (
- "fmt"
- "testing"
-
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- "github.com/apache/camel-k/v2/pkg/util/camel"
-)
-
-func newTestGroovyInspector(t *testing.T) GroovyInspector {
- t.Helper()
-
- catalog, err := camel.DefaultCatalog()
- require.NoError(t, err)
-
- return GroovyInspector{
- baseInspector: baseInspector{
- catalog: catalog,
- },
- }
-}
-
-const groovyKameletEip = `
-from("direct:start")
- .kamelet("foo/bar?baz=test")
-`
-
-const groovyKameletEipSingleQuote = `
-from("direct:start")
- .kamelet('foo/bar?baz=test')
-`
-
-const groovyKameletEndpoint = `
-from("direct:start")
- .to("kamelet:foo/bar?baz=test")
-`
-
-const groovyKameletEndpointSingleQuote = `
-from("direct:start")
- .to('kamelet:foo/bar?baz=test')
-`
-
-const groovyWireTapEipSingleQuote = `
-from("direct:start")
- .wireTap('kamelet:foo/bar?baz=test')
-`
-
-func TestGroovyKamelet(t *testing.T) {
- tc := []struct {
- source string
- kamelets []string
- }{
- {
- source: groovyKameletEip,
- kamelets: []string{"foo/bar"},
- },
- {
- source: groovyKameletEndpoint,
- kamelets: []string{"foo/bar"},
- },
- {
- source: groovyKameletEipSingleQuote,
- kamelets: []string{"foo/bar"},
- },
- {
- source: groovyKameletEndpointSingleQuote,
- kamelets: []string{"foo/bar"},
- },
- {
- source: groovyWireTapEipSingleQuote,
- kamelets: []string{"foo/bar"},
- },
- }
-
- inspector := newTestGroovyInspector(t)
- for i := range tc {
- test := tc[i]
- t.Run(fmt.Sprintf("TestGroovyKamelet-%d", i), func(t *testing.T) {
- assertExtract(t, inspector, test.source, func(meta *Metadata) {
- assert.True(t, meta.RequiredCapabilities.IsEmpty())
- for _, k := range test.kamelets {
- assert.Contains(t, meta.Kamelets, k)
- }
- })
- })
- }
-}
-
-const groovyJSONEip = `
-from("direct:start")
- .unmarshal().json()
-`
-
-const groovyJSONJacksonEip = `
-from("direct:start")
- .unmarshal().json(JsonLibrary.Jackson)
-`
-
-const groovyAvroEndpoint = `
-from("direct:start")
- .to("dataformat:avro:marshal")
-`
-
-const groovyJacksonEndpoint = `
-from("direct:start")
- .to("dataformat:jackson:marshal")
-`
-
-const groovyProtobufEndpoint = `
-from("direct:start")
- .to("dataformat:protobuf:marshal")
-`
-
-func TestGroovyDataFormat(t *testing.T) {
- tc := []struct {
- source string
- deps []string
- }{
- {
- source: groovyJSONEip,
- deps: []string{"camel:jackson"},
- },
- {
- source: groovyJSONJacksonEip,
- deps: []string{"camel:jackson"},
- },
- {
- source: groovyAvroEndpoint,
- deps: []string{"camel:dataformat", "camel:avro"},
- },
- {
- source: groovyJacksonEndpoint,
- deps: []string{"camel:dataformat", "camel:jackson"},
- },
- {
- source: groovyProtobufEndpoint,
- deps: []string{"camel:dataformat", "camel:protobuf"},
- },
- }
-
- inspector := newTestGroovyInspector(t)
- for i := range tc {
- test := tc[i]
- t.Run(fmt.Sprintf("TestGroovyDataFormat-%d", i), func(t *testing.T) {
- assertExtract(t, inspector, test.source, func(meta *Metadata) {
- for _, d := range test.deps {
- assert.Contains(t, meta.Dependencies.List(), d)
- }
- })
- })
- }
-}
-
-func TestGroovyReplaceURI(t *testing.T) {
- inspector := newTestGroovyInspector(t)
-
- sourceSpec := &v1.SourceSpec{
- DataSpec: v1.DataSpec{
- Name: "test.groovy",
- Content: "from('quartz:trigger?cron=0 0/1 * * * ?').to('log:info')",
- },
- }
- replaced, err := inspector.ReplaceFromURI(
- sourceSpec,
- "direct:newURI?hello=world",
- )
- assert.Nil(t, err)
- assert.True(t, replaced)
- assert.Equal(t, "from('direct:newURI?hello=world').to('log:info')", sourceSpec.Content)
-
- sourceSpec = &v1.SourceSpec{
- DataSpec: v1.DataSpec{
- Name: "test.groovy",
- Content: "from(\"quartz:trigger?cron=0 0/1 * * * ?\").to(\"log:info\")",
- },
- }
- replaced, err = inspector.ReplaceFromURI(
- sourceSpec,
- "direct:newURI?hello=world",
- )
- assert.True(t, replaced)
- assert.Nil(t, err)
- assert.Equal(t, "from(\"direct:newURI?hello=world\").to(\"log:info\")", sourceSpec.Content)
-}
-
-func TestGroovyMultiReplaceURI(t *testing.T) {
- inspector := newTestGroovyInspector(t)
-
- sourceSpec := &v1.SourceSpec{
- DataSpec: v1.DataSpec{
- Name: "test.groovy",
- Content: "from('quartz:trigger?cron=0 0/1 * * * ?').to('direct:d1');from('direct:d1').to('log:info')",
- },
- }
- replaced, err := inspector.ReplaceFromURI(
- sourceSpec,
- "direct:newURI?hello=world",
- )
- assert.Nil(t, err)
- assert.True(t, replaced)
- assert.Equal(t, "from('direct:newURI?hello=world').to('direct:d1');from('direct:d1').to('log:info')", sourceSpec.Content)
-}
diff --git a/pkg/util/source/inspector_java_script.go b/pkg/util/source/inspector_java_script.go
deleted file mode 100644
index cef88834f..000000000
--- a/pkg/util/source/inspector_java_script.go
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-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 source
-
-import (
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- "github.com/apache/camel-k/v2/pkg/util"
-)
-
-// JavaScriptInspector inspects Javascript DSL spec.
-type JavaScriptInspector struct {
- baseInspector
-}
-
-// Extract extracts all metadata from source spec.
-func (i JavaScriptInspector) Extract(source v1.SourceSpec, meta *Metadata) error {
- from := util.FindAllDistinctStringSubmatch(
- source.Content,
- singleQuotedFrom,
- doubleQuotedFrom,
- singleQuotedFromF,
- doubleQuotedFromF,
- )
- to := util.FindAllDistinctStringSubmatch(
- source.Content,
- singleQuotedTo,
- doubleQuotedTo,
- singleQuotedToD,
- doubleQuotedToD,
- singleQuotedToF,
- doubleQuotedToF,
- singleQuotedWireTap,
- doubleQuotedWireTap,
- )
- kameletEips := util.FindAllDistinctStringSubmatch(
- source.Content,
- singleQuotedKameletEip,
- doubleQuotedKameletEip)
-
- hasRest := restRegexp.MatchString(source.Content)
-
- return i.extract(source, meta, from, to, kameletEips, hasRest)
-}
-
-// ReplaceFromURI parses the source content and replace the `from` URI configuration with the a new URI. Returns true if it applies a replacement.
-func (i JavaScriptInspector) ReplaceFromURI(source *v1.SourceSpec, newFromURI string) (bool, error) {
- return replaceFromURI(source, newFromURI)
-}
diff --git a/pkg/util/source/inspector_java_script_test.go b/pkg/util/source/inspector_java_script_test.go
deleted file mode 100644
index c777d0279..000000000
--- a/pkg/util/source/inspector_java_script_test.go
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
-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 source
-
-import (
- "fmt"
- "testing"
-
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- "github.com/apache/camel-k/v2/pkg/util/camel"
-
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-)
-
-func newTestJavaScriptInspector(t *testing.T) JavaScriptInspector {
- t.Helper()
-
- catalog, err := camel.DefaultCatalog()
- require.NoError(t, err)
-
- return JavaScriptInspector{
- baseInspector: baseInspector{
- catalog: catalog,
- },
- }
-}
-
-const javaScriptKameletEip = `
-from("direct:start")
- .kamelet("foo/bar?baz=test")
-`
-
-const javaScriptKameletEndpoint = `
-from("direct:start")
- .to("kamelet:foo/bar?baz=test")
-`
-
-const javaScriptWireTapEipSingleQuote = `
-from("direct:start")
- .wireTap('kamelet:foo/bar?baz=test')
-`
-
-func TestJavaScriptKamelet(t *testing.T) {
- tc := []struct {
- source string
- kamelets []string
- }{
- {
- source: javaScriptKameletEip,
- kamelets: []string{"foo/bar"},
- },
- {
- source: javaScriptKameletEndpoint,
- kamelets: []string{"foo/bar"},
- },
- {
- source: javaScriptWireTapEipSingleQuote,
- kamelets: []string{"foo/bar"},
- },
- }
-
- inspector := newTestJavaScriptInspector(t)
- for i := range tc {
- test := tc[i]
- t.Run(fmt.Sprintf("TestJavaScriptKamelet-%d", i), func(t *testing.T) {
- assertExtract(t, inspector, test.source, func(meta *Metadata) {
- assert.True(t, meta.RequiredCapabilities.IsEmpty())
- for _, k := range test.kamelets {
- assert.Contains(t, meta.Kamelets, k)
- }
- })
- })
- }
-}
-
-const javaScriptJSONEip = `
-from('direct:start')
- .unmarshal().json()
-`
-
-const javaScriptJSONJacksonEip = `
-from('direct:start')
- .unmarshal().json(JsonLibrary.Jackson)
-`
-
-const javaScriptAvroEndpoint = `
-from('direct:start')
- .to('dataformat:avro:marshal');
-`
-
-const javaScriptJacksonEndpoint = `
-from('direct:start')
- .to('dataformat:jackson:marshal')
-`
-
-const javaScriptProtobufEndpoint = `
-from('direct:start')
- .to('dataformat:protobuf:marshal')
-`
-
-func TestJavaScriptDataFormat(t *testing.T) {
- tc := []struct {
- source string
- deps []string
- }{
- {
- source: javaScriptJSONEip,
- deps: []string{"camel:jackson"},
- },
- {
- source: javaScriptJSONJacksonEip,
- deps: []string{"camel:jackson"},
- },
- {
- source: javaScriptAvroEndpoint,
- deps: []string{"camel:dataformat", "camel:avro"},
- },
- {
- source: javaScriptJacksonEndpoint,
- deps: []string{"camel:dataformat", "camel:jackson"},
- },
- {
- source: javaScriptProtobufEndpoint,
- deps: []string{"camel:dataformat", "camel:protobuf"},
- },
- }
-
- inspector := newTestJavaScriptInspector(t)
- for i := range tc {
- test := tc[i]
- t.Run(fmt.Sprintf("TestJavaScriptDataFormat-%d", i), func(t *testing.T) {
- assertExtract(t, inspector, test.source, func(meta *Metadata) {
- for _, d := range test.deps {
- assert.Contains(t, meta.Dependencies.List(), d)
- }
- })
- })
- }
-}
-
-func TestJavascriptReplaceURI(t *testing.T) {
- inspector := newTestJavaScriptInspector(t)
-
- sourceSpec := &v1.SourceSpec{
- DataSpec: v1.DataSpec{
- Name: "test.js",
- Content: "from('quartz:trigger?cron=0 0/1 * * * ?').to('log:info')",
- },
- }
- replaced, err := inspector.ReplaceFromURI(
- sourceSpec,
- "direct:newURI?hello=world",
- )
- assert.Nil(t, err)
- assert.True(t, replaced)
- assert.Equal(t, "from('direct:newURI?hello=world').to('log:info')", sourceSpec.Content)
-
- sourceSpec = &v1.SourceSpec{
- DataSpec: v1.DataSpec{
- Name: "test.js",
- Content: "from(\"quartz:trigger?cron=0 0/1 * * * ?\").to(\"log:info\")",
- },
- }
- replaced, err = inspector.ReplaceFromURI(
- sourceSpec,
- "direct:newURI?hello=world",
- )
- assert.Nil(t, err)
- assert.True(t, replaced)
- assert.Equal(t, "from(\"direct:newURI?hello=world\").to(\"log:info\")", sourceSpec.Content)
-}
-
-func TestJavascriptMultiReplaceURI(t *testing.T) {
- inspector := newTestJavaScriptInspector(t)
-
- sourceSpec := &v1.SourceSpec{
- DataSpec: v1.DataSpec{
- Name: "test.js",
- Content: "from('quartz:trigger?cron=0 0/1 * * * ?').to('direct:d1');from('direct:d1').to('log:info')",
- },
- }
- replaced, err := inspector.ReplaceFromURI(
- sourceSpec,
- "direct:newURI?hello=world",
- )
- assert.Nil(t, err)
- assert.True(t, replaced)
- assert.Equal(t, "from('direct:newURI?hello=world').to('direct:d1');from('direct:d1').to('log:info')", sourceSpec.Content)
-}
diff --git a/pkg/util/source/inspector_java_source.go b/pkg/util/source/inspector_java_source.go
index 74b4bd9f7..00837ed11 100644
--- a/pkg/util/source/inspector_java_source.go
+++ b/pkg/util/source/inspector_java_source.go
@@ -18,10 +18,18 @@ limitations under the License.
package source
import (
+ "fmt"
+ "regexp"
+
v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
"github.com/apache/camel-k/v2/pkg/util"
)
+var (
+ replaceURIDoubleQuotedFrom = regexp.MustCompile(`from\s*\(\s*"(?:timer|cron|quartz)[^"]*"\s*\)`)
+ replaceURIDoubleQuotedFromF = regexp.MustCompile(`fromF\s*\(\s*"(?:timer|cron|quartz)[^"]*"\s*\)`)
+)
+
// JavaScriptInspector inspects Java DSL spec.
type JavaSourceInspector struct {
baseInspector
@@ -43,7 +51,6 @@ func (i JavaSourceInspector) Extract(source v1.SourceSpec, meta *Metadata) error
)
kameletEips := util.FindAllDistinctStringSubmatch(
source.Content,
- singleQuotedKameletEip,
doubleQuotedKameletEip)
hasRest := restRegexp.MatchString(source.Content)
@@ -55,3 +62,12 @@ func (i JavaSourceInspector) Extract(source v1.SourceSpec, meta *Metadata) error
func (i JavaSourceInspector) ReplaceFromURI(source *v1.SourceSpec, newFromURI string) (bool, error) {
return replaceFromURIDoubleQuotesOnly(source, newFromURI)
}
+
+func replaceFromURIDoubleQuotesOnly(source *v1.SourceSpec, newFromURI string) (bool, error) {
+ originalContent := source.Content
+
+ source.Content = replaceURIDoubleQuotedFrom.ReplaceAllString(source.Content, fmt.Sprintf(`from("%s")`, newFromURI))
+ source.Content = replaceURIDoubleQuotedFromF.ReplaceAllString(source.Content, fmt.Sprintf(`fromF('%s')`, newFromURI))
+
+ return originalContent != source.Content, nil
+}
diff --git a/pkg/util/source/inspector_kotlin.go b/pkg/util/source/inspector_kotlin.go
deleted file mode 100644
index 14eff39ad..000000000
--- a/pkg/util/source/inspector_kotlin.go
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
-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 source
-
-import (
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- "github.com/apache/camel-k/v2/pkg/util"
-)
-
-// KotlinInspector inspects Kotlin DSL spec.
-type KotlinInspector struct {
- baseInspector
-}
-
-// Extract extracts all metadata from source spec.
-func (i KotlinInspector) Extract(source v1.SourceSpec, meta *Metadata) error {
- from := util.FindAllDistinctStringSubmatch(
- source.Content,
- doubleQuotedFrom,
- doubleQuotedFromF,
- )
- to := util.FindAllDistinctStringSubmatch(
- source.Content,
- doubleQuotedTo,
- doubleQuotedToD,
- doubleQuotedToF,
- doubleQuotedWireTap,
- )
- kameletEips := util.FindAllDistinctStringSubmatch(
- source.Content,
- singleQuotedKameletEip,
- doubleQuotedKameletEip)
-
- hasRest := restRegexp.MatchString(source.Content) || restClosureRegexp.MatchString(source.Content)
-
- return i.extract(source, meta, from, to, kameletEips, hasRest)
-}
-
-// ReplaceFromURI parses the source content and replace the `from` URI configuration with the a new URI. Returns true if it applies a replacement.
-func (i KotlinInspector) ReplaceFromURI(source *v1.SourceSpec, newFromURI string) (bool, error) {
- return replaceFromURIDoubleQuotesOnly(source, newFromURI)
-}
diff --git a/pkg/util/source/inspector_kotlin_test.go b/pkg/util/source/inspector_kotlin_test.go
deleted file mode 100644
index a332ad950..000000000
--- a/pkg/util/source/inspector_kotlin_test.go
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
-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 source
-
-import (
- "fmt"
- "testing"
-
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- "github.com/apache/camel-k/v2/pkg/util/camel"
-
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-)
-
-func newTestKotlinInspector(t *testing.T) KotlinInspector {
- t.Helper()
-
- catalog, err := camel.DefaultCatalog()
- require.NoError(t, err)
-
- return KotlinInspector{
- baseInspector: baseInspector{
- catalog: catalog,
- },
- }
-}
-
-const kotlinKameletEip = `
-from("direct:start")
- .kamelet("foo/bar?baz=test")
-`
-
-const kotlinKameletEndpoint = `
-from("direct:start")
- .to("kamelet:foo/bar?baz=test")
-`
-
-const kotlinWireTapEip = `
-from("direct:start")
- .wireTap("kamelet:foo/bar?baz=test")
-`
-
-func TestKotlinKamelet(t *testing.T) {
- tc := []struct {
- source string
- kamelets []string
- }{
- {
- source: kotlinKameletEip,
- kamelets: []string{"foo/bar"},
- },
- {
- source: kotlinKameletEndpoint,
- kamelets: []string{"foo/bar"},
- },
- {
- source: kotlinWireTapEip,
- kamelets: []string{"foo/bar"},
- },
- }
-
- inspector := newTestKotlinInspector(t)
- for i := range tc {
- test := tc[i]
- t.Run(fmt.Sprintf("TestKotlinKamelet-%d", i), func(t *testing.T) {
- assertExtract(t, inspector, test.source, func(meta *Metadata) {
- assert.True(t, meta.RequiredCapabilities.IsEmpty())
- for _, k := range test.kamelets {
- assert.Contains(t, meta.Kamelets, k)
- }
- })
- })
- }
-}
-
-const kotlinJSONEip = `
-from("direct:start")
- .unmarshal().json()
-`
-
-const kotlinJSONJacksonEip = `
-from("direct:start")
- .unmarshal().json(JsonLibrary.Jackson)
-`
-
-const kotlinAvroEndpoint = `
-from("direct:start")
- .to("dataformat:avro:marshal")
-`
-
-const kotlinJacksonEndpoint = `
-from("direct:start")
- .to("dataformat:jackson:marshal")
-`
-
-const kotlinProtobufEndpoint = `
-from("direct:start")
- .to("dataformat:protobuf:marshal")
-`
-
-func TestKotlinDataFormat(t *testing.T) {
- tc := []struct {
- source string
- deps []string
- }{
- {
- source: kotlinJSONEip,
- deps: []string{"camel:jackson"},
- },
- {
- source: kotlinJSONJacksonEip,
- deps: []string{"camel:jackson"},
- },
- {
- source: kotlinAvroEndpoint,
- deps: []string{"camel:dataformat", "camel:avro"},
- },
- {
- source: kotlinJacksonEndpoint,
- deps: []string{"camel:dataformat", "camel:jackson"},
- },
- {
- source: kotlinProtobufEndpoint,
- deps: []string{"camel:dataformat", "camel:protobuf"},
- },
- }
-
- inspector := newTestKotlinInspector(t)
- for i := range tc {
- test := tc[i]
- t.Run(fmt.Sprintf("TestKotlinDataFormat-%d", i), func(t *testing.T) {
- assertExtract(t, inspector, test.source, func(meta *Metadata) {
- for _, d := range test.deps {
- assert.Contains(t, meta.Dependencies.List(), d)
- }
- })
- })
- }
-}
-
-func TestKotlinReplaceURI(t *testing.T) {
- inspector := newTestKotlinInspector(t)
-
- sourceSpec := &v1.SourceSpec{
- DataSpec: v1.DataSpec{
- Name: "test.java",
- Content: "from(\"quartz:trigger?cron=0 0/1 * * * ?\").to(\"log:info\")",
- },
- }
- replaced, err := inspector.ReplaceFromURI(
- sourceSpec,
- "direct:newURI?hello=world",
- )
- assert.Nil(t, err)
- assert.True(t, replaced)
- assert.Equal(t, "from(\"direct:newURI?hello=world\").to(\"log:info\")", sourceSpec.Content)
-}
-
-func TestKotlinReplaceMultiURI(t *testing.T) {
- inspector := newTestKotlinInspector(t)
-
- sourceSpec := &v1.SourceSpec{
- DataSpec: v1.DataSpec{
- Name: "test.java",
- Content: "from(\"quartz:trigger?cron=0 0/1 * * * ?\").to(\"direct:d1\");from(\"direct:d1\").to(\"log:info\");",
- },
- }
- replaced, err := inspector.ReplaceFromURI(
- sourceSpec,
- "direct:newURI?hello=world",
- )
- assert.Nil(t, err)
- assert.True(t, replaced)
- assert.Equal(t, "from(\"direct:newURI?hello=world\").to(\"direct:d1\");from(\"direct:d1\").to(\"log:info\");", sourceSpec.Content)
-}
diff --git a/script/check_licenses.sh b/script/check_licenses.sh
index e9c31f04a..5bc06aac2 100755
--- a/script/check_licenses.sh
+++ b/script/check_licenses.sh
@@ -54,10 +54,7 @@ check_licenses() {
check_licenses *.go ./script/headers/default.txt
-check_licenses *.groovy ./script/headers/default-jvm.txt
check_licenses *.java ./script/headers/default-jvm.txt
-check_licenses *.kts ./script/headers/default-jvm.txt
-check_licenses *.js ./script/headers/js.txt
check_licenses *.xml ./script/headers/xml.txt
check_licenses *.yaml ./script/headers/yaml.txt
check_licenses *.yml ./script/headers/yaml.txt