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 73cbd6923 chore(api): remove unused server field
73cbd6923 is described below
commit 73cbd69231b1f9e6ea586ddb434c0834a8305c1e
Author: Pasquale Congiusti <[email protected]>
AuthorDate: Sat Apr 25 09:04:07 2026 +0200
chore(api): remove unused server field
Closes #6579
---
docs/modules/ROOT/partials/apis/camel-k-crds.adoc | 2 +
helm/camel-k/crds/camel-k-crds.yaml | 10 ++-
pkg/apis/camel/v1/build_types.go | 4 +-
pkg/apis/camel/v1/zz_generated.deepcopy.go | 4 +-
pkg/builder/project.go | 73 ----------------------
pkg/builder/project_test.go | 69 --------------------
.../applyconfiguration/camel/v1/mavenbuildspec.go | 14 +++--
.../config/crd/bases/camel.apache.org_builds.yaml | 10 ++-
8 files changed, 31 insertions(+), 155 deletions(-)
diff --git a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
index 997ee0e7a..29951efc7 100644
--- a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
+++ b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
@@ -4578,6 +4578,8 @@ additional repositories
Servers (auth)
+Deprecated: no longer in use.
+
|===
diff --git a/helm/camel-k/crds/camel-k-crds.yaml
b/helm/camel-k/crds/camel-k-crds.yaml
index 961561de0..415ddf548 100644
--- a/helm/camel-k/crds/camel-k-crds.yaml
+++ b/helm/camel-k/crds/camel-k-crds.yaml
@@ -572,7 +572,10 @@ spec:
type: object
type: array
servers:
- description: Servers (auth)
+ description: |-
+ Servers (auth)
+
+ Deprecated: no longer in use.
items:
description: Server see
link:https://maven.apache.org/settings.html[Maven
settings].
@@ -1502,7 +1505,10 @@ spec:
type: object
type: array
servers:
- description: Servers (auth)
+ description: |-
+ Servers (auth)
+
+ Deprecated: no longer in use.
items:
description: Server see
link:https://maven.apache.org/settings.html[Maven
settings].
diff --git a/pkg/apis/camel/v1/build_types.go b/pkg/apis/camel/v1/build_types.go
index a1a318909..e3add9950 100644
--- a/pkg/apis/camel/v1/build_types.go
+++ b/pkg/apis/camel/v1/build_types.go
@@ -144,7 +144,9 @@ type MavenBuildSpec struct {
// additional repositories
Repositories []Repository `json:"repositories,omitempty"`
// Servers (auth)
- Servers []Server `json:"servers,omitempty"`
+ //
+ // Deprecated: no longer in use.
+ DeprecatedServers []Server `json:"servers,omitempty"`
}
// PublishTask image publish configuration.
diff --git a/pkg/apis/camel/v1/zz_generated.deepcopy.go
b/pkg/apis/camel/v1/zz_generated.deepcopy.go
index 2d3e8c2a7..75c4ba0e0 100644
--- a/pkg/apis/camel/v1/zz_generated.deepcopy.go
+++ b/pkg/apis/camel/v1/zz_generated.deepcopy.go
@@ -2366,8 +2366,8 @@ func (in *MavenBuildSpec) DeepCopyInto(out
*MavenBuildSpec) {
*out = make([]Repository, len(*in))
copy(*out, *in)
}
- if in.Servers != nil {
- in, out := &in.Servers, &out.Servers
+ if in.DeprecatedServers != nil {
+ in, out := &in.DeprecatedServers, &out.DeprecatedServers
*out = make([]Server, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
diff --git a/pkg/builder/project.go b/pkg/builder/project.go
index 39fb5430b..3fd124cc5 100644
--- a/pkg/builder/project.go
+++ b/pkg/builder/project.go
@@ -18,20 +18,15 @@ limitations under the License.
package builder
import (
- "bytes"
"encoding/xml"
"fmt"
"os"
- "regexp"
- "strings"
"github.com/apache/camel-k/v2/pkg/util/io"
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
"github.com/apache/camel-k/v2/pkg/util/camel"
"github.com/apache/camel-k/v2/pkg/util/jvm"
"github.com/apache/camel-k/v2/pkg/util/kubernetes"
- "github.com/apache/camel-k/v2/pkg/util/log"
"github.com/apache/camel-k/v2/pkg/util/maven"
)
@@ -103,7 +98,6 @@ func generateProjectSettings(ctx *builderContext) error {
if err != nil {
return err
}
- val = injectServersIntoMavenSettings(val, ctx.Build.Maven.Servers)
if val != "" {
ctx.Maven.UserSettings = []byte(val)
}
@@ -129,73 +123,6 @@ func generateProjectSettings(ctx *builderContext) error {
return nil
}
-func injectServersIntoMavenSettings(settings string, servers []v1.Server)
string {
- if len(servers) < 1 {
- return settings
- }
- newSettings, i := getServerTagIndex(settings)
- if i < 0 {
- log.Infof("Could not find a place to store Server information
in Maven settings, skipping")
-
- return settings
- }
- content, err := encodeXMLNoHeader(servers)
- if err != nil {
- log.Infof("Could not marshall extra Servers into Maven
settings, skipping")
-
- return settings
- }
-
- return newSettings[:i] + string(content) + newSettings[i:]
-}
-
-func encodeXMLNoHeader(content any) ([]byte, error) {
- w := &bytes.Buffer{}
- w.WriteString("\n")
- e := xml.NewEncoder(w)
- e.Indent(" ", " ")
-
- if err := e.Encode(content); err != nil {
- return []byte{}, err
- }
- w.WriteString("\n ")
-
- return w.Bytes(), nil
-}
-
-// Return Index of </server> Tag in val. Creates Tag if necessary.
-func getServerTagIndex(val string) (string, int) {
- serversTag := "\n <servers></servers>\n"
- val = strings.Replace(val, "<servers/>", serversTag, 1)
- endServerTag := "</servers>"
- i := strings.Index(val, endServerTag)
- if i > 0 {
- return val, i
- }
- // create necessary tags
- tags := []string{"</proxies>", "<proxies/>", "</offline>",
"<offline/>", "</usePluginRegistry>", "<usePluginRegistry/>",
"</interactiveMode>", "<interactiveMode/>", "</localRepository>",
"<localRepository/>"}
- i = -1
- for _, tag := range tags {
- i = strings.Index(val, tag)
- if i > 0 {
- i += len(tag)
-
- break
- }
- }
- if i < 0 {
- regexp := regexp.MustCompile(`<settings.*>`)
- loc := regexp.FindStringIndex(val)
- if loc == nil {
- return val, i
- }
- i = loc[1]
- }
- val = val[:i] + serversTag + val[i:]
-
- return val, strings.Index(val, endServerTag)
-}
-
func injectDependencies(ctx *builderContext) error {
// Add dependencies from build
return camel.ManageIntegrationDependencies(&ctx.Maven.Project,
ctx.Build.Dependencies, ctx.Catalog)
diff --git a/pkg/builder/project_test.go b/pkg/builder/project_test.go
index 1a50dfdd2..ff4221fcd 100644
--- a/pkg/builder/project_test.go
+++ b/pkg/builder/project_test.go
@@ -18,11 +18,8 @@ limitations under the License.
package builder
import (
- "regexp"
"testing"
- "github.com/apache/camel-k/v2/pkg/util/boolean"
-
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -31,9 +28,7 @@ import (
v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
"github.com/apache/camel-k/v2/pkg/internal"
- "github.com/apache/camel-k/v2/pkg/util"
"github.com/apache/camel-k/v2/pkg/util/camel"
- "github.com/apache/camel-k/v2/pkg/util/maven"
)
const customSettings = `<?xml version="1.0" encoding="UTF-8"?>
@@ -432,67 +427,3 @@ func TestMavenSettingsWithSettingsSecurityFromSecret(t
*testing.T) {
assert.Equal(t, []byte("setting-data"), ctx.Maven.UserSettings)
assert.Equal(t, []byte("setting-security-data"),
ctx.Maven.SettingsSecurity)
}
-
-func TestInjectEmptyServersIntoDefaultMavenSettings(t *testing.T) {
- settings, err := maven.NewSettings(maven.DefaultRepositories)
- require.NoError(t, err)
-
- content, err := util.EncodeXML(settings)
- require.NoError(t, err)
-
- contentStr := string(content)
- newSettings := injectServersIntoMavenSettings(contentStr, nil)
-
- assert.Equal(t, contentStr, newSettings)
-}
-
-func TestInjectServersIntoDefaultMavenSettings(t *testing.T) {
- settings, err := maven.NewSettings(maven.DefaultRepositories)
- require.NoError(t, err)
-
- servers := []v1.Server{
- {
- ID: "image-repository",
- Username: "jpoth",
- Password: "changeit",
- Configuration: v1.Properties{
- "allowInsecureRegistries": boolean.FalseString,
- },
- },
- }
-
- content, err := util.EncodeXML(settings)
- require.NoError(t, err)
-
- contentStr := string(content)
- newSettings := injectServersIntoMavenSettings(contentStr, servers)
-
- settings.Servers = servers
- expectedNewSettings, err := util.EncodeXML(settings)
- require.NoError(t, err)
-
- expectedNewSettingsStr := string(expectedNewSettings)
- assert.Equal(t, expectedNewSettingsStr, newSettings)
-}
-
-func TestInjectServersIntoCustomMavenSettings(t *testing.T) {
- servers := []v1.Server{
- {
- ID: "image-repository",
- Username: "jpoth",
- Password: "changeit",
- Configuration: v1.Properties{
- "allowInsecureRegistries": boolean.FalseString,
- },
- },
- }
-
- newSettings := injectServersIntoMavenSettings(customSettings, servers)
-
- assert.Equal(t,
removeWhitespaces(expectedCustomSettingsWithExtraServers),
removeWhitespaces(newSettings))
-}
-
-func removeWhitespaces(s string) string {
- re := regexp.MustCompile(`\s`)
- return re.ReplaceAllString(s, "")
-}
diff --git a/pkg/client/camel/applyconfiguration/camel/v1/mavenbuildspec.go
b/pkg/client/camel/applyconfiguration/camel/v1/mavenbuildspec.go
index f9532c274..335e92cd0 100644
--- a/pkg/client/camel/applyconfiguration/camel/v1/mavenbuildspec.go
+++ b/pkg/client/camel/applyconfiguration/camel/v1/mavenbuildspec.go
@@ -33,7 +33,9 @@ type MavenBuildSpecApplyConfiguration struct {
// additional repositories
Repositories []RepositoryApplyConfiguration
`json:"repositories,omitempty"`
// Servers (auth)
- Servers []ServerApplyConfiguration `json:"servers,omitempty"`
+ //
+ // Deprecated: no longer in use.
+ DeprecatedServers []ServerApplyConfiguration `json:"servers,omitempty"`
}
// MavenBuildSpecApplyConfiguration constructs a declarative configuration of
the MavenBuildSpec type for use with
@@ -139,15 +141,15 @@ func (b *MavenBuildSpecApplyConfiguration)
WithRepositories(values ...*Repositor
return b
}
-// WithServers adds the given value to the Servers field in the declarative
configuration
+// WithDeprecatedServers adds the given value to the DeprecatedServers field
in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With"
function invocations.
-// If called multiple times, values provided by each call will be appended to
the Servers field.
-func (b *MavenBuildSpecApplyConfiguration) WithServers(values
...*ServerApplyConfiguration) *MavenBuildSpecApplyConfiguration {
+// If called multiple times, values provided by each call will be appended to
the DeprecatedServers field.
+func (b *MavenBuildSpecApplyConfiguration) WithDeprecatedServers(values
...*ServerApplyConfiguration) *MavenBuildSpecApplyConfiguration {
for i := range values {
if values[i] == nil {
- panic("nil value passed to WithServers")
+ panic("nil value passed to WithDeprecatedServers")
}
- b.Servers = append(b.Servers, *values[i])
+ b.DeprecatedServers = append(b.DeprecatedServers, *values[i])
}
return b
}
diff --git a/pkg/resources/config/crd/bases/camel.apache.org_builds.yaml
b/pkg/resources/config/crd/bases/camel.apache.org_builds.yaml
index 29903917c..8ce7eb075 100644
--- a/pkg/resources/config/crd/bases/camel.apache.org_builds.yaml
+++ b/pkg/resources/config/crd/bases/camel.apache.org_builds.yaml
@@ -572,7 +572,10 @@ spec:
type: object
type: array
servers:
- description: Servers (auth)
+ description: |-
+ Servers (auth)
+
+ Deprecated: no longer in use.
items:
description: Server see
link:https://maven.apache.org/settings.html[Maven
settings].
@@ -1502,7 +1505,10 @@ spec:
type: object
type: array
servers:
- description: Servers (auth)
+ description: |-
+ Servers (auth)
+
+ Deprecated: no longer in use.
items:
description: Server see
link:https://maven.apache.org/settings.html[Maven
settings].