Skip to content

Commit ac44348

Browse files
committed
feat(api): deprecate IntegrationPlatform
This is a prerequisite for next gen architecture of Camel K, where we aim to simplify the API. From now on, the configuration which was previously part of the IntegrationPlatform custom resource, has to be configured as environment variable on the operator. Ref #6454
1 parent 1ff6ca3 commit ac44348

File tree

97 files changed

+1098
-2769
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+1098
-2769
lines changed

.github/workflows/common.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,35 @@ jobs:
8282
run: |
8383
DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make test-common
8484
85+
# This job will replace the previous one when we've settled any possible issue
86+
# with IntegrationPlatform deprecation
87+
common-platformless:
88+
runs-on: ubuntu-latest
89+
steps:
90+
- name: Checkout code
91+
uses: actions/checkout@v4
92+
with:
93+
persist-credentials: false
94+
submodules: recursive
95+
96+
- name: Infra setting
97+
uses: ./.github/actions/infra-setting
98+
99+
- name: Install operator
100+
shell: bash
101+
run: |
102+
kubectl create ns camel-k
103+
kubectl apply -k install/overlays/kubernetes/descoped/ --server-side --force-conflicts
104+
kubectl wait --for=condition=available deployment/camel-k-operator -n camel-k --timeout=60s
105+
# Install Apache Kamelets catalog
106+
curl -sL "https://repo1.maven.org/maven2/org/apache/camel/kamelets/camel-kamelets/4.18.1/camel-kamelets-4.18.1.jar" > /tmp/camel-kamelets.jar
107+
unzip /tmp/camel-kamelets.jar && kubectl apply -f /tmp/kamelets
108+
109+
- name: Run test
110+
shell: bash
111+
run: |
112+
DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make test-common
113+
85114
advanced:
86115
runs-on: ubuntu-latest
87116
steps:

build/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ RUN tar -xC ${MVNW_DIR} -f ${MVNW_DIR}mvnw.tar \
3939
# Used by mvnw to download maven dist into it
4040
ENV MAVEN_USER_HOME="${MAVEN_HOME}"
4141
# Install a default mvnw distribution at build time
42-
RUN ${MVNW_DIR}/mvnw --version
42+
RUN ${MVNW_DIR}mvnw --version
4343

4444
ADD build/_maven_output ${MVN_REPO}
4545
# Fix https://github.com/moby/moby/issues/37965
@@ -56,7 +56,7 @@ USER 1001:0
5656

5757
ADD build/_output/bin/kamel-${IMAGE_ARCH} /usr/local/bin/kamel
5858

59-
FROM golang:1.22 AS go
59+
FROM golang:1.25 AS go
6060

6161
RUN go install github.com/go-delve/delve/cmd/dlv@latest
6262

docs/modules/ROOT/partials/apis/camel-k-crds.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2975,6 +2975,8 @@ the maximum amount of parallel running pipelines started by this operator instan
29752975
29762976
IntegrationPlatformCluster is the kind of orchestration cluster the platform is installed into.
29772977
2978+
Deprecated: no longer in use.
2979+
29782980
29792981
[#_camel_apache_org_v1_IntegrationPlatformCondition]
29802982
=== IntegrationPlatformCondition

e2e/advanced/platform_traits_test.go

Lines changed: 0 additions & 63 deletions
This file was deleted.

e2e/install/helm/setup_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
corev1 "k8s.io/api/core/v1"
3333

3434
. "github.com/apache/camel-k/v2/e2e/support"
35+
v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
3536
"github.com/apache/camel-k/v2/pkg/util/defaults"
3637
. "github.com/onsi/gomega"
3738
)
@@ -73,6 +74,8 @@ func TestHelmInstallation(t *testing.T) {
7374
g.Expect(operatorPod.Spec.Containers[0].SecurityContext.SeccompProfile).To(Equal(DefaultOperatorSecurityContext().SeccompProfile))
7475
g.Expect(operatorPod.Spec.Containers[0].SecurityContext.AllowPrivilegeEscalation).To(Equal(DefaultOperatorSecurityContext().AllowPrivilegeEscalation))
7576

77+
g.Eventually(PlatformPhase(t, ctx, ns)).Should(Equal(v1.IntegrationPlatformPhaseReady))
78+
7679
// Test a simple route
7780
t.Run("simple route", func(t *testing.T) {
7881
g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())

e2e/support/test_util.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"sync"
3232
"testing"
3333

34+
v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
3435
. "github.com/onsi/gomega"
3536
"github.com/onsi/gomega/gexec"
3637
. "github.com/onsi/gomega/gstruct"
@@ -104,8 +105,9 @@ func InstallOperatorWithConf(t *testing.T, ctx context.Context, g *WithT, ns, op
104105
ExpectExecSucceed(t, g,
105106
Make(t, makeRule, args...),
106107
)
107-
// Let's make sure the operator has been deployed
108+
// Let's make sure the operator has been deployed and the platform ready
108109
g.Eventually(OperatorPod(t, ctx, ns)).ShouldNot(BeNil())
110+
g.Eventually(PlatformPhase(t, ctx, ns)).Should(Equal(v1.IntegrationPlatformPhaseReady))
109111
}
110112

111113
// UninstallOperator will delete operator resources from namespace (keeps CRDs).

helm/camel-k/templates/operator-deployment.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ spec:
6363
value: {{ .Values.operator.logLevel }}
6464
- name: OPERATOR_NAME
6565
value: camel-k
66+
# NOTE: this value must be changed properly with a real
67+
# container registry value. In development Minikube environment
68+
# you can use constant "MINIKUBE" to dynamically look and load the
69+
# registry add-on which has to be installed previously on the cluster.
70+
- name: REGISTRY_ADDRESS
71+
value: MINIKUBE
6672
- name: POD_NAME
6773
valueFrom:
6874
fieldRef:

pkg/apis/camel/v1/common_types_support.go

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,6 @@ func (in *RuntimeSpec) CapabilityDependencies(capability string) []MavenArtifact
5050
return deps
5151
}
5252

53-
// TraitProfileByName returns the trait profile corresponding to the given name (case insensitive).
54-
func TraitProfileByName(name string) TraitProfile {
55-
for _, p := range AllTraitProfiles {
56-
if strings.EqualFold(name, string(p)) {
57-
return p
58-
}
59-
}
60-
61-
return ""
62-
}
63-
6453
// Equal checks if the profile is equal to the given profile (case insensitive).
6554
func (p TraitProfile) Equal(other TraitProfile) bool {
6655
return strings.EqualFold(string(p), string(other))
@@ -289,3 +278,23 @@ func (s *SourceSpec) InferLanguage() Language {
289278

290279
return ""
291280
}
281+
282+
// Validate checks if the strategy is supported.
283+
func (b BuildStrategy) Validate() error {
284+
switch b {
285+
case BuildStrategyRoutine, BuildStrategyPod:
286+
return nil
287+
default:
288+
return fmt.Errorf("invalid BuildStrategy: %q", b)
289+
}
290+
}
291+
292+
// Validate checks if the strategy is supported.
293+
func (b BuildOrderStrategy) Validate() error {
294+
switch b {
295+
case BuildOrderStrategyDependencies, BuildOrderStrategyFIFO, BuildOrderStrategySequential:
296+
return nil
297+
default:
298+
return fmt.Errorf("invalid BuildStrategy: %q", b)
299+
}
300+
}

pkg/apis/camel/v1/common_types_support_test.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,52 @@ func TestDecodeValueSourceInvalid(t *testing.T) {
190190
}
191191

192192
}
193+
194+
func TestBuildStrategy_Validate(t *testing.T) {
195+
tests := []struct {
196+
name string
197+
input BuildStrategy
198+
wantError bool
199+
}{
200+
{"valid routine", BuildStrategyRoutine, false},
201+
{"valid pod", BuildStrategyPod, false},
202+
{"invalid strategy", BuildStrategy("wrong"), true},
203+
{"empty strategy", BuildStrategy(""), true},
204+
}
205+
206+
for _, tt := range tests {
207+
t.Run(tt.name, func(t *testing.T) {
208+
err := tt.input.Validate()
209+
if tt.wantError {
210+
assert.Error(t, err)
211+
} else {
212+
assert.NoError(t, err)
213+
}
214+
})
215+
}
216+
}
217+
218+
func TestBuildOrderStrategy_Validate(t *testing.T) {
219+
tests := []struct {
220+
name string
221+
input BuildOrderStrategy
222+
wantError bool
223+
}{
224+
{"valid dependencies", BuildOrderStrategyDependencies, false},
225+
{"valid fifo", BuildOrderStrategyFIFO, false},
226+
{"valid sequential", BuildOrderStrategySequential, false},
227+
{"invalid strategy", BuildOrderStrategy("wrong"), true},
228+
{"empty strategy", BuildOrderStrategy(""), true},
229+
}
230+
231+
for _, tt := range tests {
232+
t.Run(tt.name, func(t *testing.T) {
233+
err := tt.input.Validate()
234+
if tt.wantError {
235+
assert.Error(t, err)
236+
} else {
237+
assert.NoError(t, err)
238+
}
239+
})
240+
}
241+
}

pkg/apis/camel/v1/integration_types_support.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -283,17 +283,6 @@ func (in *Integration) SetOperatorID(operatorID string) {
283283
SetAnnotation(&in.ObjectMeta, OperatorIDAnnotation, operatorID)
284284
}
285285

286-
func (in *Integration) SetIntegrationPlatform(platform *IntegrationPlatform) {
287-
cs := corev1.ConditionTrue
288-
289-
if platform.Status.Phase != IntegrationPlatformPhaseReady {
290-
cs = corev1.ConditionFalse
291-
}
292-
293-
in.Status.SetCondition(IntegrationConditionPlatformAvailable, cs, IntegrationConditionPlatformAvailableReason, platform.Namespace+"/"+platform.Name)
294-
in.Status.Platform = platform.Name
295-
}
296-
297286
func (in *Integration) SetIntegrationKit(kit *IntegrationKit) {
298287
if kit == nil {
299288
in.Status.IntegrationKit = nil
@@ -328,15 +317,18 @@ func (in *Integration) SetIntegrationKit(kit *IntegrationKit) {
328317
in.Status.Image = image
329318
}
330319

331-
func (in *Integration) GetIntegrationKitNamespace(p *IntegrationPlatform) string {
320+
// GetIntegrationKitNamespace returns the namespace of the kit. You must provide a fallback platform
321+
// namespace where the new Kit is going to be created (ie, the older IntegrationPlatform namespace) or
322+
// the operator namespace.
323+
func (in *Integration) GetIntegrationKitNamespace(platformNamespace string) string {
332324
if in.Status.IntegrationKit != nil && in.Status.IntegrationKit.Namespace != "" {
333325
return in.Status.IntegrationKit.Namespace
334326
}
335327
if in.Spec.IntegrationKit != nil && in.Spec.IntegrationKit.Namespace != "" {
336328
return in.Spec.IntegrationKit.Namespace
337329
}
338-
if p != nil {
339-
return p.Namespace
330+
if platformNamespace != "" {
331+
return platformNamespace
340332
}
341333

342334
return in.Namespace

0 commit comments

Comments
 (0)