Skip to content

Commit

Permalink
fix(trait): catalog to drive dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
squakez committed Feb 29, 2024
1 parent d45d039 commit b86a7fb
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 23 deletions.
3 changes: 0 additions & 3 deletions addons/vault/aws/aws_secrets_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ func (t *awsSecretsManagerTrait) Apply(environment *trait.Environment) error {
rex := regexp.MustCompile(`^(configmap|secret):([a-zA-Z0-9][a-zA-Z0-9-]*)(/([a-zA-Z0-9].*))?$`)
if environment.IntegrationInPhase(v1.IntegrationPhaseInitialization) {
util.StringSliceUniqueAdd(&environment.Integration.Status.Capabilities, v1.CapabilityAwsSecretsManager)
// Deprecated
// remove dependencies after Camel K Runtime > 2.16.0 and no longer supported or LTS
util.StringSliceUniqueAdd(&environment.Integration.Status.Dependencies, "mvn:org.apache.camel.quarkus:camel-quarkus-aws-secrets-manager")
}

if environment.IntegrationInRunningPhases() {
Expand Down
3 changes: 0 additions & 3 deletions addons/vault/azure/azure_key_vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ func (t *azureKeyVaultTrait) Apply(environment *trait.Environment) error {
rex := regexp.MustCompile(`^(configmap|secret):([a-zA-Z0-9][a-zA-Z0-9-]*)(/([a-zA-Z0-9].*))?$`)
if environment.IntegrationInPhase(v1.IntegrationPhaseInitialization) {
util.StringSliceUniqueAdd(&environment.Integration.Status.Capabilities, v1.CapabilityAzureKeyVault)
// Deprecated
// remove dependencies after Camel K Runtime > 2.16.0 and no longer supported or LTS
util.StringSliceUniqueAdd(&environment.Integration.Status.Dependencies, "mvn:org.apache.camel.quarkus:camel-quarkus-azure-key-vault")
}

if environment.IntegrationInRunningPhases() {
Expand Down
3 changes: 0 additions & 3 deletions addons/vault/gcp/gcp_secret_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ func (t *gcpSecretManagerTrait) Configure(environment *trait.Environment) (bool,
func (t *gcpSecretManagerTrait) Apply(environment *trait.Environment) error {
if environment.IntegrationInPhase(v1.IntegrationPhaseInitialization) {
util.StringSliceUniqueAdd(&environment.Integration.Status.Capabilities, v1.CapabilityGcpSecretManager)
// Deprecated
// remove dependencies after Camel K Runtime > 2.16.0 and no longer supported or LTS
util.StringSliceUniqueAdd(&environment.Integration.Status.Dependencies, "mvn:org.apache.camel.quarkus:camel-quarkus-google-secret-manager")
}

if environment.IntegrationInRunningPhases() {
Expand Down
3 changes: 0 additions & 3 deletions addons/vault/hashicorp/hashicorp_vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ func (t *hashicorpVaultTrait) Apply(environment *trait.Environment) error {
rex := regexp.MustCompile(`^(configmap|secret):([a-zA-Z0-9][a-zA-Z0-9-]*)(/([a-zA-Z0-9].*))?$`)
if environment.IntegrationInPhase(v1.IntegrationPhaseInitialization) {
util.StringSliceUniqueAdd(&environment.Integration.Status.Capabilities, v1.CapabilityHashicorpVault)
// Deprecated
// remove dependencies after Camel K Runtime > 2.16.0 and no longer supported or LTS
util.StringSliceUniqueAdd(&environment.Integration.Status.Dependencies, "mvn:org.apache.camel.quarkus:camel-quarkus-hashicorp-vault")
}

if environment.IntegrationInRunningPhases() {
Expand Down
6 changes: 0 additions & 6 deletions pkg/trait/knative.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,6 @@ func (t *knativeTrait) Apply(e *Environment) error {
if e.IntegrationInPhase(v1.IntegrationPhaseInitialization) {
util.StringSliceUniqueAdd(&e.Integration.Status.Capabilities, v1.CapabilityKnative)
}
// Deprecated
// remove dependencies after Camel K Runtime > 2.16.0 and no longer supported or LTS
if pointer.BoolDeref(t.SinkBinding, false) {
util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, "camel:knative")
util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, "mvn:org.apache.camel.k:camel-k-knative-impl")
}

if len(t.ChannelSources) > 0 || len(t.EndpointSources) > 0 || len(t.EventSources) > 0 {
util.StringSliceUniqueAdd(&e.Integration.Status.Capabilities, v1.CapabilityPlatformHTTP)
Expand Down
5 changes: 0 additions & 5 deletions pkg/trait/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ func (t *prometheusTrait) Configure(e *Environment) (bool, *TraitCondition, erro
func (t *prometheusTrait) Apply(e *Environment) error {
if e.IntegrationInPhase(v1.IntegrationPhaseInitialization) {
util.StringSliceUniqueAdd(&e.Integration.Status.Capabilities, v1.CapabilityPrometheus)
// Deprecated
// remove dependencies after Camel K Runtime > 2.16.0 and no longer supported or LTS
util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, "mvn:org.apache.camel.quarkus:camel-quarkus-micrometer")
util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, "mvn:io.micrometer:micrometer-registry-prometheus")
return nil
}

container := e.GetIntegrationContainer()
Expand Down
65 changes: 65 additions & 0 deletions pkg/util/camel/camel_runtime_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
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 camel

import (
"context"
"os"
"testing"
"time"

v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
"github.com/apache/camel-k/v2/pkg/util/defaults"
"github.com/apache/camel-k/v2/pkg/util/test"
"github.com/stretchr/testify/assert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func TestCreateCatalog(t *testing.T) {
ip := v1.IntegrationPlatform{}
ip.Status.Build.Timeout = &metav1.Duration{
Duration: 5 * time.Minute,
}
c, err := test.NewFakeClient()
assert.Nil(t, err)
// use local Maven executable in tests
t.Setenv("MAVEN_WRAPPER", "false")
_, ok := os.LookupEnv("MAVEN_CMD")
if !ok {
t.Setenv("MAVEN_CMD", "mvn")
}
catalog, err := CreateCatalog(
context.TODO(),
c,
"",
&ip,
v1.RuntimeSpec{Provider: v1.RuntimeProviderQuarkus, Version: defaults.DefaultRuntimeVersion})
assert.Nil(t, err)
assert.NotNil(t, catalog)
assert.Equal(t, defaults.DefaultRuntimeVersion, catalog.Runtime.Version)
assert.Equal(t, v1.RuntimeProviderQuarkus, catalog.Runtime.Provider)
assert.NotEmpty(t, catalog.Runtime.Capabilities)

camelCatalog := v1.CamelCatalog{
Spec: catalog.CamelCatalogSpec,
Status: catalog.CamelCatalogStatus,
}

rtCat := NewRuntimeCatalog(camelCatalog)
assert.NotNil(t, rtCat.Runtime.Capabilities["knative"])
}

0 comments on commit b86a7fb

Please sign in to comment.