This is an automated email from the ASF dual-hosted git repository.
squakez 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 8fa711c89 chore(ci): bump lint
8fa711c89 is described below
commit 8fa711c893c681ad3d36e8f803cbe22dc96e2f53
Author: Pasquale Congiusti <[email protected]>
AuthorDate: Tue Sep 15 08:32:07 2026 +0200
chore(ci): bump lint
Closes #6814
---
.golangci.yml | 1 +
cmd/util/doc-gen/generators/traitdocgen.go | 2 +-
pkg/apis/camel/v1/build_types_support.go | 12 +--
pkg/apis/camel/v1/camelcatalog_types_support.go | 32 +++-----
pkg/apis/camel/v1/common_types_support.go | 12 +--
pkg/apis/camel/v1/integration_types_support.go | 30 +++----
pkg/apis/camel/v1/integrationkit_types_support.go | 18 ++--
.../camel/v1/integrationplatform_types_support.go | 18 ++--
.../camel/v1/integrationprofile_types_support.go | 12 +--
pkg/apis/camel/v1/pipe_types_support.go | 18 ++--
pkg/apis/camel/v1/trait/base.go | 2 +-
pkg/builder/s2i.go | 28 +++----
pkg/builder/steps.go | 2 +-
pkg/client/apply.go | 3 +-
pkg/cmd/bind.go | 7 +-
pkg/cmd/delete.go | 19 ++---
pkg/cmd/get.go | 8 +-
pkg/cmd/log.go | 25 ++----
pkg/cmd/run.go | 21 ++---
pkg/cmd/util.go | 13 +--
pkg/controller/build/build_pod.go | 45 ++++------
pkg/controller/integration/build.go | 64 ++++++---------
.../integration/integration_controller.go | 25 ++----
pkg/controller/integration/monitor.go | 25 ++----
pkg/controller/integrationkit/build.go | 16 ++--
.../integrationkit/integrationkit_controller.go | 7 +-
pkg/controller/pipe/integration.go | 26 +++---
pkg/install/openshift.go | 9 +-
pkg/internal/client.go | 12 +--
pkg/platform/defaults.go | 16 ++--
pkg/platform/env_platform.go | 18 ++--
pkg/trait/builder.go | 48 ++++-------
pkg/trait/camel.go | 47 +++++------
pkg/trait/cron.go | 16 ++--
pkg/trait/deployment.go | 16 ++--
pkg/trait/gateway.go | 33 +++-----
pkg/trait/health.go | 10 +--
pkg/trait/ingress.go | 21 ++---
pkg/trait/init.go | 6 +-
pkg/trait/kamelets.go | 39 ++++-----
pkg/trait/kamelets_support.go | 23 ++----
pkg/trait/keda.go | 25 ++----
pkg/trait/knative_service.go | 16 ++--
pkg/trait/mount.go | 27 +++---
pkg/trait/mount_support.go | 12 +--
pkg/trait/pdb.go | 14 ++--
pkg/trait/prometheus.go | 14 ++--
pkg/trait/pull_secret.go | 13 +--
pkg/trait/route.go | 19 ++---
pkg/trait/service.go | 17 ++--
pkg/trait/trait.go | 12 +--
pkg/trait/trait_types.go | 4 +-
pkg/trait/util.go | 2 +-
pkg/util/camel/camel_runtime_catalog.go | 18 ++--
pkg/util/knative/apis.go | 96 ++++++++--------------
pkg/util/knative/knative.go | 36 +++-----
pkg/util/kubernetes/client.go | 25 ++----
pkg/util/kubernetes/collection.go | 8 +-
pkg/util/kubernetes/factory.go | 13 +--
pkg/util/kubernetes/log/pod_scraper.go | 12 +--
pkg/util/kubernetes/lookup.go | 96 ++++++++--------------
pkg/util/maven/maven_command.go | 2 +-
pkg/util/maven/maven_repositories.go | 1 +
pkg/util/openshift/openshift.go | 4 +-
pkg/util/source/inspector.go | 12 +--
script/Makefile | 2 +-
66 files changed, 464 insertions(+), 841 deletions(-)
diff --git a/.golangci.yml b/.golangci.yml
index d6d4bf230..f50e4ae49 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -26,6 +26,7 @@ linters:
- err113
- exhaustive
- exhaustruct
+ - exhaustruct_v5
- funcorder
- funlen
- gochecknoglobals
diff --git a/cmd/util/doc-gen/generators/traitdocgen.go
b/cmd/util/doc-gen/generators/traitdocgen.go
index f15436bb0..b39c2f987 100644
--- a/cmd/util/doc-gen/generators/traitdocgen.go
+++ b/cmd/util/doc-gen/generators/traitdocgen.go
@@ -254,7 +254,7 @@ func writeMembers(t *types.Type, traitID string, content
*[]string) {
if json == "" {
continue
}
- jsonName := strings.Split(json, ",")[0]
+ jsonName, _, _ := strings.Cut(json, ",")
res = append(res, "| "+traitID+"."+jsonName)
res = append(res, "|
"+strings.TrimPrefix(m.Type.Name.Name, "*"))
diff --git a/pkg/apis/camel/v1/build_types_support.go
b/pkg/apis/camel/v1/build_types_support.go
index 6128b96b1..0a7126876 100644
--- a/pkg/apis/camel/v1/build_types_support.go
+++ b/pkg/apis/camel/v1/build_types_support.go
@@ -27,14 +27,10 @@ import (
func NewBuild(namespace string, name string) *Build {
return &Build{
- TypeMeta: metav1.TypeMeta{
- APIVersion: SchemeGroupVersion.String(),
- Kind: BuildKind,
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: namespace,
- Name: name,
- },
+ APIVersion: SchemeGroupVersion.String(),
+ Kind: BuildKind,
+ Namespace: namespace,
+ Name: name,
}
}
diff --git a/pkg/apis/camel/v1/camelcatalog_types_support.go
b/pkg/apis/camel/v1/camelcatalog_types_support.go
index 5a07bffbb..3ca23c354 100644
--- a/pkg/apis/camel/v1/camelcatalog_types_support.go
+++ b/pkg/apis/camel/v1/camelcatalog_types_support.go
@@ -27,39 +27,29 @@ import (
// NewCamelCatalog --.
func NewCamelCatalog(namespace string, name string) CamelCatalog {
return CamelCatalog{
- TypeMeta: metav1.TypeMeta{
- APIVersion: SchemeGroupVersion.String(),
- Kind: CamelCatalogKind,
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: namespace,
- Name: name,
- },
+ APIVersion: SchemeGroupVersion.String(),
+ Kind: CamelCatalogKind,
+ Namespace: namespace,
+ Name: name,
}
}
// NewCamelCatalogWithSpecs --.
func NewCamelCatalogWithSpecs(namespace string, name string, spec
CamelCatalogSpec) CamelCatalog {
return CamelCatalog{
- TypeMeta: metav1.TypeMeta{
- APIVersion: SchemeGroupVersion.String(),
- Kind: CamelCatalogKind,
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: namespace,
- Name: name,
- },
- Spec: spec,
+ APIVersion: SchemeGroupVersion.String(),
+ Kind: CamelCatalogKind,
+ Namespace: namespace,
+ Name: name,
+ Spec: spec,
}
}
// NewCamelCatalogList --.
func NewCamelCatalogList() CamelCatalogList {
return CamelCatalogList{
- TypeMeta: metav1.TypeMeta{
- APIVersion: SchemeGroupVersion.String(),
- Kind: CamelCatalogKind,
- },
+ APIVersion: SchemeGroupVersion.String(),
+ Kind: CamelCatalogKind,
}
}
diff --git a/pkg/apis/camel/v1/common_types_support.go
b/pkg/apis/camel/v1/common_types_support.go
index d79d10453..bfee3e035 100644
--- a/pkg/apis/camel/v1/common_types_support.go
+++ b/pkg/apis/camel/v1/common_types_support.go
@@ -231,20 +231,16 @@ func DecodeValueSource(input string, defaultKey string)
(ValueSource, error) {
if sub[0] == "configmap" {
return ValueSource{
ConfigMapKeyRef: &corev1.ConfigMapKeySelector{
- LocalObjectReference:
corev1.LocalObjectReference{
- Name: sub[1],
- },
- Key: key,
+ Name: sub[1],
+ Key: key,
},
}, nil
}
if sub[0] == "secret" {
return ValueSource{
SecretKeyRef: &corev1.SecretKeySelector{
- LocalObjectReference:
corev1.LocalObjectReference{
- Name: sub[1],
- },
- Key: key,
+ Name: sub[1],
+ Key: key,
},
}, nil
}
diff --git a/pkg/apis/camel/v1/integration_types_support.go
b/pkg/apis/camel/v1/integration_types_support.go
index bae4ee4fc..edab20269 100644
--- a/pkg/apis/camel/v1/integration_types_support.go
+++ b/pkg/apis/camel/v1/integration_types_support.go
@@ -50,23 +50,17 @@ const (
func NewIntegration(namespace string, name string) Integration {
return Integration{
- TypeMeta: metav1.TypeMeta{
- APIVersion: SchemeGroupVersion.String(),
- Kind: IntegrationKind,
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: namespace,
- Name: name,
- },
+ APIVersion: SchemeGroupVersion.String(),
+ Kind: IntegrationKind,
+ Namespace: namespace,
+ Name: name,
}
}
func NewIntegrationList() IntegrationList {
return IntegrationList{
- TypeMeta: metav1.TypeMeta{
- APIVersion: SchemeGroupVersion.String(),
- Kind: IntegrationKind,
- },
+ APIVersion: SchemeGroupVersion.String(),
+ Kind: IntegrationKind,
}
}
@@ -139,10 +133,8 @@ func (in *Integration) OriginalSourcesOnly() []SourceSpec {
if len(in.Spec.Flows) > 0 {
content, _ := ToYamlDSL(in.Spec.Flows)
sources = append(sources, SourceSpec{
- DataSpec: DataSpec{
- Name: IntegrationFlowEmbeddedSourceName,
- Content: string(content),
- },
+ Name: IntegrationFlowEmbeddedSourceName,
+ Content: string(content),
})
}
@@ -270,10 +262,8 @@ func (in *Integration) Configurations()
[]ConfigurationSpec {
func NewSourceSpec(name string, content string, language Language) SourceSpec {
return SourceSpec{
- DataSpec: DataSpec{
- Name: name,
- Content: content,
- },
+ Name: name,
+ Content: content,
Language: language,
}
}
diff --git a/pkg/apis/camel/v1/integrationkit_types_support.go
b/pkg/apis/camel/v1/integrationkit_types_support.go
index b791a1db7..fcae6dfb5 100644
--- a/pkg/apis/camel/v1/integrationkit_types_support.go
+++ b/pkg/apis/camel/v1/integrationkit_types_support.go
@@ -32,23 +32,17 @@ const IntegrationKitLabel =
"camel.apache.org/integrationkit"
func NewIntegrationKit(namespace string, name string) *IntegrationKit {
return &IntegrationKit{
- TypeMeta: metav1.TypeMeta{
- APIVersion: SchemeGroupVersion.String(),
- Kind: IntegrationKitKind,
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: namespace,
- Name: name,
- },
+ APIVersion: SchemeGroupVersion.String(),
+ Kind: IntegrationKitKind,
+ Namespace: namespace,
+ Name: name,
}
}
func NewIntegrationKitList() IntegrationKitList {
return IntegrationKitList{
- TypeMeta: metav1.TypeMeta{
- APIVersion: SchemeGroupVersion.String(),
- Kind: IntegrationKitKind,
- },
+ APIVersion: SchemeGroupVersion.String(),
+ Kind: IntegrationKitKind,
}
}
diff --git a/pkg/apis/camel/v1/integrationplatform_types_support.go
b/pkg/apis/camel/v1/integrationplatform_types_support.go
index 6aaf718a5..36b4916dc 100644
--- a/pkg/apis/camel/v1/integrationplatform_types_support.go
+++ b/pkg/apis/camel/v1/integrationplatform_types_support.go
@@ -27,24 +27,18 @@ import (
// NewIntegrationPlatformList --.
func NewIntegrationPlatformList() IntegrationPlatformList {
return IntegrationPlatformList{
- TypeMeta: metav1.TypeMeta{
- APIVersion: SchemeGroupVersion.String(),
- Kind: IntegrationPlatformKind,
- },
+ APIVersion: SchemeGroupVersion.String(),
+ Kind: IntegrationPlatformKind,
}
}
// NewIntegrationPlatform --.
func NewIntegrationPlatform(namespace string, name string) IntegrationPlatform
{
return IntegrationPlatform{
- TypeMeta: metav1.TypeMeta{
- APIVersion: SchemeGroupVersion.String(),
- Kind: IntegrationPlatformKind,
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: namespace,
- Name: name,
- },
+ APIVersion: SchemeGroupVersion.String(),
+ Kind: IntegrationPlatformKind,
+ Namespace: namespace,
+ Name: name,
}
}
diff --git a/pkg/apis/camel/v1/integrationprofile_types_support.go
b/pkg/apis/camel/v1/integrationprofile_types_support.go
index 011659977..fe899397f 100644
--- a/pkg/apis/camel/v1/integrationprofile_types_support.go
+++ b/pkg/apis/camel/v1/integrationprofile_types_support.go
@@ -25,14 +25,10 @@ import (
// NewIntegrationProfile --.
func NewIntegrationProfile(namespace string, name string) IntegrationProfile {
return IntegrationProfile{
- TypeMeta: metav1.TypeMeta{
- APIVersion: SchemeGroupVersion.String(),
- Kind: IntegrationProfileKind,
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: namespace,
- Name: name,
- },
+ APIVersion: SchemeGroupVersion.String(),
+ Kind: IntegrationProfileKind,
+ Namespace: namespace,
+ Name: name,
}
}
diff --git a/pkg/apis/camel/v1/pipe_types_support.go
b/pkg/apis/camel/v1/pipe_types_support.go
index d66280e9a..d56626196 100644
--- a/pkg/apis/camel/v1/pipe_types_support.go
+++ b/pkg/apis/camel/v1/pipe_types_support.go
@@ -179,23 +179,17 @@ func (p *EndpointProperties) GetPropertyMap()
(map[string]string, error) {
// NewPipe --.
func NewPipe(namespace string, name string) Pipe {
return Pipe{
- TypeMeta: metav1.TypeMeta{
- APIVersion: SchemeGroupVersion.String(),
- Kind: PipeKind,
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: namespace,
- Name: name,
- },
+ APIVersion: SchemeGroupVersion.String(),
+ Kind: PipeKind,
+ Namespace: namespace,
+ Name: name,
}
}
// NewPipeList --.
func NewPipeList() PipeList {
return PipeList{
- TypeMeta: metav1.TypeMeta{
- APIVersion: SchemeGroupVersion.String(),
- Kind: PipeKind,
- },
+ APIVersion: SchemeGroupVersion.String(),
+ Kind: PipeKind,
}
}
diff --git a/pkg/apis/camel/v1/trait/base.go b/pkg/apis/camel/v1/trait/base.go
index bcfc28728..ddc3fb6aa 100644
--- a/pkg/apis/camel/v1/trait/base.go
+++ b/pkg/apis/camel/v1/trait/base.go
@@ -51,4 +51,4 @@ type Configuration struct {
// +kubebuilder:pruning:PreserveUnknownFields
//
// Deprecated: for backward compatibility.
-type RawMessage []byte //nolint: recvcheck
+type RawMessage []byte
diff --git a/pkg/builder/s2i.go b/pkg/builder/s2i.go
index 35408d919..8a01ced13 100644
--- a/pkg/builder/s2i.go
+++ b/pkg/builder/s2i.go
@@ -63,15 +63,11 @@ func (t *s2iTask) Do(ctx context.Context) v1.BuildStatus {
status := initializeStatusFrom(t.build.Status, t.task.BaseImage)
bc := &buildv1.BuildConfig{
- TypeMeta: metav1.TypeMeta{
- APIVersion: buildv1.GroupVersion.String(),
- Kind: "BuildConfig",
- },
- ObjectMeta: metav1.ObjectMeta{
- Name: "camel-k-" + t.build.Name,
- Namespace: t.build.Namespace,
- Labels: t.build.Labels,
- },
+ APIVersion: buildv1.GroupVersion.String(),
+ Kind: "BuildConfig",
+ Name: "camel-k-" + t.build.Name,
+ Namespace: t.build.Namespace,
+ Labels: t.build.Labels,
Spec: buildv1.BuildConfigSpec{
CommonSpec: buildv1.CommonSpec{
Source: buildv1.BuildSource{
@@ -103,15 +99,11 @@ func (t *s2iTask) Do(ctx context.Context) v1.BuildStatus {
}
is := &imagev1.ImageStream{
- TypeMeta: metav1.TypeMeta{
- APIVersion: imagev1.GroupVersion.String(),
- Kind: "ImageStream",
- },
- ObjectMeta: metav1.ObjectMeta{
- Name: "camel-k-" + t.build.Name,
- Namespace: t.build.Namespace,
- Labels: t.build.Labels,
- },
+ APIVersion: imagev1.GroupVersion.String(),
+ Kind: "ImageStream",
+ Name: "camel-k-" + t.build.Name,
+ Namespace: t.build.Namespace,
+ Labels: t.build.Labels,
Spec: imagev1.ImageStreamSpec{
LookupPolicy: imagev1.ImageLookupPolicy{
Local: true,
diff --git a/pkg/builder/steps.go b/pkg/builder/steps.go
index 731edfb54..6c46f760a 100644
--- a/pkg/builder/steps.go
+++ b/pkg/builder/steps.go
@@ -85,7 +85,7 @@ func registerSteps(steps any) {
for i := range v.NumField() {
field := t.Field(i)
- if step, ok := v.Field(i).Interface().(Step); ok {
+ if step, ok := reflect.TypeAssert[Step](v.Field(i)); ok {
id := t.PkgPath() + "/" + field.Name
// Set the fully qualified step ID
reflect.Indirect(v.Field(i).Elem()).FieldByName("StepID").SetString(id)
diff --git a/pkg/client/apply.go b/pkg/client/apply.go
index 7353fcb74..d1ff39a93 100644
--- a/pkg/client/apply.go
+++ b/pkg/client/apply.go
@@ -130,8 +130,7 @@ func isIncompatibleServerError(err error) bool {
}
// 415: Unsupported media type means we're talking to a server which
doesn't
// support server-side apply.
- var serr *k8serrors.StatusError
- if errors.As(err, &serr) {
+ if serr, ok := errors.AsType[*k8serrors.StatusError](err); ok {
return serr.Status().Code == http.StatusUnsupportedMediaType
}
// Non-StatusError means the error isn't because the server is
incompatible.
diff --git a/pkg/cmd/bind.go b/pkg/cmd/bind.go
index 1e775567d..72165c432 100644
--- a/pkg/cmd/bind.go
+++ b/pkg/cmd/bind.go
@@ -34,7 +34,6 @@ import (
"github.com/apache/camel-k/v2/pkg/util/uri"
"github.com/spf13/cobra"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/cli-runtime/pkg/printers"
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -194,10 +193,8 @@ func (o *bindCmdOptions) run(cmd *cobra.Command, args
[]string) error {
name := o.nameFor(source, sink)
pipe := v1.Pipe{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: o.Namespace,
- Name: name,
- },
+ Namespace: o.Namespace,
+ Name: name,
Spec: v1.PipeSpec{
Source: source,
Sink: sink,
diff --git a/pkg/cmd/delete.go b/pkg/cmd/delete.go
index 796ed69e7..459c80ec7 100644
--- a/pkg/cmd/delete.go
+++ b/pkg/cmd/delete.go
@@ -29,7 +29,6 @@ import (
"github.com/apache/camel-k/v2/pkg/util/kubernetes"
"github.com/spf13/cobra"
k8errors "k8s.io/apimachinery/pkg/api/errors"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
)
@@ -99,10 +98,8 @@ func (command *deleteCmdOptions) run(cmd *cobra.Command,
args []string) error {
}
} else if command.DeleteAll {
integrationList := v1.IntegrationList{
- TypeMeta: metav1.TypeMeta{
- APIVersion: v1.SchemeGroupVersion.String(),
- Kind: v1.IntegrationKind,
- },
+ APIVersion: v1.SchemeGroupVersion.String(),
+ Kind: v1.IntegrationKind,
}
err := c.List(command.Context, &integrationList,
k8sclient.InNamespace(command.Namespace))
@@ -148,14 +145,10 @@ func deletePipeIfExists(ctx context.Context, c
client.Client, integration *v1.In
}
binding := v1.Pipe{
- TypeMeta: metav1.TypeMeta{
- Kind: kind,
- APIVersion: v1.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: integration.Namespace,
- Name: name,
- },
+ Kind: kind,
+ APIVersion: v1.SchemeGroupVersion.String(),
+ Namespace: integration.Namespace,
+ Name: name,
}
err := c.Delete(ctx, &binding)
if k8errors.IsNotFound(err) {
diff --git a/pkg/cmd/get.go b/pkg/cmd/get.go
index ed0fc163d..2632cf051 100644
--- a/pkg/cmd/get.go
+++ b/pkg/cmd/get.go
@@ -21,8 +21,6 @@ import (
"fmt"
"text/tabwriter"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-
k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
"github.com/spf13/cobra"
@@ -57,10 +55,8 @@ func (o *getCmdOptions) run(cmd *cobra.Command, args
[]string) error {
}
integrationList := v1.IntegrationList{
- TypeMeta: metav1.TypeMeta{
- APIVersion: v1.SchemeGroupVersion.String(),
- Kind: "Integration",
- },
+ APIVersion: v1.SchemeGroupVersion.String(),
+ Kind: "Integration",
}
namespace := o.Namespace
diff --git a/pkg/cmd/log.go b/pkg/cmd/log.go
index 3ebb3be9c..775ac65e4 100644
--- a/pkg/cmd/log.go
+++ b/pkg/cmd/log.go
@@ -26,7 +26,6 @@ import (
k8slog "github.com/apache/camel-k/v2/pkg/util/kubernetes/log"
"github.com/spf13/cobra"
k8errors "k8s.io/apimachinery/pkg/api/errors"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
)
@@ -74,14 +73,10 @@ func (o *logCmdOptions) run(cmd *cobra.Command, args
[]string) error {
integrationID := args[0]
integration := v1.Integration{
- TypeMeta: metav1.TypeMeta{
- Kind: v1.IntegrationKind,
- APIVersion: v1.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: o.Namespace,
- Name: integrationID,
- },
+ Kind: v1.IntegrationKind,
+ APIVersion: v1.SchemeGroupVersion.String(),
+ Namespace: o.Namespace,
+ Name: integrationID,
}
key := k8sclient.ObjectKey{
Namespace: o.Namespace,
@@ -156,14 +151,10 @@ func (o *logCmdOptions) run(cmd *cobra.Command, args
[]string) error {
}
integrationKit := v1.IntegrationKit{
- TypeMeta: metav1.TypeMeta{
- Kind: v1.IntegrationKitKind,
- APIVersion:
v1.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace:
integration.Status.IntegrationKit.Namespace,
- Name:
integration.Status.IntegrationKit.Name,
- },
+ Kind: v1.IntegrationKitKind,
+ APIVersion: v1.SchemeGroupVersion.String(),
+ Namespace:
integration.Status.IntegrationKit.Namespace,
+ Name:
integration.Status.IntegrationKit.Name,
}
ikKey := k8sclient.ObjectKey{
Namespace:
integration.Status.IntegrationKit.Namespace,
diff --git a/pkg/cmd/run.go b/pkg/cmd/run.go
index dd44cbf3d..f7ab595e3 100644
--- a/pkg/cmd/run.go
+++ b/pkg/cmd/run.go
@@ -38,7 +38,6 @@ import (
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/util/yaml"
"k8s.io/cli-runtime/pkg/printers"
"k8s.io/client-go/kubernetes/scheme"
@@ -671,14 +670,10 @@ func showIntegrationOutput(cmd *cobra.Command,
integration *v1.Integration, outp
func (o *runCmdOptions) getIntegration(cmd *cobra.Command, c client.Client,
namespace, name string) (*v1.Integration, *v1.Integration, error) {
it := &v1.Integration{
- TypeMeta: metav1.TypeMeta{
- Kind: v1.IntegrationKind,
- APIVersion: v1.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: namespace,
- Name: name,
- },
+ Kind: v1.IntegrationKind,
+ APIVersion: v1.SchemeGroupVersion.String(),
+ Namespace: namespace,
+ Name: name,
}
existing := &v1.Integration{}
@@ -754,11 +749,9 @@ func (o *runCmdOptions) resolveSources(cmd *cobra.Command,
sources []string, it
it.Spec.AddFlows(flows...)
} else {
it.Spec.AddSources(v1.SourceSpec{
- DataSpec: v1.DataSpec{
- Name: source.Name,
- Content: source.Content,
- Compression: source.Compress,
- },
+ Name: source.Name,
+ Content: source.Content,
+ Compression: source.Compress,
})
}
}
diff --git a/pkg/cmd/util.go b/pkg/cmd/util.go
index 865aa342e..ba5807d8f 100644
--- a/pkg/cmd/util.go
+++ b/pkg/cmd/util.go
@@ -37,7 +37,6 @@ import (
"github.com/spf13/viper"
p "github.com/gertd/go-pluralize"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
const (
@@ -47,14 +46,10 @@ const (
// DeleteIntegration --.
func DeleteIntegration(ctx context.Context, c client.Client, name string,
namespace string) error {
integration := v1.Integration{
- TypeMeta: metav1.TypeMeta{
- Kind: v1.IntegrationKind,
- APIVersion: v1.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: namespace,
- Name: name,
- },
+ Kind: v1.IntegrationKind,
+ APIVersion: v1.SchemeGroupVersion.String(),
+ Namespace: namespace,
+ Name: name,
}
return c.Delete(ctx, &integration)
diff --git a/pkg/controller/build/build_pod.go
b/pkg/controller/build/build_pod.go
index b673fad45..c885752a7 100644
--- a/pkg/controller/build/build_pod.go
+++ b/pkg/controller/build/build_pod.go
@@ -24,7 +24,6 @@ import (
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"
@@ -58,19 +57,15 @@ func newBuildPod(ctx context.Context, client client.Client,
build *v1.Build) *co
}
}
pod := &corev1.Pod{
- TypeMeta: metav1.TypeMeta{
- APIVersion: corev1.SchemeGroupVersion.String(),
- Kind: "Pod",
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: build.Namespace,
- Name: buildPodName(build),
- Labels: map[string]string{
- "camel.apache.org/build": build.Name,
- "camel.apache.org/component": "builder",
- },
- Annotations: build.BuilderConfiguration().Annotations,
+ APIVersion: corev1.SchemeGroupVersion.String(),
+ Kind: "Pod",
+ Namespace: build.Namespace,
+ Name: buildPodName(build),
+ Labels: map[string]string{
+ "camel.apache.org/build": build.Name,
+ "camel.apache.org/component": "builder",
},
+ Annotations: build.BuilderConfiguration().Annotations,
Spec: corev1.PodSpec{
ServiceAccountName: platform.BuilderServiceAccount,
RestartPolicy: corev1.RestartPolicyNever,
@@ -148,14 +143,10 @@ func configureResources(taskName string, build *v1.Build,
container *corev1.Cont
func deleteBuilderPod(ctx context.Context, c ctrl.Writer, build *v1.Build)
error {
pod := corev1.Pod{
- TypeMeta: metav1.TypeMeta{
- APIVersion: corev1.SchemeGroupVersion.String(),
- Kind: "Pod",
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: build.Namespace,
- Name: buildPodName(build),
- },
+ APIVersion: corev1.SchemeGroupVersion.String(),
+ Kind: "Pod",
+ Namespace: build.Namespace,
+ Name: buildPodName(build),
}
err := c.Delete(ctx, &pod)
@@ -188,10 +179,8 @@ func addBuildTaskToPod(ctx context.Context, client
client.Client, build *v1.Buil
pod.Spec.Volumes = append(pod.Spec.Volumes,
// EmptyDir volume used to share the build state across
tasks
corev1.Volume{
- Name: builderVolume,
- VolumeSource: corev1.VolumeSource{
- EmptyDir:
&corev1.EmptyDirVolumeSource{},
- },
+ Name: builderVolume,
+ EmptyDir: &corev1.EmptyDirVolumeSource{},
},
)
}
@@ -211,10 +200,8 @@ func addBuildTaskToPod(ctx context.Context, client
client.Client, build *v1.Buil
Name: registry.RegistrySecretConfEnvVar,
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &corev1.SecretKeySelector{
- LocalObjectReference:
corev1.LocalObjectReference{
- Name:
registrySecretName,
- },
- Key:
registry.RegistryDockerConfFilename,
+ Name: registrySecretName,
+ Key:
registry.RegistryDockerConfFilename,
},
},
},
diff --git a/pkg/controller/integration/build.go
b/pkg/controller/integration/build.go
index 8ce975398..b01cff87d 100644
--- a/pkg/controller/integration/build.go
+++ b/pkg/controller/integration/build.go
@@ -135,16 +135,12 @@ func (action *buildAction) createBuild(ctx
context.Context, it *v1.Integration)
}
build := &v1.Build{
- TypeMeta: metav1.TypeMeta{
- APIVersion: v1.SchemeGroupVersion.String(),
- Kind: v1.BuildKind,
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: it.Namespace,
- Name: it.Name,
- Labels: labels,
- Annotations: annotations,
- },
+ APIVersion: v1.SchemeGroupVersion.String(),
+ Kind: v1.BuildKind,
+ Namespace: it.Namespace,
+ Name: it.Name,
+ Labels: labels,
+ Annotations: annotations,
Spec: v1.BuildSpec{
Tasks: env.Pipeline,
Timeout: metav1.Duration{Duration: timeout},
@@ -245,16 +241,12 @@ func (action *buildAction) handleBuildRunning(ctx
context.Context, it *v1.Integr
// createBuilderServiceAccount creates the builder SA in the ns namespace.
func (action *buildAction) createBuilderServiceAccount(ctx context.Context, ns
string) error {
sa := &corev1.ServiceAccount{
- TypeMeta: metav1.TypeMeta{
- Kind: "ServiceAccount",
- APIVersion: corev1.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: ns,
- Name: platform.BuilderServiceAccount,
- Labels: map[string]string{
- "app": "camel-k",
- },
+ Kind: "ServiceAccount",
+ APIVersion: corev1.SchemeGroupVersion.String(),
+ Namespace: ns,
+ Name: platform.BuilderServiceAccount,
+ Labels: map[string]string{
+ "app": "camel-k",
},
}
action.L.Infof("Creating %s ServiceAccount in namespace %s", sa.Name,
sa.Namespace)
@@ -265,16 +257,12 @@ func (action *buildAction)
createBuilderServiceAccount(ctx context.Context, ns s
// createBuilderRole creates the builder role in the ns namespace.
func (action *buildAction) createBuilderRole(ctx context.Context, ns string)
error {
r := &rbacv1.Role{
- TypeMeta: metav1.TypeMeta{
- Kind: "Role",
- APIVersion: corev1.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: ns,
- Name: platform.BuilderServiceAccount,
- Labels: map[string]string{
- "app": "camel-k",
- },
+ Kind: "Role",
+ APIVersion: corev1.SchemeGroupVersion.String(),
+ Namespace: ns,
+ Name: platform.BuilderServiceAccount,
+ Labels: map[string]string{
+ "app": "camel-k",
},
Rules: []rbacv1.PolicyRule{
{
@@ -297,16 +285,12 @@ func (action *buildAction) createBuilderRole(ctx
context.Context, ns string) err
// createBuilderRole creates the builder role in the ns namespace.
func (action *buildAction) createBuilderRoleBinding(ctx context.Context, ns
string) error {
rb := &rbacv1.RoleBinding{
- TypeMeta: metav1.TypeMeta{
- Kind: "RoleBinding",
- APIVersion: rbacv1.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: ns,
- Name: platform.BuilderServiceAccount,
- Labels: map[string]string{
- "app": "camel-k",
- },
+ Kind: "RoleBinding",
+ APIVersion: rbacv1.SchemeGroupVersion.String(),
+ Namespace: ns,
+ Name: platform.BuilderServiceAccount,
+ Labels: map[string]string{
+ "app": "camel-k",
},
Subjects: []rbacv1.Subject{
{
diff --git a/pkg/controller/integration/integration_controller.go
b/pkg/controller/integration/integration_controller.go
index 387502ba1..ebb276c21 100644
--- a/pkg/controller/integration/integration_controller.go
+++ b/pkg/controller/integration/integration_controller.go
@@ -29,7 +29,6 @@ import (
k8serrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
- "k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/tools/events"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/builder"
@@ -174,10 +173,8 @@ func integrationKitEnqueueRequestsFromMapFunc(ctx
context.Context, c client.Clie
log.Infof("Kit %s ready, notify integration: %s", kit.Name,
integration.Name)
requests = append(requests, reconcile.Request{
- NamespacedName: types.NamespacedName{
- Namespace: integration.Namespace,
- Name: integration.Name,
- },
+ Namespace: integration.Namespace,
+ Name: integration.Name,
})
}
@@ -239,10 +236,8 @@ func enqueueRequestsFromConfigFunc(ctx context.Context, c
client.Client, res ctr
if found {
log.Infof("%s %s updated, wake-up integration: %s",
res.GetObjectKind(), res.GetName(), integration.Name)
requests = append(requests, reconcile.Request{
- NamespacedName: types.NamespacedName{
- Namespace: integration.Namespace,
- Name: integration.Name,
- },
+ Namespace: integration.Namespace,
+ Name: integration.Name,
})
}
}
@@ -273,10 +268,8 @@ func integrationPlatformEnqueueRequestsFromMapFunc(ctx
context.Context, c client
if integration.Status.Phase ==
v1.IntegrationPhaseWaitingForPlatform {
log.Infof("Platform %s ready, wake-up
integration: %s", p.Name, integration.Name)
requests = append(requests, reconcile.Request{
- NamespacedName: types.NamespacedName{
- Namespace:
integration.Namespace,
- Name: integration.Name,
- },
+ Namespace: integration.Namespace,
+ Name: integration.Name,
})
}
}
@@ -400,10 +393,8 @@ func watchIntegrationResources(c client.Client, b
*builder.Builder) {
return []reconcile.Request{
{
- NamespacedName:
types.NamespacedName{
- Namespace:
pod.GetNamespace(),
- Name:
pod.Labels[v1.IntegrationLabel],
- },
+ Namespace: pod.GetNamespace(),
+ Name:
pod.Labels[v1.IntegrationLabel],
},
}
})).
diff --git a/pkg/controller/integration/monitor.go
b/pkg/controller/integration/monitor.go
index e7f56661d..0c4ae4072 100644
--- a/pkg/controller/integration/monitor.go
+++ b/pkg/controller/integration/monitor.go
@@ -44,7 +44,6 @@ import (
"github.com/apache/camel-k/v2/pkg/util/digest"
"github.com/apache/camel-k/v2/pkg/util/kubernetes"
utilResource "github.com/apache/camel-k/v2/pkg/util/resource"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// NewMonitorAction is an action used to monitor manager Integrations.
@@ -325,26 +324,18 @@ func getIntegrationSecretAndConfigmapResourceVersions(ctx
context.Context, clien
if conf, parseErr := utilResource.ParseConfig(c);
parseErr == nil {
if conf.StorageType() ==
utilResource.StorageTypeConfigmap {
cm := corev1.ConfigMap{
- TypeMeta: metav1.TypeMeta{
- Kind:
corev1.ResourceConfigMaps.String(),
- APIVersion:
corev1.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace:
integration.Namespace,
- Name: conf.Name(),
- },
+ Kind:
corev1.ResourceConfigMaps.String(),
+ APIVersion:
corev1.SchemeGroupVersion.String(),
+ Namespace:
integration.Namespace,
+ Name: conf.Name(),
}
configmaps = append(configmaps,
kubernetes.LookupResourceVersion(ctx, client, &cm))
} else if conf.StorageType() ==
utilResource.StorageTypeSecret {
sec := corev1.Secret{
- TypeMeta: metav1.TypeMeta{
- Kind:
corev1.ResourceSecrets.String(),
- APIVersion:
corev1.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace:
integration.Namespace,
- Name: conf.Name(),
- },
+ Kind:
corev1.ResourceSecrets.String(),
+ APIVersion:
corev1.SchemeGroupVersion.String(),
+ Namespace:
integration.Namespace,
+ Name: conf.Name(),
}
secrets = append(secrets,
kubernetes.LookupResourceVersion(ctx, client, &sec))
}
diff --git a/pkg/controller/integrationkit/build.go
b/pkg/controller/integrationkit/build.go
index 95414a095..371fc4d45 100644
--- a/pkg/controller/integrationkit/build.go
+++ b/pkg/controller/integrationkit/build.go
@@ -149,16 +149,12 @@ func (action *buildAction) createBuild(ctx
context.Context, kit *v1.IntegrationK
v1.SetBuilderConfigurationTasks(env.Pipeline, buildConfig)
build := &v1.Build{
- TypeMeta: metav1.TypeMeta{
- APIVersion: v1.SchemeGroupVersion.String(),
- Kind: v1.BuildKind,
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: kit.Namespace,
- Name: kit.Name,
- Labels: labels,
- Annotations: annotations,
- },
+ APIVersion: v1.SchemeGroupVersion.String(),
+ Kind: v1.BuildKind,
+ Namespace: kit.Namespace,
+ Name: kit.Name,
+ Labels: labels,
+ Annotations: annotations,
Spec: v1.BuildSpec{
Tasks: env.Pipeline,
},
diff --git a/pkg/controller/integrationkit/integrationkit_controller.go
b/pkg/controller/integrationkit/integrationkit_controller.go
index 12c9c171d..7b0b23344 100644
--- a/pkg/controller/integrationkit/integrationkit_controller.go
+++ b/pkg/controller/integrationkit/integrationkit_controller.go
@@ -24,7 +24,6 @@ import (
k8serrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
- "k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/tools/events"
ctrl "sigs.k8s.io/controller-runtime/pkg/client"
@@ -163,10 +162,8 @@ func add(_ context.Context, mgr manager.Manager, r
reconcile.Reconciler) error {
if kit.Status.Phase ==
v1.IntegrationKitPhaseWaitingForPlatform {
log.Infof("Platform %s
ready, wake-up integration kit: %s", itp.Name, kit.Name)
requests =
append(requests, reconcile.Request{
- NamespacedName:
types.NamespacedName{
-
Namespace: kit.Namespace,
- Name:
kit.Name,
- },
+ Namespace:
kit.Namespace,
+ Name:
kit.Name,
})
}
}
diff --git a/pkg/controller/pipe/integration.go
b/pkg/controller/pipe/integration.go
index 825953693..8c6bc31f4 100644
--- a/pkg/controller/pipe/integration.go
+++ b/pkg/controller/pipe/integration.go
@@ -61,20 +61,18 @@ func CreateIntegrationFor(ctx context.Context, c
client.Client, pipe *v1.Pipe) (
}
it := v1.Integration{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: pipe.Namespace,
- Name: pipe.Name,
- Annotations: annotations,
- Labels: util.CopyMap(pipe.Labels),
- OwnerReferences: []metav1.OwnerReference{
- {
- APIVersion: pipe.APIVersion,
- Kind: pipe.Kind,
- Name: pipe.Name,
- UID: pipe.UID,
- Controller: &controller,
- BlockOwnerDeletion: &blockOwnerDeletion,
- },
+ Namespace: pipe.Namespace,
+ Name: pipe.Name,
+ Annotations: annotations,
+ Labels: util.CopyMap(pipe.Labels),
+ OwnerReferences: []metav1.OwnerReference{
+ {
+ APIVersion: pipe.APIVersion,
+ Kind: pipe.Kind,
+ Name: pipe.Name,
+ UID: pipe.UID,
+ Controller: &controller,
+ BlockOwnerDeletion: &blockOwnerDeletion,
},
},
}
diff --git a/pkg/install/openshift.go b/pkg/install/openshift.go
index c133fb18c..cacb23092 100644
--- a/pkg/install/openshift.go
+++ b/pkg/install/openshift.go
@@ -25,7 +25,6 @@ import (
"github.com/Masterminds/semver"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
console "github.com/openshift/api/console/v1"
@@ -118,12 +117,10 @@ func OpenShiftConsoleDownloadLink(ctx context.Context, c
client.Client) error {
// Create the ConsoleCLIDownload for Kamel CLI
link := console.ConsoleCLIDownload{
- ObjectMeta: metav1.ObjectMeta{
- Annotations: map[string]string{
- kamelVersionAnnotation: defaults.Version,
- },
- Name: KamelCLIDownloadName,
+ Annotations: map[string]string{
+ kamelVersionAnnotation: defaults.Version,
},
+ Name: KamelCLIDownloadName,
Spec: console.ConsoleCLIDownloadSpec{
DisplayName: KamelCLIDownloadDisplayName,
Description: KamelCLIDownloadDescription,
diff --git a/pkg/internal/client.go b/pkg/internal/client.go
index 48ffe359e..94aea9415 100644
--- a/pkg/internal/client.go
+++ b/pkg/internal/client.go
@@ -95,10 +95,8 @@ func NewFakeClient(initObjs ...runtime.Object)
(client.Client, error) {
replicasCount[key] = replicas
return true, &autoscalingv1.Scale{
- ObjectMeta: metav1.ObjectMeta{
- Name: obj.Name,
- Namespace: action.GetNamespace(),
- },
+ Name: obj.Name,
+ Namespace: action.GetNamespace(),
Spec: autoscalingv1.ScaleSpec{
Replicas: replicas,
},
@@ -110,10 +108,8 @@ func NewFakeClient(initObjs ...runtime.Object)
(client.Client, error) {
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(),
- },
+ Name: action.GetName(),
+ Namespace: action.GetNamespace(),
Spec: autoscalingv1.ScaleSpec{
Replicas: replicasCount[key],
},
diff --git a/pkg/platform/defaults.go b/pkg/platform/defaults.go
index 22538128e..1fce3af66 100644
--- a/pkg/platform/defaults.go
+++ b/pkg/platform/defaults.go
@@ -386,12 +386,10 @@ func setStatusAdditionalInfo(platform
*v1.IntegrationPlatform) {
//nolint:staticcheck
func createServiceCaBundleConfigMap(ctx context.Context, client client.Client,
p *v1.IntegrationPlatform) (*corev1.ConfigMap, error) {
cm := &corev1.ConfigMap{
- ObjectMeta: metav1.ObjectMeta{
- Name: BuilderServiceAccount + "-ca",
- Namespace: p.Namespace,
- Annotations: map[string]string{
- "service.beta.openshift.io/inject-cabundle":
"true",
- },
+ Name: BuilderServiceAccount + "-ca",
+ Namespace: p.Namespace,
+ Annotations: map[string]string{
+ "service.beta.openshift.io/inject-cabundle": "true",
},
}
@@ -406,10 +404,8 @@ func createServiceCaBundleConfigMap(ctx context.Context,
client client.Client, p
//nolint:staticcheck
func createBuilderRegistryRoleBinding(ctx context.Context, client
client.Client, p *v1.IntegrationPlatform) error {
rb := &rbacv1.RoleBinding{
- ObjectMeta: metav1.ObjectMeta{
- Name: BuilderServiceAccount + "-registry",
- Namespace: p.Namespace,
- },
+ Name: BuilderServiceAccount + "-registry",
+ Namespace: p.Namespace,
Subjects: []rbacv1.Subject{
{
Kind: "ServiceAccount",
diff --git a/pkg/platform/env_platform.go b/pkg/platform/env_platform.go
index 5d4926cf5..a5e56a49a 100644
--- a/pkg/platform/env_platform.go
+++ b/pkg/platform/env_platform.go
@@ -354,17 +354,13 @@ func valueSource(envName string) (v1.ValueSource, error) {
switch kind {
case "configmap":
valueSource.ConfigMapKeyRef =
&corev1.ConfigMapKeySelector{
- LocalObjectReference:
corev1.LocalObjectReference{
- Name: name,
- },
- Key: key,
+ Name: name,
+ Key: key,
}
case "secret":
valueSource.SecretKeyRef = &corev1.SecretKeySelector{
- LocalObjectReference:
corev1.LocalObjectReference{
- Name: name,
- },
- Key: key,
+ Name: name,
+ Key: key,
}
default:
return valueSource, errors.New("invalid value source
format: unsupported " + kind)
@@ -388,10 +384,8 @@ func caSecrets() []corev1.SecretKeySelector {
continue
}
caSecrets = append(caSecrets, corev1.SecretKeySelector{
- LocalObjectReference:
corev1.LocalObjectReference{
- Name: subparts[0],
- },
- Key: subparts[1],
+ Name: subparts[0],
+ Key: subparts[1],
})
}
}
diff --git a/pkg/trait/builder.go b/pkg/trait/builder.go
index e2bf4aab1..1eb47b9eb 100644
--- a/pkg/trait/builder.go
+++ b/pkg/trait/builder.go
@@ -289,15 +289,11 @@ func (t *builderTrait) Apply(e *Environment) error {
switch e.Platform.PublishStrategy {
case v1.IntegrationPlatformBuildPublishStrategyJib:
jibTask := v1.Task{Jib: &v1.JibTask{
- BaseTask: v1.BaseTask{
- Name: "jib",
- Configuration: *taskConfOrDefault(tasksConf,
"jib"),
- },
- PublishTask: v1.PublishTask{
- BaseImage: t.getBaseImage(e),
- Image: imageName,
- Registry: e.Platform.Registry,
- },
+ Name: "jib",
+ Configuration: *taskConfOrDefault(tasksConf, "jib"),
+ BaseImage: t.getBaseImage(e),
+ Image: imageName,
+ Registry: e.Platform.Registry,
}}
if t.ImagePlatforms != nil {
jibTask.Jib.Configuration.ImagePlatforms =
t.ImagePlatforms
@@ -306,15 +302,11 @@ func (t *builderTrait) Apply(e *Environment) error {
//nolint:staticcheck
case v1.IntegrationPlatformBuildPublishStrategyS2I:
pipelineTasks = append(pipelineTasks, v1.Task{S2i: &v1.S2iTask{
- BaseTask: v1.BaseTask{
- Name: "s2i",
- Configuration: *taskConfOrDefault(tasksConf,
"s2i"),
- },
- PublishTask: v1.PublishTask{
- BaseImage: t.getBaseImage(e),
- Image: imageName,
- },
- Tag: tag,
+ Name: "s2i",
+ Configuration: *taskConfOrDefault(tasksConf, "s2i"),
+ BaseImage: t.getBaseImage(e),
+ Image: imageName,
+ Tag: tag,
}})
}
@@ -434,14 +426,12 @@ func (t *builderTrait) builderTask(e *Environment,
taskConf *v1.BuildConfigurati
dependencies := getDependencies(e)
task := &v1.BuilderTask{
- BaseTask: v1.BaseTask{
- Name: "builder",
- Configuration: *taskConf,
- },
- BaseImage: t.getBaseImage(e),
- Runtime: e.CamelCatalog.Runtime,
- Dependencies: dependencies,
- Maven: maven,
+ Name: "builder",
+ Configuration: *taskConf,
+ BaseImage: t.getBaseImage(e),
+ Runtime: e.CamelCatalog.Runtime,
+ Dependencies: dependencies,
+ Maven: maven,
}
if e.Integration != nil && e.Integration.Spec.Git != nil {
@@ -573,10 +563,8 @@ func parseTask(task string, tasksConf
map[string]*v1.BuildConfiguration, imageNa
}
parsedTask := v1.Task{
Custom: &v1.UserTask{
- BaseTask: v1.BaseTask{
- Name: splitted[0],
- Configuration: *taskConfOrDefault(tasksConf,
splitted[0]),
- },
+ Name: splitted[0],
+ Configuration: *taskConfOrDefault(tasksConf,
splitted[0]),
PublishingImage: imageName,
ContainerImage: splitted[1],
ContainerCommands: splitContainerCommand(splitted[2]),
diff --git a/pkg/trait/camel.go b/pkg/trait/camel.go
index 8fc6e14f5..75a05fe3c 100644
--- a/pkg/trait/camel.go
+++ b/pkg/trait/camel.go
@@ -26,7 +26,6 @@ import (
"time"
corev1 "k8s.io/api/core/v1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
ctrl "sigs.k8s.io/controller-runtime/pkg/client"
@@ -336,18 +335,14 @@ func (t *camelTrait) computeUserProperties(e
*Environment) []ctrl.Object {
maps = append(
maps,
&corev1.ConfigMap{
- TypeMeta: metav1.TypeMeta{
- Kind: "ConfigMap",
- APIVersion: "v1",
- },
- ObjectMeta: metav1.ObjectMeta{
- Name: e.Integration.Name +
"-user-properties",
- Namespace: e.Integration.Namespace,
- Labels: map[string]string{
- v1.IntegrationLabel:
e.Integration.Name,
-
"camel.apache.org/properties.type": "user",
- kubernetes.ConfigMapTypeLabel:
CamelPropertiesType,
- },
+ Kind: "ConfigMap",
+ APIVersion: "v1",
+ Name: e.Integration.Name +
"-user-properties",
+ Namespace: e.Integration.Namespace,
+ Labels: map[string]string{
+ v1.IntegrationLabel:
e.Integration.Name,
+ "camel.apache.org/properties.type":
"user",
+ kubernetes.ConfigMapTypeLabel:
CamelPropertiesType,
},
Data: map[string]string{
"application.properties":
userProperties,
@@ -363,22 +358,18 @@ func (t *camelTrait) computeUserProperties(e
*Environment) []ctrl.Object {
}
cm := corev1.ConfigMap{
- TypeMeta: metav1.TypeMeta{
- Kind: "ConfigMap",
- APIVersion: "v1",
+ Kind: "ConfigMap",
+ APIVersion: "v1",
+ Name: fmt.Sprintf("%s-source-%03d",
e.Integration.Name, i),
+ Namespace: e.Integration.Namespace,
+ Labels: map[string]string{
+ v1.IntegrationLabel: e.Integration.Name,
},
- ObjectMeta: metav1.ObjectMeta{
- Name: fmt.Sprintf("%s-source-%03d",
e.Integration.Name, i),
- Namespace: e.Integration.Namespace,
- Labels: map[string]string{
- v1.IntegrationLabel: e.Integration.Name,
- },
- Annotations: map[string]string{
- sourceLanguageAnnotation:
string(s.InferLanguage()),
- sourceLoaderAnnotation: s.Loader,
- sourceNameAnnotation: s.Name,
- sourceCompressionAnnotation:
strconv.FormatBool(s.Compression),
- },
+ Annotations: map[string]string{
+ sourceLanguageAnnotation:
string(s.InferLanguage()),
+ sourceLoaderAnnotation: s.Loader,
+ sourceNameAnnotation: s.Name,
+ sourceCompressionAnnotation:
strconv.FormatBool(s.Compression),
},
Data: map[string]string{
"content": s.Content,
diff --git a/pkg/trait/cron.go b/pkg/trait/cron.go
index 375432a6e..25b9f33a2 100644
--- a/pkg/trait/cron.go
+++ b/pkg/trait/cron.go
@@ -260,16 +260,12 @@ func (t *cronTrait) getCronJobFor(e *Environment)
*batchv1.CronJob {
backoffLimit = *t.BackoffLimit
}
cronjob := batchv1.CronJob{
- TypeMeta: metav1.TypeMeta{
- Kind: "CronJob",
- APIVersion: batchv1.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Name: e.Integration.Name,
- Namespace: e.Integration.Namespace,
- Labels:
kubernetes.DeploymentLabels(e.Integration.Name),
- Annotations: e.Integration.Annotations,
- },
+ Kind: "CronJob",
+ APIVersion: batchv1.SchemeGroupVersion.String(),
+ Name: e.Integration.Name,
+ Namespace: e.Integration.Namespace,
+ Labels: kubernetes.DeploymentLabels(e.Integration.Name),
+ Annotations: e.Integration.Annotations,
Spec: batchv1.CronJobSpec{
Schedule: t.Schedule,
TimeZone: t.TimeZone,
diff --git a/pkg/trait/deployment.go b/pkg/trait/deployment.go
index c4920f763..fae4e175b 100644
--- a/pkg/trait/deployment.go
+++ b/pkg/trait/deployment.go
@@ -128,16 +128,12 @@ func (t *deploymentTrait) getDeploymentFor(e
*Environment) *appsv1.Deployment {
}
deployment := appsv1.Deployment{
- TypeMeta: metav1.TypeMeta{
- Kind: "Deployment",
- APIVersion: appsv1.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Name: e.Integration.Name,
- Namespace: e.Integration.Namespace,
- Labels:
kubernetes.DeploymentLabels(e.Integration.Name),
- Annotations: annotations,
- },
+ Kind: "Deployment",
+ APIVersion: appsv1.SchemeGroupVersion.String(),
+ Name: e.Integration.Name,
+ Namespace: e.Integration.Namespace,
+ Labels: kubernetes.DeploymentLabels(e.Integration.Name),
+ Annotations: annotations,
Spec: appsv1.DeploymentSpec{
ProgressDeadlineSeconds: &deadline,
Replicas: e.Integration.Spec.Replicas,
diff --git a/pkg/trait/gateway.go b/pkg/trait/gateway.go
index adb5e9ceb..fc64b78d7 100644
--- a/pkg/trait/gateway.go
+++ b/pkg/trait/gateway.go
@@ -26,7 +26,6 @@ import (
v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
traitv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1/trait"
corev1 "k8s.io/api/core/v1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
gwv1 "sigs.k8s.io/gateway-api/apis/v1"
)
@@ -132,14 +131,10 @@ func buildGateway(name, namespace, className string,
listeners []string) (*gwv1.
}
return &gwv1.Gateway{
- TypeMeta: metav1.TypeMeta{
- APIVersion: gwv1.GroupVersion.String(),
- Kind: "Gateway",
- },
- ObjectMeta: metav1.ObjectMeta{
- Name: name,
- Namespace: namespace,
- },
+ APIVersion: gwv1.GroupVersion.String(),
+ Kind: "Gateway",
+ Name: name,
+ Namespace: namespace,
Spec: gwv1.GatewaySpec{
GatewayClassName: gwv1.ObjectName(className),
Listeners: gwListeners,
@@ -159,12 +154,8 @@ func buildHTTPRoute(routeName, gatewayName, serviceName,
namespace string, servi
rule := gwv1.HTTPRouteRule{
BackendRefs: []gwv1.HTTPBackendRef{
{
- BackendRef: gwv1.BackendRef{
- BackendObjectReference:
gwv1.BackendObjectReference{
- Name:
gwv1.ObjectName(serviceName),
- Port: new(p),
- },
- },
+ Name: gwv1.ObjectName(serviceName),
+ Port: new(p),
},
},
}
@@ -173,14 +164,10 @@ func buildHTTPRoute(routeName, gatewayName, serviceName,
namespace string, servi
}
return &gwv1.HTTPRoute{
- TypeMeta: metav1.TypeMeta{
- APIVersion: gwv1.GroupVersion.String(),
- Kind: "HTTPRoute",
- },
- ObjectMeta: metav1.ObjectMeta{
- Name: routeName,
- Namespace: namespace,
- },
+ APIVersion: gwv1.GroupVersion.String(),
+ Kind: "HTTPRoute",
+ Name: routeName,
+ Namespace: namespace,
Spec: gwv1.HTTPRouteSpec{
CommonRouteSpec: gwv1.CommonRouteSpec{
ParentRefs: []gwv1.ParentReference{
diff --git a/pkg/trait/health.go b/pkg/trait/health.go
index 5f95c5478..0187dc68b 100644
--- a/pkg/trait/health.go
+++ b/pkg/trait/health.go
@@ -283,12 +283,10 @@ func newProbe(
initialDelay, timeout, period, success, failure int32,
) *corev1.Probe {
return &corev1.Probe{
- ProbeHandler: corev1.ProbeHandler{
- HTTPGet: &corev1.HTTPGetAction{
- Path: path,
- Scheme: scheme,
- Port: *resolverPort,
- },
+ HTTPGet: &corev1.HTTPGetAction{
+ Path: path,
+ Scheme: scheme,
+ Port: *resolverPort,
},
InitialDelaySeconds: initialDelay,
TimeoutSeconds: timeout,
diff --git a/pkg/trait/ingress.go b/pkg/trait/ingress.go
index 8f3e4505f..943b7b1e7 100644
--- a/pkg/trait/ingress.go
+++ b/pkg/trait/ingress.go
@@ -25,7 +25,6 @@ import (
traitv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1/trait"
corev1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
)
@@ -105,23 +104,17 @@ func (t *ingressTrait) Apply(e *Environment) error {
}
ingress := networkingv1.Ingress{
- TypeMeta: metav1.TypeMeta{
- Kind: "Ingress",
- APIVersion: networkingv1.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Name: service.Name,
- Namespace: service.Namespace,
- Annotations: t.Annotations,
- },
+ Kind: "Ingress",
+ APIVersion: networkingv1.SchemeGroupVersion.String(),
+ Name: service.Name,
+ Namespace: service.Namespace,
+ Annotations: t.Annotations,
Spec: networkingv1.IngressSpec{
Rules: []networkingv1.IngressRule{
{
Host: t.Host,
- IngressRuleValue:
networkingv1.IngressRuleValue{
- HTTP:
&networkingv1.HTTPIngressRuleValue{
- Paths:
t.getPaths(service),
- },
+ HTTP:
&networkingv1.HTTPIngressRuleValue{
+ Paths: t.getPaths(service),
},
},
},
diff --git a/pkg/trait/init.go b/pkg/trait/init.go
index 9a1f0e46d..369a752ff 100644
--- a/pkg/trait/init.go
+++ b/pkg/trait/init.go
@@ -59,10 +59,8 @@ func (t *initTrait) Apply(e *Environment) error {
return err
}
e.Integration.Status.AddOrReplaceGeneratedSources(v1.SourceSpec{
- DataSpec: v1.DataSpec{
- Name: v1.IntegrationFlowEmbeddedSourceName,
- Content: string(content),
- },
+ Name: v1.IntegrationFlowEmbeddedSourceName,
+ Content: string(content),
})
}
diff --git a/pkg/trait/kamelets.go b/pkg/trait/kamelets.go
index e9ffa226f..a2b421f96 100644
--- a/pkg/trait/kamelets.go
+++ b/pkg/trait/kamelets.go
@@ -27,7 +27,6 @@ import (
"strings"
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"
@@ -322,10 +321,8 @@ func (t *kameletsTrait) addKameletAsSource(e *Environment,
kamelet *v1.Kamelet)
return err
}
flowSource := v1.SourceSpec{
- DataSpec: v1.DataSpec{
- Name: kamelet.Name + ".yaml",
- Content: string(flowData),
- },
+ Name: kamelet.Name + ".yaml",
+ Content: string(flowData),
Language: v1.LanguageYaml,
}
flowSource, err = integrationSourceFromKameletSource(e,
kamelet, flowSource, fmt.Sprintf("%s-kamelet-%s-template", e.Integration.Name,
kamelet.Name))
@@ -445,25 +442,21 @@ func integrationSourceFromKameletSource(e *Environment,
kamelet *v1.Kamelet, sou
func initializeConfigmapKameletSource(source v1.SourceSpec, hash, name,
namespace, itName, kamName string) corev1.ConfigMap {
return corev1.ConfigMap{
- TypeMeta: metav1.TypeMeta{
- Kind: "ConfigMap",
- APIVersion: "v1",
+ Kind: "ConfigMap",
+ APIVersion: "v1",
+ Name: name,
+ Namespace: namespace,
+ Labels: map[string]string{
+ "camel.apache.org/integration": itName,
+ "camel.apache.org/kamelet": kamName,
},
- ObjectMeta: metav1.ObjectMeta{
- Name: name,
- Namespace: namespace,
- Labels: map[string]string{
- "camel.apache.org/integration": itName,
- "camel.apache.org/kamelet": kamName,
- },
- Annotations: map[string]string{
- sourceLanguageAnnotation:
string(source.Language),
- sourceNameAnnotation: name,
- sourceCompressionAnnotation:
strconv.FormatBool(source.Compression),
- "camel.apache.org/source.generated":
boolean.TrueString,
- "camel.apache.org/source.type":
string(source.Type),
- "camel.apache.org/source.digest": hash,
- },
+ Annotations: map[string]string{
+ sourceLanguageAnnotation:
string(source.Language),
+ sourceNameAnnotation: name,
+ sourceCompressionAnnotation:
strconv.FormatBool(source.Compression),
+ "camel.apache.org/source.generated": boolean.TrueString,
+ "camel.apache.org/source.type":
string(source.Type),
+ "camel.apache.org/source.digest": hash,
},
Data: map[string]string{
contentKey: source.Content,
diff --git a/pkg/trait/kamelets_support.go b/pkg/trait/kamelets_support.go
index af02dd09d..187c7aa16 100644
--- a/pkg/trait/kamelets_support.go
+++ b/pkg/trait/kamelets_support.go
@@ -25,7 +25,6 @@ import (
"github.com/apache/camel-k/v2/pkg/util/boolean"
"github.com/apache/camel-k/v2/pkg/util/kubernetes"
corev1 "k8s.io/api/core/v1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
const KameletBundleType = "kamelets-bundle"
@@ -74,20 +73,16 @@ func (kb *kameletBundle) toConfigmaps(itName, itNamespace
string) ([]*corev1.Con
func newBundleConfigmap(name, namespace string, id int) *corev1.ConfigMap {
return &corev1.ConfigMap{
- TypeMeta: metav1.TypeMeta{
- Kind: "ConfigMap",
- APIVersion: "v1",
+ Kind: "ConfigMap",
+ APIVersion: "v1",
+ Name: fmt.Sprintf("%s-%s-%03d", KameletBundleType, name,
id),
+ Namespace: namespace,
+ Labels: map[string]string{
+ v1.IntegrationLabel: name,
+ kubernetes.ConfigMapTypeLabel: KameletBundleType,
},
- ObjectMeta: metav1.ObjectMeta{
- Name: fmt.Sprintf("%s-%s-%03d", KameletBundleType,
name, id),
- Namespace: namespace,
- Labels: map[string]string{
- v1.IntegrationLabel: name,
- kubernetes.ConfigMapTypeLabel:
KameletBundleType,
- },
- Annotations: map[string]string{
- kubernetes.ConfigMapAutogenLabel:
boolean.TrueString,
- },
+ Annotations: map[string]string{
+ kubernetes.ConfigMapAutogenLabel: boolean.TrueString,
},
Data: map[string]string{},
}
diff --git a/pkg/trait/keda.go b/pkg/trait/keda.go
index 36ee9c621..e34452b3f 100644
--- a/pkg/trait/keda.go
+++ b/pkg/trait/keda.go
@@ -29,7 +29,6 @@ import (
kedamapper "github.com/apache/camel-k/v2/pkg/trait/keda"
_ "github.com/apache/camel-k/v2/pkg/trait/keda/scalers"
corev1 "k8s.io/api/core/v1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
)
@@ -66,14 +65,10 @@ func (t *kedaTrait) Apply(e *Environment) error {
triggers, auths := t.populateTriggers(e.Integration.Name,
e.Integration.Namespace)
scaleTarget := t.getScaleTarget(e.Integration)
scaledObject := &v1alpha1.ScaledObject{
- TypeMeta: metav1.TypeMeta{
- APIVersion: v1alpha1.SchemeGroupVersion.String(),
- Kind: "ScaledObject",
- },
- ObjectMeta: metav1.ObjectMeta{
- Name: e.Integration.Name,
- Namespace: e.Integration.Namespace,
- },
+ APIVersion: v1alpha1.SchemeGroupVersion.String(),
+ Kind: "ScaledObject",
+ Name: e.Integration.Name,
+ Namespace: e.Integration.Namespace,
Spec: v1alpha1.ScaledObjectSpec{
ScaleTargetRef: scaleTarget,
PollingInterval: t.PollingInterval,
@@ -116,14 +111,10 @@ func (t *kedaTrait) populateTriggers(itName, itNamespace
string) ([]v1alpha1.Sca
func populateTriggerAuth(secrets []*traitv1.KedaSecret, itName, itNamespace,
kedaType string) *v1alpha1.TriggerAuthentication {
triggerAuth := &v1alpha1.TriggerAuthentication{
- TypeMeta: metav1.TypeMeta{
- APIVersion: v1alpha1.SchemeGroupVersion.String(),
- Kind: "TriggerAuthentication",
- },
- ObjectMeta: metav1.ObjectMeta{
- Name: fmt.Sprintf("%s-%s", itName, kedaType),
- Namespace: itNamespace,
- },
+ APIVersion: v1alpha1.SchemeGroupVersion.String(),
+ Kind: "TriggerAuthentication",
+ Name: fmt.Sprintf("%s-%s", itName, kedaType),
+ Namespace: itNamespace,
Spec: v1alpha1.TriggerAuthenticationSpec{
SecretTargetRef: make([]v1alpha1.AuthSecretTargetRef,
0, len(secrets)),
},
diff --git a/pkg/trait/knative_service.go b/pkg/trait/knative_service.go
index 666bdcd7a..3bbd6cf43 100644
--- a/pkg/trait/knative_service.go
+++ b/pkg/trait/knative_service.go
@@ -227,16 +227,12 @@ func (t *knativeServiceTrait) getServiceFor(e
*Environment) (*serving.Service, e
}
svc := serving.Service{
- TypeMeta: metav1.TypeMeta{
- Kind: "Service",
- APIVersion: serving.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Name: e.Integration.Name,
- Namespace: e.Integration.Namespace,
- Labels: serviceLabels,
- Annotations: serviceAnnotations,
- },
+ Kind: "Service",
+ APIVersion: serving.SchemeGroupVersion.String(),
+ Name: e.Integration.Name,
+ Namespace: e.Integration.Namespace,
+ Labels: serviceLabels,
+ Annotations: serviceAnnotations,
Spec: serving.ServiceSpec{
ConfigurationSpec: serving.ConfigurationSpec{
Template: serving.RevisionTemplateSpec{
diff --git a/pkg/trait/mount.go b/pkg/trait/mount.go
index ab3a71dd3..99a7e287c 100644
--- a/pkg/trait/mount.go
+++ b/pkg/trait/mount.go
@@ -26,7 +26,6 @@ import (
appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
serving "knative.dev/serving/pkg/apis/serving/v1"
@@ -212,10 +211,8 @@ func (t *mountTrait) configureVolumesAndMounts(
// EmptyDir volume for truststore output
trustStoreVolume := corev1.Volume{
- Name: caCertVolumeName,
- VolumeSource: corev1.VolumeSource{
- EmptyDir:
&corev1.EmptyDirVolumeSource{},
- },
+ Name: caCertVolumeName,
+ EmptyDir: &corev1.EmptyDirVolumeSource{},
}
*vols = append(*vols, trustStoreVolume)
@@ -354,18 +351,14 @@ func (t *mountTrait) computeApplicationProperties(e
*Environment) (*corev1.Confi
if applicationProperties != "" {
return &corev1.ConfigMap{
- TypeMeta: metav1.TypeMeta{
- Kind: "ConfigMap",
- APIVersion: "v1",
- },
- ObjectMeta: metav1.ObjectMeta{
- Name: e.Integration.Name +
"-application-properties",
- Namespace: e.Integration.Namespace,
- Labels: map[string]string{
- v1.IntegrationLabel:
e.Integration.Name,
- "camel.apache.org/properties.type":
"application",
- kubernetes.ConfigMapTypeLabel:
CamelPropertiesType,
- },
+ Kind: "ConfigMap",
+ APIVersion: "v1",
+ Name: e.Integration.Name +
"-application-properties",
+ Namespace: e.Integration.Namespace,
+ Labels: map[string]string{
+ v1.IntegrationLabel:
e.Integration.Name,
+ "camel.apache.org/properties.type":
"application",
+ kubernetes.ConfigMapTypeLabel:
CamelPropertiesType,
},
Data: map[string]string{
"application.properties": applicationProperties,
diff --git a/pkg/trait/mount_support.go b/pkg/trait/mount_support.go
index c6916a809..780296557 100644
--- a/pkg/trait/mount_support.go
+++ b/pkg/trait/mount_support.go
@@ -49,10 +49,8 @@ func ParseEmptyDirVolume(item string) (*corev1.Volume,
*corev1.VolumeMount, erro
volume := &corev1.Volume{
Name: refName,
- VolumeSource: corev1.VolumeSource{
- EmptyDir: &corev1.EmptyDirVolumeSource{
- SizeLimit: &parsed,
- },
+ EmptyDir: &corev1.EmptyDirVolumeSource{
+ SizeLimit: &parsed,
},
}
@@ -86,10 +84,8 @@ func ParseAndCreateVolume(e *Environment, item string)
(*corev1.Volume, *corev1.
volume = &corev1.Volume{
Name: kubernetes.SanitizeLabel(volumeName),
- VolumeSource: corev1.VolumeSource{
- PersistentVolumeClaim:
&corev1.PersistentVolumeClaimVolumeSource{
- ClaimName: volumeName,
- },
+ PersistentVolumeClaim:
&corev1.PersistentVolumeClaimVolumeSource{
+ ClaimName: volumeName,
},
}
diff --git a/pkg/trait/pdb.go b/pkg/trait/pdb.go
index b30b9cffd..e4edf2e8e 100644
--- a/pkg/trait/pdb.go
+++ b/pkg/trait/pdb.go
@@ -79,15 +79,11 @@ func (t *pdbTrait) Apply(e *Environment) error {
func (t *pdbTrait) podDisruptionBudgetFor(integration *v1.Integration)
*policyv1.PodDisruptionBudget {
pdb := &policyv1.PodDisruptionBudget{
- TypeMeta: metav1.TypeMeta{
- Kind: "PodDisruptionBudget",
- APIVersion: policyv1.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Name: integration.Name,
- Namespace: integration.Namespace,
- Labels: integration.Labels,
- },
+ Kind: "PodDisruptionBudget",
+ APIVersion: policyv1.SchemeGroupVersion.String(),
+ Name: integration.Name,
+ Namespace: integration.Namespace,
+ Labels: integration.Labels,
Spec: policyv1.PodDisruptionBudgetSpec{
Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{
diff --git a/pkg/trait/prometheus.go b/pkg/trait/prometheus.go
index 5ae98deaf..128b2be92 100644
--- a/pkg/trait/prometheus.go
+++ b/pkg/trait/prometheus.go
@@ -145,15 +145,11 @@ func (t *prometheusTrait) getPodMonitorFor(e
*Environment, portName string) (*mo
labels[v1.IntegrationLabel] = e.Integration.Name
podMonitor := monitoringv1.PodMonitor{
- TypeMeta: metav1.TypeMeta{
- Kind: "PodMonitor",
- APIVersion: monitoringv1.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Name: e.Integration.Name,
- Namespace: e.Integration.Namespace,
- Labels: labels,
- },
+ Kind: "PodMonitor",
+ APIVersion: monitoringv1.SchemeGroupVersion.String(),
+ Name: e.Integration.Name,
+ Namespace: e.Integration.Namespace,
+ Labels: labels,
Spec: monitoringv1.PodMonitorSpec{
Selector: metav1.LabelSelector{
MatchLabels: map[string]string{
diff --git a/pkg/trait/pull_secret.go b/pkg/trait/pull_secret.go
index d6ca457e0..724d443f7 100644
--- a/pkg/trait/pull_secret.go
+++ b/pkg/trait/pull_secret.go
@@ -22,7 +22,6 @@ import (
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
traitv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1/trait"
@@ -142,14 +141,10 @@ func (t *pullSecretTrait) newImagePullerRoleBinding(e
*Environment) *rbacv1.Role
}
return &rbacv1.RoleBinding{
- TypeMeta: metav1.TypeMeta{
- Kind: "RoleBinding",
- APIVersion: rbacv1.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: targetNamespace,
- Name: fmt.Sprintf("camel-k-puller-%s-%s",
e.Integration.Namespace, serviceAccount),
- },
+ Kind: "RoleBinding",
+ APIVersion: rbacv1.SchemeGroupVersion.String(),
+ Namespace: targetNamespace,
+ Name: fmt.Sprintf("camel-k-puller-%s-%s",
e.Integration.Namespace, serviceAccount),
RoleRef: rbacv1.RoleRef{
Kind: "ClusterRole",
Name: "system:image-puller",
diff --git a/pkg/trait/route.go b/pkg/trait/route.go
index 9bc1ab1e8..15edbde4a 100644
--- a/pkg/trait/route.go
+++ b/pkg/trait/route.go
@@ -23,7 +23,6 @@ import (
"strings"
corev1 "k8s.io/api/core/v1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/utils/ptr"
@@ -108,18 +107,14 @@ func (t *routeTrait) Apply(e *Environment) error {
return err
}
route := routev1.Route{
- TypeMeta: metav1.TypeMeta{
- Kind: "Route",
- APIVersion: routev1.GroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Name: t.service.Name,
- Namespace: t.service.Namespace,
- Labels: map[string]string{
- v1.IntegrationLabel: e.Integration.Name,
- },
- Annotations: t.Annotations,
+ Kind: "Route",
+ APIVersion: routev1.GroupVersion.String(),
+ Name: t.service.Name,
+ Namespace: t.service.Namespace,
+ Labels: map[string]string{
+ v1.IntegrationLabel: e.Integration.Name,
},
+ Annotations: t.Annotations,
Spec: routev1.RouteSpec{
Port: &routev1.RoutePort{
TargetPort: intstr.FromString(servicePortName),
diff --git a/pkg/trait/service.go b/pkg/trait/service.go
index 336d5b957..779c3fa6e 100644
--- a/pkg/trait/service.go
+++ b/pkg/trait/service.go
@@ -24,7 +24,6 @@ import (
"strings"
corev1 "k8s.io/api/core/v1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/utils/ptr"
@@ -153,16 +152,12 @@ func (t *serviceTrait) getServiceFor(itName, itNamespace
string) *corev1.Service
ports := t.getServicePorts()
return &corev1.Service{
- TypeMeta: metav1.TypeMeta{
- Kind: "Service",
- APIVersion: "v1",
- },
- ObjectMeta: metav1.ObjectMeta{
- Name: itName,
- Namespace: itNamespace,
- Labels: labels,
- Annotations: t.Annotations,
- },
+ Kind: "Service",
+ APIVersion: "v1",
+ Name: itName,
+ Namespace: itNamespace,
+ Labels: labels,
+ Annotations: t.Annotations,
Spec: corev1.ServiceSpec{
Ports: ports,
Selector: map[string]string{
diff --git a/pkg/trait/trait.go b/pkg/trait/trait.go
index b2ce2fac9..cb499eaab 100644
--- a/pkg/trait/trait.go
+++ b/pkg/trait/trait.go
@@ -211,14 +211,10 @@ func getCamelAppObject(ctx context.Context, c
client.Client, kind, namespace, na
return c.BatchV1().CronJobs(namespace).Get(ctx, name,
metav1.GetOptions{})
case "KnativeService":
ksvc := &serving.Service{
- TypeMeta: metav1.TypeMeta{
- Kind: "Service",
- APIVersion: serving.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Name: name,
- Namespace: namespace,
- },
+ Kind: "Service",
+ APIVersion: serving.SchemeGroupVersion.String(),
+ Name: name,
+ Namespace: namespace,
}
err := c.Get(ctx, ctrl.ObjectKeyFromObject(ksvc), ksvc)
diff --git a/pkg/trait/trait_types.go b/pkg/trait/trait_types.go
index f5621dfa7..f790ed1fd 100644
--- a/pkg/trait/trait_types.go
+++ b/pkg/trait/trait_types.go
@@ -408,9 +408,7 @@ func getVolume(volName, storageType, storageName,
filterKey, filterValue string)
switch storageType {
case configmapStorageType:
volume.ConfigMap = &corev1.ConfigMapVolumeSource{
- LocalObjectReference: corev1.LocalObjectReference{
- Name: storageName,
- },
+ Name: storageName,
Items: items,
}
case secretStorageType:
diff --git a/pkg/trait/util.go b/pkg/trait/util.go
index f82c391bd..2a7f36d4e 100644
--- a/pkg/trait/util.go
+++ b/pkg/trait/util.go
@@ -332,7 +332,7 @@ func ExtractAndMaybeDeleteTraits(c client.Client,
annotations map[string]string,
//nolint:staticcheck
if strings.HasPrefix(k, v1.TraitAnnotationPrefix) {
key := strings.ReplaceAll(k, v1.TraitAnnotationPrefix,
"")
- traitID := strings.Split(key, ".")[0]
+ traitID, _, _ := strings.Cut(key, ".")
if err := ValidateTrait(catalog, traitID); err != nil {
return nil, err
}
diff --git a/pkg/util/camel/camel_runtime_catalog.go
b/pkg/util/camel/camel_runtime_catalog.go
index c20887cd0..34e113a83 100644
--- a/pkg/util/camel/camel_runtime_catalog.go
+++ b/pkg/util/camel/camel_runtime_catalog.go
@@ -25,15 +25,15 @@ import (
// NewRuntimeCatalog creates a runtime catalog with the given catalog.
func NewRuntimeCatalog(cat v1.CamelCatalog) *RuntimeCatalog {
- catalog := RuntimeCatalog{}
- catalog.CamelCatalogSpec = cat.Spec
- catalog.CamelCatalogStatus = cat.Status
- catalog.artifactByScheme = make(map[string]string)
- catalog.artifactByDataFormat = make(map[string]string)
- catalog.schemesByID = make(map[string]v1.CamelScheme)
- catalog.languageDependencies = make(map[string]string)
- catalog.javaTypeDependencies = make(map[string]string)
- catalog.loaderByArtifact = make(map[string]string)
+ catalog := RuntimeCatalog{
+ CamelCatalogSpec: cat.Spec,
+ CamelCatalogStatus: cat.Status,
+ artifactByScheme: make(map[string]string),
+ artifactByDataFormat: make(map[string]string),
+ schemesByID: make(map[string]v1.CamelScheme),
+ languageDependencies: make(map[string]string),
+ javaTypeDependencies: make(map[string]string),
+ loaderByArtifact: make(map[string]string)}
for id, artifact := range catalog.Artifacts {
for _, scheme := range artifact.Schemes {
diff --git a/pkg/util/knative/apis.go b/pkg/util/knative/apis.go
index e4a6e5bb1..e6d7691a3 100644
--- a/pkg/util/knative/apis.go
+++ b/pkg/util/knative/apis.go
@@ -28,59 +28,45 @@ var (
// KnownChannelKinds are known channel kinds belonging to Knative.
KnownChannelKinds = []GroupVersionKindResource{
{
- GroupVersionKind: schema.GroupVersionKind{
- Kind: "Channel",
- Group: "messaging.knative.dev",
- Version: "v1",
- },
+ Kind: "Channel",
+ Group: "messaging.knative.dev",
+ Version: "v1",
Resource: "channels",
},
{
- GroupVersionKind: schema.GroupVersionKind{
- Kind: "Channel",
- Group: "messaging.knative.dev",
- Version: "v1beta1",
- },
+ Kind: "Channel",
+ Group: "messaging.knative.dev",
+ Version: "v1beta1",
Resource: "channels",
},
{
- GroupVersionKind: schema.GroupVersionKind{
- Kind: "InMemoryChannel",
- Group: "messaging.knative.dev",
- Version: "v1",
- },
+ Kind: "InMemoryChannel",
+ Group: "messaging.knative.dev",
+ Version: "v1",
Resource: "inmemorychannels",
},
{
- GroupVersionKind: schema.GroupVersionKind{
- Kind: "InMemoryChannel",
- Group: "messaging.knative.dev",
- Version: "v1beta1",
- },
+ Kind: "InMemoryChannel",
+ Group: "messaging.knative.dev",
+ Version: "v1beta1",
Resource: "inmemorychannels",
},
{
- GroupVersionKind: schema.GroupVersionKind{
- Kind: "KafkaChannel",
- Group: "messaging.knative.dev",
- Version: "v1beta1",
- },
+ Kind: "KafkaChannel",
+ Group: "messaging.knative.dev",
+ Version: "v1beta1",
Resource: "kafkachannels",
},
{
- GroupVersionKind: schema.GroupVersionKind{
- Kind: "KafkaChannel",
- Group: "messaging.knative.dev",
- Version: "v1alpha1",
- },
+ Kind: "KafkaChannel",
+ Group: "messaging.knative.dev",
+ Version: "v1alpha1",
Resource: "kafkachannels",
},
{
- GroupVersionKind: schema.GroupVersionKind{
- Kind: "NatssChannel",
- Group: "messaging.knative.dev",
- Version: "v1alpha1",
- },
+ Kind: "NatssChannel",
+ Group: "messaging.knative.dev",
+ Version: "v1alpha1",
Resource: "natsschannels",
},
}
@@ -88,27 +74,21 @@ var (
// KnownEndpointKinds are known endpoint kinds belonging to Knative.
KnownEndpointKinds = []GroupVersionKindResource{
{
- GroupVersionKind: schema.GroupVersionKind{
- Kind: "Service",
- Group: "serving.knative.dev",
- Version: "v1",
- },
+ Kind: "Service",
+ Group: "serving.knative.dev",
+ Version: "v1",
Resource: "services",
},
{
- GroupVersionKind: schema.GroupVersionKind{
- Kind: "Service",
- Group: "serving.knative.dev",
- Version: "v1beta1",
- },
+ Kind: "Service",
+ Group: "serving.knative.dev",
+ Version: "v1beta1",
Resource: "services",
},
{
- GroupVersionKind: schema.GroupVersionKind{
- Kind: "Service",
- Group: "serving.knative.dev",
- Version: "v1alpha1",
- },
+ Kind: "Service",
+ Group: "serving.knative.dev",
+ Version: "v1alpha1",
Resource: "services",
},
}
@@ -116,19 +96,15 @@ var (
// KnownBrokerKinds are known broker kinds belonging to Knative.
KnownBrokerKinds = []GroupVersionKindResource{
{
- GroupVersionKind: schema.GroupVersionKind{
- Kind: "Broker",
- Group: "eventing.knative.dev",
- Version: "v1",
- },
+ Kind: "Broker",
+ Group: "eventing.knative.dev",
+ Version: "v1",
Resource: "brokers",
},
{
- GroupVersionKind: schema.GroupVersionKind{
- Kind: "Broker",
- Group: "eventing.knative.dev",
- Version: "v1beta1",
- },
+ Kind: "Broker",
+ Group: "eventing.knative.dev",
+ Version: "v1beta1",
Resource: "brokers",
},
}
diff --git a/pkg/util/knative/knative.go b/pkg/util/knative/knative.go
index 0aa68910e..372f1e72d 100644
--- a/pkg/util/knative/knative.go
+++ b/pkg/util/knative/knative.go
@@ -50,14 +50,10 @@ const knativeService = "Service"
func CreateSubscription(channelReference corev1.ObjectReference, serviceName
string, path string) *messaging.Subscription {
return &messaging.Subscription{
- TypeMeta: metav1.TypeMeta{
- APIVersion: messaging.SchemeGroupVersion.String(),
- Kind: "Subscription",
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: channelReference.Namespace,
- Name: channelReference.Name + "-" + serviceName,
- },
+ APIVersion: messaging.SchemeGroupVersion.String(),
+ Kind: "Subscription",
+ Namespace: channelReference.Namespace,
+ Name: channelReference.Name + "-" + serviceName,
Spec: messaging.SubscriptionSpec{
Channel: duckv1.KReference{
APIVersion:
channelReference.GroupVersionKind().GroupVersion().String(),
@@ -102,14 +98,10 @@ func CreateKnativeServiceTrigger(brokerReference
corev1.ObjectReference, service
func CreateTrigger(brokerReference corev1.ObjectReference, subscriberRef
duckv1.KReference, eventType string, path string, attributes map[string]string)
(*eventing.Trigger, error) {
trigger := eventing.Trigger{
- TypeMeta: metav1.TypeMeta{
- APIVersion: eventing.SchemeGroupVersion.String(),
- Kind: "Trigger",
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: brokerReference.Namespace,
- Name: GetTriggerName(brokerReference.Name,
subscriberRef.Name, eventType),
- },
+ APIVersion: eventing.SchemeGroupVersion.String(),
+ Kind: "Trigger",
+ Namespace: brokerReference.Namespace,
+ Name: GetTriggerName(brokerReference.Name,
subscriberRef.Name, eventType),
Spec: eventing.TriggerSpec{
Broker: brokerReference.Name,
Subscriber: duckv1.Destination{
@@ -141,14 +133,10 @@ func GetTriggerName(brokerName string, subscriberName
string, eventType string)
func CreateSinkBinding(source corev1.ObjectReference, target
corev1.ObjectReference) *sources.SinkBinding {
return &sources.SinkBinding{
- TypeMeta: metav1.TypeMeta{
- APIVersion: sources.SchemeGroupVersion.String(),
- Kind: "SinkBinding",
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: source.Namespace,
- Name: source.Name,
- },
+ APIVersion: sources.SchemeGroupVersion.String(),
+ Kind: "SinkBinding",
+ Namespace: source.Namespace,
+ Name: source.Name,
Spec: sources.SinkBindingSpec{
BindingSpec: duckv1.BindingSpec{
Subject: tracker.Reference{
diff --git a/pkg/util/kubernetes/client.go b/pkg/util/kubernetes/client.go
index 71b6b0e9c..501018d84 100644
--- a/pkg/util/kubernetes/client.go
+++ b/pkg/util/kubernetes/client.go
@@ -23,7 +23,6 @@ import (
"fmt"
corev1 "k8s.io/api/core/v1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -108,14 +107,10 @@ func GetUnstructured(context context.Context, client
ctrl.Reader, gvk schema.Gro
func GetConfigMap(context context.Context, client ctrl.Reader, name string,
namespace string) (*corev1.ConfigMap, error) {
configMap := &corev1.ConfigMap{
- TypeMeta: metav1.TypeMeta{
- Kind: "ConfigMap",
- APIVersion: "v1",
- },
- ObjectMeta: metav1.ObjectMeta{
- Name: name,
- Namespace: namespace,
- },
+ Kind: "ConfigMap",
+ APIVersion: "v1",
+ Name: name,
+ Namespace: namespace,
}
if err := client.Get(context, ctrl.ObjectKeyFromObject(configMap),
configMap); err != nil {
@@ -127,14 +122,10 @@ func GetConfigMap(context context.Context, client
ctrl.Reader, name string, name
func GetSecret(context context.Context, client ctrl.Reader, name string,
namespace string) (*corev1.Secret, error) {
secret := &corev1.Secret{
- TypeMeta: metav1.TypeMeta{
- Kind: "Secret",
- APIVersion: "v1",
- },
- ObjectMeta: metav1.ObjectMeta{
- Name: name,
- Namespace: namespace,
- },
+ Kind: "Secret",
+ APIVersion: "v1",
+ Name: name,
+ Namespace: namespace,
}
if err := client.Get(context, ctrl.ObjectKeyFromObject(secret),
secret); err != nil {
diff --git a/pkg/util/kubernetes/collection.go
b/pkg/util/kubernetes/collection.go
index 20b7fad55..11bd8dbc9 100644
--- a/pkg/util/kubernetes/collection.go
+++ b/pkg/util/kubernetes/collection.go
@@ -66,11 +66,9 @@ func (c *Collection) Items() []ctrl.Object {
// AsKubernetesList returns all resources wrapped in a Kubernetes list.
func (c *Collection) AsKubernetesList() *corev1.List {
lst := corev1.List{
- TypeMeta: metav1.TypeMeta{
- Kind: "List",
- APIVersion: "v1",
- },
- Items: make([]runtime.RawExtension, 0, len(c.items)),
+ Kind: "List",
+ APIVersion: "v1",
+ Items: make([]runtime.RawExtension, 0, len(c.items)),
}
for _, res := range c.items {
raw := runtime.RawExtension{
diff --git a/pkg/util/kubernetes/factory.go b/pkg/util/kubernetes/factory.go
index 0aa98b683..3c02f2e5d 100644
--- a/pkg/util/kubernetes/factory.go
+++ b/pkg/util/kubernetes/factory.go
@@ -24,7 +24,6 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
var (
@@ -78,14 +77,10 @@ func NewTolerations(taints []string) ([]corev1.Toleration,
error) {
func NewPersistentVolumeClaim(
ns, name, storageClassName string, capacityStorage resource.Quantity,
accessMode corev1.PersistentVolumeAccessMode) *corev1.PersistentVolumeClaim {
pvc := corev1.PersistentVolumeClaim{
- TypeMeta: metav1.TypeMeta{
- Kind: "PersistentVolumeClaim",
- APIVersion: corev1.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: ns,
- Name: name,
- },
+ Kind: "PersistentVolumeClaim",
+ APIVersion: corev1.SchemeGroupVersion.String(),
+ Namespace: ns,
+ Name: name,
Spec: corev1.PersistentVolumeClaimSpec{
StorageClassName: &storageClassName,
AccessModes: []corev1.PersistentVolumeAccessMode{
diff --git a/pkg/util/kubernetes/log/pod_scraper.go
b/pkg/util/kubernetes/log/pod_scraper.go
index 1567c1f0e..650b4cbaf 100644
--- a/pkg/util/kubernetes/log/pod_scraper.go
+++ b/pkg/util/kubernetes/log/pod_scraper.go
@@ -156,14 +156,10 @@ func (s *PodScraper) handleAndRestart(ctx
context.Context, err error, wait time.
//nolint:nestif
func (s *PodScraper) waitForPodRunning(ctx context.Context, namespace string,
podName string, defaultContainerName string) (string, error) {
pod := corev1.Pod{
- TypeMeta: metav1.TypeMeta{
- Kind: "Pod",
- APIVersion: corev1.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Name: podName,
- Namespace: namespace,
- },
+ Kind: "Pod",
+ APIVersion: corev1.SchemeGroupVersion.String(),
+ Name: podName,
+ Namespace: namespace,
}
podClient := s.client.CoreV1().Pods(pod.Namespace)
watcher, err := podClient.Watch(ctx, metav1.ListOptions{
diff --git a/pkg/util/kubernetes/lookup.go b/pkg/util/kubernetes/lookup.go
index a6f62c0cb..7e8f43ec8 100644
--- a/pkg/util/kubernetes/lookup.go
+++ b/pkg/util/kubernetes/lookup.go
@@ -34,14 +34,10 @@ import (
// Deprecated: won't be supported in future releases.
func LookupConfigmap(ctx context.Context, c client.Client, ns string, name
string) *corev1.ConfigMap {
cm := corev1.ConfigMap{
- TypeMeta: metav1.TypeMeta{
- Kind: "ConfigMap",
- APIVersion: corev1.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: ns,
- Name: name,
- },
+ Kind: "ConfigMap",
+ APIVersion: corev1.SchemeGroupVersion.String(),
+ Namespace: ns,
+ Name: name,
}
key := ctrl.ObjectKey{
Namespace: ns,
@@ -71,14 +67,10 @@ func LookupResourceVersion(ctx context.Context, c
client.Client, object ctrl.Obj
// Deprecated: won't be supported in future releases.
func LookupSecret(ctx context.Context, c client.Client, ns string, name
string) *corev1.Secret {
secret := corev1.Secret{
- TypeMeta: metav1.TypeMeta{
- Kind: "Secret",
- APIVersion: corev1.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: ns,
- Name: name,
- },
+ Kind: "Secret",
+ APIVersion: corev1.SchemeGroupVersion.String(),
+ Namespace: ns,
+ Name: name,
}
key := ctrl.ObjectKey{
Namespace: ns,
@@ -96,14 +88,10 @@ func LookupSecret(ctx context.Context, c client.Client, ns
string, name string)
// LookupPersistentVolumeClaim will look for any k8s PersistentVolumeClaim
with a given name in a given namespace.
func LookupPersistentVolumeClaim(ctx context.Context, c client.Client, ns
string, name string) (*corev1.PersistentVolumeClaim, error) {
pvc := corev1.PersistentVolumeClaim{
- TypeMeta: metav1.TypeMeta{
- Kind: "PersistentVolumeClaim",
- APIVersion: corev1.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: ns,
- Name: name,
- },
+ Kind: "PersistentVolumeClaim",
+ APIVersion: corev1.SchemeGroupVersion.String(),
+ Namespace: ns,
+ Name: name,
}
key := ctrl.ObjectKey{
Namespace: ns,
@@ -121,14 +109,10 @@ func LookupPersistentVolumeClaim(ctx context.Context, c
client.Client, ns string
// LookupStorageClass will look for any k8s StorageClass with a given name in
a given namespace.
func LookupStorageClass(ctx context.Context, c client.Client, ns string, name
string) (*storagev1.StorageClass, error) {
sc := storagev1.StorageClass{
- TypeMeta: metav1.TypeMeta{
- Kind: "StorageClass",
- APIVersion: storagev1.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: ns,
- Name: name,
- },
+ Kind: "StorageClass",
+ APIVersion: storagev1.SchemeGroupVersion.String(),
+ Namespace: ns,
+ Name: name,
}
key := ctrl.ObjectKey{
Namespace: ns,
@@ -165,14 +149,10 @@ func LookupDefaultStorageClass(ctx context.Context, c
client.Client) (*storagev1
// LookupServiceAccount will look for any k8s ServiceAccount with a given name
in a given namespace.
func LookupServiceAccount(ctx context.Context, c client.Client, ns string,
name string) (*corev1.ServiceAccount, error) {
sa := corev1.ServiceAccount{
- TypeMeta: metav1.TypeMeta{
- Kind: "ServiceAccount",
- APIVersion: corev1.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: ns,
- Name: name,
- },
+ Kind: "ServiceAccount",
+ APIVersion: corev1.SchemeGroupVersion.String(),
+ Namespace: ns,
+ Name: name,
}
key := ctrl.ObjectKey{
Namespace: ns,
@@ -190,14 +170,10 @@ func LookupServiceAccount(ctx context.Context, c
client.Client, ns string, name
// LookupRole will look for any k8s Role with a given name in a given
namespace.
func LookupRole(ctx context.Context, c client.Client, ns string, name string)
(*rbacv1.Role, error) {
r := rbacv1.Role{
- TypeMeta: metav1.TypeMeta{
- Kind: "Role",
- APIVersion: rbacv1.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: ns,
- Name: name,
- },
+ Kind: "Role",
+ APIVersion: rbacv1.SchemeGroupVersion.String(),
+ Namespace: ns,
+ Name: name,
}
key := ctrl.ObjectKey{
Namespace: ns,
@@ -215,14 +191,10 @@ func LookupRole(ctx context.Context, c client.Client, ns
string, name string) (*
// LookupRoleBinding will look for any k8s RoleBinding with a given name in a
given namespace.
func LookupRoleBinding(ctx context.Context, c client.Client, ns string, name
string) (*rbacv1.RoleBinding, error) {
rb := rbacv1.RoleBinding{
- TypeMeta: metav1.TypeMeta{
- Kind: "RoleBinding",
- APIVersion: rbacv1.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: ns,
- Name: name,
- },
+ Kind: "RoleBinding",
+ APIVersion: rbacv1.SchemeGroupVersion.String(),
+ Namespace: ns,
+ Name: name,
}
key := ctrl.ObjectKey{
Namespace: ns,
@@ -240,14 +212,10 @@ func LookupRoleBinding(ctx context.Context, c
client.Client, ns string, name str
// LookupService will look for any k8s Service with a given name in a given
namespace.
func LookupService(ctx context.Context, c client.Client, ns string, name
string) (*corev1.Service, error) {
svc := corev1.Service{
- TypeMeta: metav1.TypeMeta{
- Kind: "Service",
- APIVersion: corev1.SchemeGroupVersion.String(),
- },
- ObjectMeta: metav1.ObjectMeta{
- Namespace: ns,
- Name: name,
- },
+ Kind: "Service",
+ APIVersion: corev1.SchemeGroupVersion.String(),
+ Namespace: ns,
+ Name: name,
}
key := ctrl.ObjectKey{
Namespace: ns,
diff --git a/pkg/util/maven/maven_command.go b/pkg/util/maven/maven_command.go
index 5d0d4dddc..9a8f9864d 100644
--- a/pkg/util/maven/maven_command.go
+++ b/pkg/util/maven/maven_command.go
@@ -128,7 +128,7 @@ func (c *Command) optionsFromEnv() ([]string, []string) {
for _, extraOption := range c.context.ExtraMavenOpts {
// Basic duplicated key detection, that should be
improved
// to support a wider range of JVM options
- key := strings.SplitN(extraOption, "=", 2)[0]
+ key, _, _ := strings.Cut(extraOption, "=")
exists := false
for _, opt := range options {
if strings.HasPrefix(opt, key) {
diff --git a/pkg/util/maven/maven_repositories.go
b/pkg/util/maven/maven_repositories.go
index 88e07ca37..b458ef03a 100644
--- a/pkg/util/maven/maven_repositories.go
+++ b/pkg/util/maven/maven_repositories.go
@@ -28,6 +28,7 @@ var DefaultRepositories = defaultRepositories{}
type defaultRepositories struct{}
+//nolint:unparam // it implements an interface
func (o defaultRepositories) apply(settings *Settings) error {
for _, repository := range defaultMavenRepositories() {
settings.Profiles[0].Repositories =
upsertRepository(repository, settings.Profiles[0].Repositories)
diff --git a/pkg/util/openshift/openshift.go b/pkg/util/openshift/openshift.go
index c2ce1b781..ce5244588 100644
--- a/pkg/util/openshift/openshift.go
+++ b/pkg/util/openshift/openshift.go
@@ -61,7 +61,7 @@ func GetOpenshiftPodSecurityContextRestricted(ctx
context.Context, client kubern
}
supplementalGroups = strings.Split(supplementalGroups, ",")[0]
- fsGroupStr := strings.Split(supplementalGroups, "/")[0]
+ fsGroupStr, _, _ := strings.Cut(supplementalGroups, "/")
fsGroup, err := strconv.ParseInt(fsGroupStr, 10, 64)
if err != nil {
return nil, fmt.Errorf("failed to convert fsgroup to integer
%q: %w", fsGroupStr, err)
@@ -109,7 +109,7 @@ func GetOpenshiftUser(ctx context.Context, client
kubernetes.Interface, namespac
if !ok {
return nil, errors.New("annotation
'openshift.io/sa.scc.uid-range' not found")
}
- uidStr := strings.Split(uidRange, "/")[0]
+ uidStr, _, _ := strings.Cut(uidRange, "/")
uid, err := strconv.ParseInt(uidStr, 10, 64)
if err != nil {
return nil, fmt.Errorf("failed to convert uid to integer %q:
%w", uidStr, err)
diff --git a/pkg/util/source/inspector.go b/pkg/util/source/inspector.go
index 654e6e986..d99864a7d 100644
--- a/pkg/util/source/inspector.go
+++ b/pkg/util/source/inspector.go
@@ -194,21 +194,15 @@ func InspectorForLanguage(catalog *camel.RuntimeCatalog,
language v1.Language) I
switch language {
case v1.LanguageJavaSource:
return &JavaSourceInspector{
- baseInspector: baseInspector{
- catalog: catalog,
- },
+ catalog: catalog,
}
case v1.LanguageXML:
return &XMLInspector{
- baseInspector: baseInspector{
- catalog: catalog,
- },
+ catalog: catalog,
}
case v1.LanguageYaml:
return &YAMLInspector{
- baseInspector: baseInspector{
- catalog: catalog,
- },
+ catalog: catalog,
}
}
diff --git a/script/Makefile b/script/Makefile
index 8b73f9aae..6dcc9447f 100644
--- a/script/Makefile
+++ b/script/Makefile
@@ -44,7 +44,7 @@ LINTER ?= $(LOCALBIN)/golangci-lint
DEADCODE ?= $(LOCALBIN)/deadcode
GOVULNCHECK ?= $(LOCALBIN)/govulncheck
GOIMPORT ?= $(LOCALBIN)/goimports
-LINTER_VERSION ?= v2.12.2
+LINTER_VERSION ?= v2.13.2
GOVULNCHECK_VERSION ?= latest
LINT_GOGC ?= 20
LINT_DEADLINE ?= 10m