This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 1d1c8d12de528d556a12d430d6a9a9106f029a0c
Author: Antonin Stefanutti <anto...@stefanutti.fr>
AuthorDate: Fri Mar 26 15:29:28 2021 +0100

    chore: Clean-up util methods
---
 pkg/install/operator.go                            |  2 +-
 pkg/trait/toleration.go                            |  2 +-
 pkg/util/kubernetes/{camel_labels.go => camel.go}  |  4 +-
 pkg/util/kubernetes/{core_client.go => client.go}  | 46 ----------------------
 .../kubernetes/{core_factory.go => factory.go}     |  2 +-
 pkg/util/olm/operator.go                           |  2 +-
 6 files changed, 6 insertions(+), 52 deletions(-)

diff --git a/pkg/install/operator.go b/pkg/install/operator.go
index 9798d1a..1fc6cf7 100644
--- a/pkg/install/operator.go
+++ b/pkg/install/operator.go
@@ -90,7 +90,7 @@ func OperatorOrCollect(ctx context.Context, c client.Client, 
cfg OperatorConfigu
                if cfg.Tolerations != nil {
                        if d, ok := o.(*appsv1.Deployment); ok {
                                if d.Labels["camel.apache.org/component"] == 
"operator" {
-                                       tolerations, err := 
kubernetes.GetTolerations(cfg.Tolerations)
+                                       tolerations, err := 
kubernetes.NewTolerations(cfg.Tolerations)
                                        if err != nil {
                                                fmt.Println("Warning: could not 
parse the configured tolerations!")
                                        }
diff --git a/pkg/trait/toleration.go b/pkg/trait/toleration.go
index 9b97c6e..bc0fd8e 100644
--- a/pkg/trait/toleration.go
+++ b/pkg/trait/toleration.go
@@ -66,7 +66,7 @@ func (t *tolerationTrait) Configure(e *Environment) (bool, 
error) {
 }
 
 func (t *tolerationTrait) Apply(e *Environment) (err error) {
-       tolerations, err := kubernetes.GetTolerations(t.Taints)
+       tolerations, err := kubernetes.NewTolerations(t.Taints)
        if err != nil {
                return err
        }
diff --git a/pkg/util/kubernetes/camel_labels.go b/pkg/util/kubernetes/camel.go
similarity index 98%
rename from pkg/util/kubernetes/camel_labels.go
rename to pkg/util/kubernetes/camel.go
index cc31559..ca487b5 100644
--- a/pkg/util/kubernetes/camel_labels.go
+++ b/pkg/util/kubernetes/camel.go
@@ -20,13 +20,13 @@ package kubernetes
 import (
        "strings"
 
-       camelv1 "github.com/apache/camel-k/pkg/apis/camel/v1"
        v1 "k8s.io/api/core/v1"
        metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
        "k8s.io/apimachinery/pkg/runtime"
+
+       camelv1 "github.com/apache/camel-k/pkg/apis/camel/v1"
 )
 
-// CamelCreatorLabelPrefix --
 const (
        CamelCreatorLabelPrefix = "camel.apache.org/created.by"
 
diff --git a/pkg/util/kubernetes/core_client.go b/pkg/util/kubernetes/client.go
similarity index 83%
rename from pkg/util/kubernetes/core_client.go
rename to pkg/util/kubernetes/client.go
index 621a90f..ceecef5 100644
--- a/pkg/util/kubernetes/core_client.go
+++ b/pkg/util/kubernetes/client.go
@@ -30,7 +30,6 @@ import (
        "github.com/apache/camel-k/pkg/client"
 )
 
-// GetIntegrationPlatform --
 func GetIntegrationPlatform(context context.Context, client ctrl.Reader, name 
string, namespace string) (*v1.IntegrationPlatform, error) {
        key := ctrl.ObjectKey{
                Name:      name,
@@ -46,7 +45,6 @@ func GetIntegrationPlatform(context context.Context, client 
ctrl.Reader, name st
        return &answer, nil
 }
 
-// GetIntegrationKit --
 func GetIntegrationKit(context context.Context, client ctrl.Reader, name 
string, namespace string) (*v1.IntegrationKit, error) {
        key := ctrl.ObjectKey{
                Name:      name,
@@ -62,23 +60,6 @@ func GetIntegrationKit(context context.Context, client 
ctrl.Reader, name string,
        return &answer, nil
 }
 
-// GetIntegration --
-func GetIntegration(context context.Context, client ctrl.Reader, name string, 
namespace string) (*v1.Integration, error) {
-       key := ctrl.ObjectKey{
-               Name:      name,
-               Namespace: namespace,
-       }
-
-       answer := v1.NewIntegration(namespace, name)
-
-       if err := client.Get(context, key, &answer); err != nil {
-               return nil, err
-       }
-
-       return &answer, nil
-}
-
-// GetBuild --
 func GetBuild(context context.Context, client client.Client, name string, 
namespace string) (*v1.Build, error) {
        key := ctrl.ObjectKey{
                Name:      name,
@@ -94,7 +75,6 @@ func GetBuild(context context.Context, client client.Client, 
name string, namesp
        return &answer, nil
 }
 
-// GetConfigMap --
 func GetConfigMap(context context.Context, client ctrl.Reader, name string, 
namespace string) (*corev1.ConfigMap, error) {
        key := ctrl.ObjectKey{
                Name:      name,
@@ -119,7 +99,6 @@ func GetConfigMap(context context.Context, client 
ctrl.Reader, name string, name
        return &answer, nil
 }
 
-// GetSecret --
 func GetSecret(context context.Context, client ctrl.Reader, name string, 
namespace string) (*corev1.Secret, error) {
        key := ctrl.ObjectKey{
                Name:      name,
@@ -144,31 +123,6 @@ func GetSecret(context context.Context, client 
ctrl.Reader, name string, namespa
        return &answer, nil
 }
 
-// GetService --
-func GetService(context context.Context, client ctrl.Reader, name string, 
namespace string) (*corev1.Service, error) {
-       key := ctrl.ObjectKey{
-               Name:      name,
-               Namespace: namespace,
-       }
-
-       answer := corev1.Service{
-               TypeMeta: metav1.TypeMeta{
-                       Kind:       "Service",
-                       APIVersion: "v1",
-               },
-               ObjectMeta: metav1.ObjectMeta{
-                       Name:      name,
-                       Namespace: namespace,
-               },
-       }
-
-       if err := client.Get(context, key, &answer); err != nil {
-               return nil, err
-       }
-
-       return &answer, nil
-}
-
 // GetSecretRefValue returns the value of a secret in the supplied namespace
 func GetSecretRefValue(ctx context.Context, client ctrl.Reader, namespace 
string, selector *corev1.SecretKeySelector) (string, error) {
        data, err := GetSecretRefData(ctx, client, namespace, selector)
diff --git a/pkg/util/kubernetes/core_factory.go 
b/pkg/util/kubernetes/factory.go
similarity index 96%
rename from pkg/util/kubernetes/core_factory.go
rename to pkg/util/kubernetes/factory.go
index 5ae1891..a85c472 100644
--- a/pkg/util/kubernetes/core_factory.go
+++ b/pkg/util/kubernetes/factory.go
@@ -28,7 +28,7 @@ import (
 var validTaintRegexp = 
regexp.MustCompile(`^([\w\/_\-\.]+)(=)?([\w_\-\.]+)?:(NoSchedule|NoExecute|PreferNoSchedule):?(\d*)?$`)
 
 // GetTolerations build an array of Tolerations from an array of string
-func GetTolerations(taints []string) ([]corev1.Toleration, error) {
+func NewTolerations(taints []string) ([]corev1.Toleration, error) {
        tolerations := make([]corev1.Toleration, 0)
        for _, t := range taints {
                if !validTaintRegexp.MatchString(t) {
diff --git a/pkg/util/olm/operator.go b/pkg/util/olm/operator.go
index 360cc15..896b241 100644
--- a/pkg/util/olm/operator.go
+++ b/pkg/util/olm/operator.go
@@ -207,7 +207,7 @@ func Install(ctx context.Context, client client.Client, 
namespace string, global
 
 func maybeSetTolerations(sub *operatorsv1alpha1.Subscription, tolArray 
[]string) error {
        if tolArray != nil {
-               tolerations, err := kubernetes.GetTolerations(tolArray)
+               tolerations, err := kubernetes.NewTolerations(tolArray)
                if err != nil {
                        return err
                }

Reply via email to