diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 28af9d66de..1c2c701255 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -37,7 +37,6 @@ updates: - dependency-name: "github.com/mitchellh/mapstructure" - dependency-name: "github.com/onsi/gomega" - dependency-name: "github.com/operator-framework/api" - - dependency-name: "github.com/pkg/errors" - dependency-name: "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring" - dependency-name: "github.com/prometheus/client_golang" - dependency-name: "github.com/prometheus/client_model" diff --git a/go.mod b/go.mod index 406ef63743..aed742b1b4 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,6 @@ require ( github.com/apache/camel-k/v2/pkg/kamelet/repository v0.0.0 github.com/container-tools/spectrum v0.6.11 github.com/evanphx/json-patch v4.12.0+incompatible - github.com/fatih/camelcase v1.0.0 github.com/fatih/structs v1.1.0 github.com/gertd/go-pluralize v0.2.1 github.com/go-logr/logr v1.2.4 @@ -25,6 +24,7 @@ require ( github.com/openshift/api v3.9.1-0.20190927182313-d4a64ec2cbd8+incompatible github.com/operator-framework/api v0.13.0 github.com/otiai10/copy v1.9.0 + github.com/pkg/errors v0.9.1 github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.60.0 github.com/prometheus/client_golang v1.15.1 github.com/prometheus/client_model v0.4.0 @@ -135,7 +135,6 @@ require ( github.com/opencontainers/image-spec v1.0.3-0.20220114050600-8b9d41f48198 // indirect github.com/opencontainers/runc v1.0.2 // indirect github.com/pelletier/go-toml/v2 v2.0.6 // indirect - github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/procfs v0.9.0 // indirect github.com/prometheus/statsd_exporter v0.21.0 // indirect diff --git a/go.sum b/go.sum index c362a348eb..a4e8550816 100644 --- a/go.sum +++ b/go.sum @@ -414,8 +414,6 @@ github.com/evanphx/json-patch v4.12.0+incompatible h1:4onqiflcdA9EOZ4RxV643DvftH github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww= github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4= -github.com/fatih/camelcase v1.0.0 h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8= -github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= diff --git a/pkg/cmd/version.go b/pkg/cmd/version.go index 3314e1274a..c0bedebec6 100644 --- a/pkg/cmd/version.go +++ b/pkg/cmd/version.go @@ -21,24 +21,18 @@ import ( "context" "fmt" "regexp" - "strings" v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1" "github.com/apache/camel-k/v2/pkg/util/camel" - "golang.org/x/text/cases" - "golang.org/x/text/language" - k8serrors "k8s.io/apimachinery/pkg/api/errors" "github.com/Masterminds/semver" - "github.com/fatih/camelcase" "github.com/spf13/cobra" "github.com/apache/camel-k/v2/pkg/client" platformutil "github.com/apache/camel-k/v2/pkg/platform" "github.com/apache/camel-k/v2/pkg/util/defaults" - "github.com/apache/camel-k/v2/pkg/util/log" ) // VersionVariant may be overridden at build time. @@ -150,18 +144,12 @@ func operatorInfo(ctx context.Context, c client.Client, namespace string) (map[s return nil, err } - // Useful information - infos["name"] = platform.Name - infos["version"] = platform.Status.Version - infos["publishStrategy"] = string(platform.Status.Build.PublishStrategy) - infos["runtimeVersion"] = platform.Status.Build.RuntimeVersion - infos["registryAddress"] = platform.Status.Build.Registry.Address - - if platform.Status.Info != nil { - for k, v := range platform.Status.Info { - infos[k] = v - } - } + infos["Name"] = platform.Name + infos["Version"] = platform.Status.Version + infos["Publish strategy"] = string(platform.Status.Build.PublishStrategy) + infos["Runtime version"] = platform.Status.Build.RuntimeVersion + infos["Registry address"] = platform.Status.Build.Registry.Address + infos["Git commit"] = platform.Status.Info["gitCommit"] catalog, err := camel.LoadCatalog(ctx, c, namespace, v1.RuntimeSpec{Version: platform.Status.Build.RuntimeVersion, Provider: platform.Status.Build.RuntimeProvider}) if err != nil { @@ -170,25 +158,12 @@ func operatorInfo(ctx context.Context, c client.Client, namespace string) (map[s if catalog == nil { return nil, fmt.Errorf("CamelCatalog can't be found in %s namespace", platform.Namespace) } - for k, v := range catalog.CamelCatalogSpec.Runtime.Metadata { - infos[k] = v - } - ccInfo := fromCamelCase(infos) - log.Debugf("Operator Info for namespace %s: %v", namespace, ccInfo) - return ccInfo, nil -} - -func fromCamelCase(infos map[string]string) map[string]string { - textKeys := make(map[string]string) - - for k, v := range infos { - key := cases.Title(language.English).String(strings.Join(camelcase.Split(k), " ")) - key = replaceRegexp.ReplaceAllString(key, " ") - textKeys[key] = v - } + infos["Camel Quarkus version"] = catalog.CamelCatalogSpec.Runtime.Metadata["camel-quarkus.version"] + infos["Camel version"] = catalog.CamelCatalogSpec.Runtime.Metadata["camel.version"] + infos["Quarkus version"] = catalog.CamelCatalogSpec.Runtime.Metadata["quarkus.version"] - return textKeys + return infos, nil } func operatorVersion(ctx context.Context, c client.Client, namespace string) (string, error) { diff --git a/pkg/cmd/version_test.go b/pkg/cmd/version_test.go index 6dda7f1b65..053e0dae8a 100644 --- a/pkg/cmd/version_test.go +++ b/pkg/cmd/version_test.go @@ -101,9 +101,9 @@ func TestOperatorVersionVerbose(t *testing.T) { assert.Nil(t, err) assert.Equal(t, true, versionCmdOptions.Verbose) assert.Contains(t, output, fmt.Sprintf("Camel K Operator %s\n", defaults.Version)) - assert.Contains(t, output, fmt.Sprintf("Camel Version: %s\n", catalog.Spec.Runtime.Metadata["camel.version"])) - assert.Contains(t, output, fmt.Sprintf("Camel Quarkus Version: %s\n", catalog.Spec.Runtime.Metadata["camel-quarkus.version"])) - assert.Contains(t, output, fmt.Sprintf("Quarkus Version: %s\n", catalog.Spec.Runtime.Metadata["quarkus.version"])) + assert.Contains(t, output, fmt.Sprintf("Camel version: %s\n", catalog.Spec.Runtime.Metadata["camel.version"])) + assert.Contains(t, output, fmt.Sprintf("Camel Quarkus version: %s\n", catalog.Spec.Runtime.Metadata["camel-quarkus.version"])) + assert.Contains(t, output, fmt.Sprintf("Quarkus version: %s\n", catalog.Spec.Runtime.Metadata["quarkus.version"])) } func TestCompatibleVersions(t *testing.T) {