Skip to content

Commit

Permalink
feat(api): expose Camel core version
Browse files Browse the repository at this point in the history
It is useful to know what core version of Camel the runtime is running
  • Loading branch information
squakez committed Sep 5, 2024
1 parent 0b04044 commit 80328ab
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 2 deletions.
7 changes: 7 additions & 0 deletions docs/modules/ROOT/partials/apis/camel-k-crds.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2830,6 +2830,13 @@ the Camel K Runtime dependency version
the runtime used. Likely Camel Quarkus (we used to have main runtime which has been discontinued since version 1.5)
|`runtimeCoreVersion` +
string
|
the Camel core version used by this IntegrationPlatform
|`baseImage` +
string
|
Expand Down
10 changes: 10 additions & 0 deletions helm/camel-k/crds/camel-k-crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3212,6 +3212,10 @@ spec:
jsonPath: .status.build.runtimeVersion
name: Default runtime
type: string
- description: The default Camel core version
jsonPath: .status.build.runtimeCoreVersion
name: Camel version
type: string
name: v1
schema:
openAPIV3Schema:
Expand Down Expand Up @@ -3571,6 +3575,9 @@ spec:
description: the secret where credentials are stored
type: string
type: object
runtimeCoreVersion:
description: the Camel core version used by this IntegrationPlatform
type: string
runtimeProvider:
description: the runtime used. Likely Camel Quarkus (we used to
have main runtime which has been discontinued since version
Expand Down Expand Up @@ -5661,6 +5668,9 @@ spec:
description: the secret where credentials are stored
type: string
type: object
runtimeCoreVersion:
description: the Camel core version used by this IntegrationPlatform
type: string
runtimeProvider:
description: the runtime used. Likely Camel Quarkus (we used to
have main runtime which has been discontinued since version
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/camel/v1/integrationplatform_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ type IntegrationPlatformStatus struct {
// +kubebuilder:printcolumn:name="Publish strategy",type=string,JSONPath=`.status.build.publishStrategy`,description="The default publish strategy"
// +kubebuilder:printcolumn:name="Registry address",type=string,JSONPath=`.status.build.registry.address`,description="The container registry address"
// +kubebuilder:printcolumn:name="Default runtime",type=string,JSONPath=`.status.build.runtimeVersion`,description="The default runtime version"
// +kubebuilder:printcolumn:name="Camel version",type=string,JSONPath=`.status.build.runtimeCoreVersion`,description="The default Camel core version"

// IntegrationPlatform is the resource used to drive the Camel K operator behavior.
// It defines the behavior of all Custom Resources (`IntegrationKit`, `Integration`, `Kamelet`) in the given namespace.
Expand Down Expand Up @@ -119,6 +120,8 @@ type IntegrationPlatformBuildSpec struct {
RuntimeVersion string `json:"runtimeVersion,omitempty"`
// the runtime used. Likely Camel Quarkus (we used to have main runtime which has been discontinued since version 1.5)
RuntimeProvider RuntimeProvider `json:"runtimeProvider,omitempty"`
// the Camel core version used by this IntegrationPlatform
RuntimeCoreVersion string `json:"runtimeCoreVersion,omitempty"`
// a base image that can be used as base layer for all images.
// It can be useful if you want to provide some custom base image with further utility software
BaseImage string `json:"baseImage,omitempty"`
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions pkg/controller/integrationplatform/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ func (action *catalogAction) Handle(ctx context.Context, platform *v1.Integratio
Provider: v1.RuntimeProviderQuarkus,
}

if catalog, err := camel.LoadCatalog(ctx, action.client, platform.Namespace, runtimeSpec); err != nil {
catalog, err := camel.LoadCatalog(ctx, action.client, platform.Namespace, runtimeSpec)
if err != nil {
action.L.Error(err, "IntegrationPlatform unable to load Camel catalog",
"runtime-version", runtimeSpec.Version, "runtime-provider", runtimeSpec.Provider)
return platform, nil
} else if catalog == nil {
if _, err = camel.CreateCatalog(ctx, action.client, platform.Namespace, platform, runtimeSpec); err != nil {
if catalog, err = camel.CreateCatalog(ctx, action.client, platform.Namespace, platform, runtimeSpec); err != nil {
action.L.Error(err, "IntegrationPlatform unable to create Camel catalog",
"runtime-version", runtimeSpec.Version, "runtime-provider", runtimeSpec.Provider)

Expand All @@ -77,6 +78,7 @@ func (action *catalogAction) Handle(ctx context.Context, platform *v1.Integratio
corev1.ConditionTrue,
v1.IntegrationPlatformConditionCamelCatalogAvailableReason,
fmt.Sprintf("camel catalog %s available", runtimeSpec.Version))
platform.Status.Build.RuntimeCoreVersion = catalog.Runtime.Metadata["camel.version"]

return platform, nil
}
6 changes: 6 additions & 0 deletions pkg/controller/integrationplatform/catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ func TestCreateCatalog(t *testing.T) {

assert.Equal(t, v1.IntegrationPlatformPhaseReady, answer.Status.Phase, "Error", answer.Status.Conditions[0].Message)
assert.Equal(t, corev1.ConditionTrue, answer.Status.GetCondition(v1.IntegrationPlatformConditionCamelCatalogAvailable).Status)
// We don't know exactly which is the core version, it is enough to check is not empty in the test
assert.NotEqual(t, "", answer.Status.Build.RuntimeCoreVersion)

list := v1.NewCamelCatalogList()
err = c.List(context.TODO(), &list, k8sclient.InNamespace(ip.Namespace))
Expand Down Expand Up @@ -160,6 +162,9 @@ func TestCatalogAlreadyPresent(t *testing.T) {
catalog := v1.NewCamelCatalog("ns", fmt.Sprintf("camel-catalog-%s", defaults.DefaultRuntimeVersion))
catalog.Spec.Runtime.Version = defaults.DefaultRuntimeVersion
catalog.Spec.Runtime.Provider = v1.RuntimeProviderQuarkus
catalog.Spec.Runtime.Metadata = map[string]string{
"camel.version": "4.4.0",
}

c, err := test.NewFakeClient(&ip, &catalog)
require.NoError(t, err)
Expand All @@ -176,6 +181,7 @@ func TestCatalogAlreadyPresent(t *testing.T) {
assert.NotNil(t, answer)

assert.Equal(t, v1.IntegrationPlatformPhaseReady, answer.Status.Phase)
assert.Equal(t, "4.4.0", answer.Status.Build.RuntimeCoreVersion)
assert.Equal(t, corev1.ConditionTrue, answer.Status.GetCondition(v1.IntegrationPlatformConditionCamelCatalogAvailable).Status)
}

Expand Down
1 change: 1 addition & 0 deletions pkg/controller/integrationplatform/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func (action *monitorAction) Handle(ctx context.Context, platform *v1.Integratio
corev1.ConditionTrue,
v1.IntegrationPlatformConditionCamelCatalogAvailableReason,
fmt.Sprintf("camel catalog %s available", runtimeSpec.Version))
platform.Status.Build.RuntimeCoreVersion = catalog.Runtime.Metadata["camel.version"]
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ spec:
jsonPath: .status.build.runtimeVersion
name: Default runtime
type: string
- description: The default Camel core version
jsonPath: .status.build.runtimeCoreVersion
name: Camel version
type: string
name: v1
schema:
openAPIV3Schema:
Expand Down Expand Up @@ -416,6 +420,9 @@ spec:
description: the secret where credentials are stored
type: string
type: object
runtimeCoreVersion:
description: the Camel core version used by this IntegrationPlatform
type: string
runtimeProvider:
description: the runtime used. Likely Camel Quarkus (we used to
have main runtime which has been discontinued since version
Expand Down Expand Up @@ -2506,6 +2513,9 @@ spec:
description: the secret where credentials are stored
type: string
type: object
runtimeCoreVersion:
description: the Camel core version used by this IntegrationPlatform
type: string
runtimeProvider:
description: the runtime used. Likely Camel Quarkus (we used to
have main runtime which has been discontinued since version
Expand Down

0 comments on commit 80328ab

Please sign in to comment.