Skip to content

Commit

Permalink
chore(deps): remove camelcase dependency
Browse files Browse the repository at this point in the history
Ref #4326
  • Loading branch information
squakez committed May 11, 2023
1 parent 773f686 commit 1708646
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 43 deletions.
1 change: 0 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
45 changes: 10 additions & 35 deletions pkg/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand All @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 1708646

Please sign in to comment.