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

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

commit b41957b61d33288e6bb06a85e197e20054ff2d14
Author: Tadayoshi Sato <[email protected]>
AuthorDate: Tue Aug 3 13:40:46 2021 +0900

    refactor(trait): move bool pointer functions to trait package
---
 pkg/trait/affinity.go              | 17 ++++++++---------
 pkg/trait/affinity_test.go         |  9 ++++-----
 pkg/trait/builder_test.go          |  3 +--
 pkg/trait/container.go             | 12 ++++++------
 pkg/trait/container_probes_test.go |  3 +--
 pkg/trait/environment.go           |  5 ++---
 pkg/trait/jvm.go                   |  8 ++++----
 pkg/trait/jvm_test.go              |  9 ++++-----
 pkg/trait/knative.go               | 16 ++++++++--------
 pkg/trait/logging.go               | 10 +++++-----
 pkg/trait/pod_test.go              |  3 +--
 pkg/trait/prometheus.go            |  4 ++--
 pkg/trait/pull_secret.go           |  9 ++++-----
 pkg/trait/toleration.go            |  3 +--
 pkg/trait/toleration_test.go       |  4 +---
 pkg/trait/util.go                  | 29 +++++++++++++++++++++++++++++
 pkg/util/util.go                   | 29 -----------------------------
 17 files changed, 81 insertions(+), 92 deletions(-)

diff --git a/pkg/trait/affinity.go b/pkg/trait/affinity.go
index ff86dbd..330bd58 100644
--- a/pkg/trait/affinity.go
+++ b/pkg/trait/affinity.go
@@ -27,7 +27,6 @@ import (
        "k8s.io/apimachinery/pkg/selection"
 
        v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-       "github.com/apache/camel-k/pkg/util"
 )
 
 // Allows constraining which nodes the integration pod(s) are eligible to be 
scheduled on, based on labels on the node,
@@ -55,17 +54,17 @@ type affinityTrait struct {
 func newAffinityTrait() Trait {
        return &affinityTrait{
                BaseTrait:       NewBaseTrait("affinity", 1300),
-               PodAffinity:     util.BoolP(false),
-               PodAntiAffinity: util.BoolP(false),
+               PodAffinity:     BoolP(false),
+               PodAntiAffinity: BoolP(false),
        }
 }
 
 func (t *affinityTrait) Configure(e *Environment) (bool, error) {
-       if util.IsNilOrFalse(t.Enabled) {
+       if IsNilOrFalse(t.Enabled) {
                return false, nil
        }
 
-       if util.IsTrue(t.PodAffinity) && util.IsTrue(t.PodAntiAffinity) {
+       if IsTrue(t.PodAffinity) && IsTrue(t.PodAntiAffinity) {
                return false, fmt.Errorf("both pod affinity and pod 
anti-affinity can't be set simultaneously")
        }
 
@@ -132,7 +131,7 @@ func (t *affinityTrait) addNodeAffinity(_ *Environment, 
podSpec *corev1.PodSpec)
 }
 
 func (t *affinityTrait) addPodAffinity(e *Environment, podSpec 
*corev1.PodSpec) error {
-       if util.IsNilOrFalse(t.PodAffinity) && len(t.PodAffinityLabels) == 0 {
+       if IsNilOrFalse(t.PodAffinity) && len(t.PodAffinityLabels) == 0 {
                return nil
        }
 
@@ -157,7 +156,7 @@ func (t *affinityTrait) addPodAffinity(e *Environment, 
podSpec *corev1.PodSpec)
                }
        }
 
-       if util.IsTrue(t.PodAffinity) {
+       if IsTrue(t.PodAffinity) {
                labelSelectorRequirements = append(labelSelectorRequirements, 
metav1.LabelSelectorRequirement{
                        Key:      v1.IntegrationLabel,
                        Operator: metav1.LabelSelectorOpIn,
@@ -183,7 +182,7 @@ func (t *affinityTrait) addPodAffinity(e *Environment, 
podSpec *corev1.PodSpec)
 }
 
 func (t *affinityTrait) addPodAntiAffinity(e *Environment, podSpec 
*corev1.PodSpec) error {
-       if util.IsNilOrFalse(t.PodAntiAffinity) && len(t.PodAntiAffinityLabels) 
== 0 {
+       if IsNilOrFalse(t.PodAntiAffinity) && len(t.PodAntiAffinityLabels) == 0 
{
                return nil
        }
 
@@ -208,7 +207,7 @@ func (t *affinityTrait) addPodAntiAffinity(e *Environment, 
podSpec *corev1.PodSp
                }
        }
 
-       if util.IsTrue(t.PodAntiAffinity) {
+       if IsTrue(t.PodAntiAffinity) {
                labelSelectorRequirements = append(labelSelectorRequirements, 
metav1.LabelSelectorRequirement{
                        Key:      v1.IntegrationLabel,
                        Operator: metav1.LabelSelectorOpIn,
diff --git a/pkg/trait/affinity_test.go b/pkg/trait/affinity_test.go
index 065b4dc..bce3441 100644
--- a/pkg/trait/affinity_test.go
+++ b/pkg/trait/affinity_test.go
@@ -26,7 +26,6 @@ import (
        metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 
        v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-       "github.com/apache/camel-k/pkg/util"
 )
 
 func TestConfigureAffinityTraitDoesSucceed(t *testing.T) {
@@ -41,8 +40,8 @@ func TestConfigureAffinityTraitDoesSucceed(t *testing.T) {
 func TestConfigureAffinityTraitWithConflictingAffinitiesFails(t *testing.T) {
        affinityTrait := createNominalAffinityTest()
        environment, _ := createNominalDeploymentTraitTest()
-       affinityTrait.PodAffinity = util.BoolP(true)
-       affinityTrait.PodAntiAffinity = util.BoolP(true)
+       affinityTrait.PodAffinity = BoolP(true)
+       affinityTrait.PodAntiAffinity = BoolP(true)
        configured, err := affinityTrait.Configure(environment)
 
        assert.False(t, configured)
@@ -117,7 +116,7 @@ func testApplyNodeAffinityLabelsDoesSucceed(t *testing.T, 
trait *affinityTrait,
 
 func TestApplyPodAntiAffinityLabelsDoesSucceed(t *testing.T) {
        affinityTrait := createNominalAffinityTest()
-       affinityTrait.PodAntiAffinity = util.BoolP(true)
+       affinityTrait.PodAntiAffinity = BoolP(true)
        affinityTrait.PodAntiAffinityLabels = []string{"criteria != value"}
 
        environment, deployment := createNominalDeploymentTraitTest()
@@ -150,7 +149,7 @@ func testApplyPodAntiAffinityLabelsDoesSucceed(t 
*testing.T, trait *affinityTrai
 
 func TestApplyPodAffinityLabelsDoesSucceed(t *testing.T) {
        affinityTrait := createNominalAffinityTest()
-       affinityTrait.PodAffinity = util.BoolP(true)
+       affinityTrait.PodAffinity = BoolP(true)
        affinityTrait.PodAffinityLabels = []string{"!criteria"}
 
        environment, deployment := createNominalDeploymentTraitTest()
diff --git a/pkg/trait/builder_test.go b/pkg/trait/builder_test.go
index 1c5282b..2c79bd6 100644
--- a/pkg/trait/builder_test.go
+++ b/pkg/trait/builder_test.go
@@ -27,7 +27,6 @@ import (
        metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 
        v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-       "github.com/apache/camel-k/pkg/util"
        "github.com/apache/camel-k/pkg/util/camel"
        "github.com/apache/camel-k/pkg/util/defaults"
        "github.com/apache/camel-k/pkg/util/kubernetes"
@@ -165,7 +164,7 @@ func TestMavenPropertyBuilderTrait(t *testing.T) {
 
 func createNominalBuilderTraitTest() *builderTrait {
        builderTrait := newBuilderTrait().(*builderTrait)
-       builderTrait.Enabled = util.BoolP(true)
+       builderTrait.Enabled = BoolP(true)
 
        return builderTrait
 }
diff --git a/pkg/trait/container.go b/pkg/trait/container.go
index ecdd833..94c155b 100644
--- a/pkg/trait/container.go
+++ b/pkg/trait/container.go
@@ -118,7 +118,7 @@ func newContainerTrait() Trait {
                ServicePort:     defaultServicePort,
                ServicePortName: defaultContainerPortName,
                Name:            defaultContainerName,
-               ProbesEnabled:   util.BoolP(false),
+               ProbesEnabled:   BoolP(false),
                LivenessScheme:  string(corev1.URISchemeHTTP),
                ReadinessScheme: string(corev1.URISchemeHTTP),
        }
@@ -133,7 +133,7 @@ func (t *containerTrait) Configure(e *Environment) (bool, 
error) {
                return false, nil
        }
 
-       if util.IsNilOrTrue(t.Auto) {
+       if IsNilOrTrue(t.Auto) {
                if t.Expose == nil {
                        e := 
e.Resources.GetServiceForIntegration(e.Integration) != nil
                        t.Expose = &e
@@ -192,7 +192,7 @@ func (t *containerTrait) configureDependencies(e 
*Environment) error {
                        e.Resources.Add(&kit)
                        e.Integration.SetIntegrationKit(&kit)
                }
-               if util.IsTrue(t.ProbesEnabled) {
+               if IsTrue(t.ProbesEnabled) {
                        if capability, ok := 
e.CamelCatalog.Runtime.Capabilities[v1.CapabilityHealth]; ok {
                                for _, dependency := range 
capability.Dependencies {
                                        
util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, 
dependency.GetDependencyID())
@@ -243,7 +243,7 @@ func (t *containerTrait) configureContainer(e *Environment) 
error {
        }
        // Deployment
        if err := e.Resources.VisitDeploymentE(func(deployment 
*appsv1.Deployment) error {
-               if util.IsTrue(t.ProbesEnabled) && portName == 
defaultContainerPortName {
+               if IsTrue(t.ProbesEnabled) && portName == 
defaultContainerPortName {
                        t.configureProbes(&container, t.Port, defaultProbePath)
                }
 
@@ -270,7 +270,7 @@ func (t *containerTrait) configureContainer(e *Environment) 
error {
 
        // Knative Service
        if err := e.Resources.VisitKnativeServiceE(func(service 
*serving.Service) error {
-               if util.IsTrue(t.ProbesEnabled) && portName == 
defaultContainerPortName {
+               if IsTrue(t.ProbesEnabled) && portName == 
defaultContainerPortName {
                        // don't set the port on Knative service as it is not 
allowed.
                        t.configureProbes(&container, 0, defaultProbePath)
                }
@@ -309,7 +309,7 @@ func (t *containerTrait) configureContainer(e *Environment) 
error {
 
        // CronJob
        if err := e.Resources.VisitCronJobE(func(cron *v1beta1.CronJob) error {
-               if util.IsTrue(t.ProbesEnabled) && portName == 
defaultContainerPortName {
+               if IsTrue(t.ProbesEnabled) && portName == 
defaultContainerPortName {
                        t.configureProbes(&container, t.Port, defaultProbePath)
                }
 
diff --git a/pkg/trait/container_probes_test.go 
b/pkg/trait/container_probes_test.go
index b58c7f2..c4d496d 100644
--- a/pkg/trait/container_probes_test.go
+++ b/pkg/trait/container_probes_test.go
@@ -28,7 +28,6 @@ import (
        corev1 "k8s.io/api/core/v1"
 
        v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-       "github.com/apache/camel-k/pkg/util"
        "github.com/apache/camel-k/pkg/util/camel"
        "github.com/apache/camel-k/pkg/util/kubernetes"
 )
@@ -59,7 +58,7 @@ func newTestProbesEnv(t *testing.T, provider 
v1.RuntimeProvider) Environment {
 
 func newTestContainerTrait() *containerTrait {
        tr := newContainerTrait().(*containerTrait)
-       tr.ProbesEnabled = util.BoolP(true)
+       tr.ProbesEnabled = BoolP(true)
 
        return tr
 }
diff --git a/pkg/trait/environment.go b/pkg/trait/environment.go
index bfc8cae..8fee827 100644
--- a/pkg/trait/environment.go
+++ b/pkg/trait/environment.go
@@ -19,7 +19,6 @@ package trait
 
 import (
        v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-       "github.com/apache/camel-k/pkg/util"
        "github.com/apache/camel-k/pkg/util/defaults"
        "github.com/apache/camel-k/pkg/util/envvar"
 )
@@ -54,7 +53,7 @@ const (
 func newEnvironmentTrait() Trait {
        return &environmentTrait{
                BaseTrait:     NewBaseTrait("environment", 800),
-               ContainerMeta: util.BoolP(true),
+               ContainerMeta: BoolP(true),
        }
 }
 
@@ -75,7 +74,7 @@ func (t *environmentTrait) Apply(e *Environment) error {
        envvar.SetVal(&e.EnvVars, envVarMountPathConfigMaps, 
configConfigmapsMountPath)
        envvar.SetVal(&e.EnvVars, envVarMountPathSecrets, 
configSecretsMountPath)
 
-       if util.IsNilOrTrue(t.ContainerMeta) {
+       if IsNilOrTrue(t.ContainerMeta) {
                envvar.SetValFrom(&e.EnvVars, envVarNamespace, 
"metadata.namespace")
                envvar.SetValFrom(&e.EnvVars, envVarPodName, "metadata.name")
        }
diff --git a/pkg/trait/jvm.go b/pkg/trait/jvm.go
index 1371e03..f13099d 100644
--- a/pkg/trait/jvm.go
+++ b/pkg/trait/jvm.go
@@ -62,7 +62,7 @@ func newJvmTrait() Trait {
        return &jvmTrait{
                BaseTrait:    NewBaseTrait("jvm", 2000),
                DebugAddress: "*:5005",
-               PrintCommand: util.BoolP(true),
+               PrintCommand: BoolP(true),
        }
 }
 
@@ -132,9 +132,9 @@ func (t *jvmTrait) Apply(e *Environment) error {
        args := container.Args
 
        // Remote debugging
-       if util.IsTrue(t.Debug) {
+       if IsTrue(t.Debug) {
                suspend := "n"
-               if util.IsTrue(t.DebugSuspend) {
+               if IsTrue(t.DebugSuspend) {
                        suspend = "y"
                }
                args = append(args,
@@ -184,7 +184,7 @@ func (t *jvmTrait) Apply(e *Environment) error {
        args = append(args, "-cp", strings.Join(items, ":"))
        args = append(args, e.CamelCatalog.Runtime.ApplicationClass)
 
-       if util.IsNilOrTrue(t.PrintCommand) {
+       if IsNilOrTrue(t.PrintCommand) {
                args = append([]string{"exec", "java"}, args...)
                container.Command = []string{"/bin/sh", "-c"}
                cmd := strings.Join(args, " ")
diff --git a/pkg/trait/jvm_test.go b/pkg/trait/jvm_test.go
index ebf7909b..3337972 100644
--- a/pkg/trait/jvm_test.go
+++ b/pkg/trait/jvm_test.go
@@ -35,7 +35,6 @@ import (
 
        v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
        "github.com/apache/camel-k/pkg/builder"
-       "github.com/apache/camel-k/pkg/util"
        "github.com/apache/camel-k/pkg/util/camel"
        "github.com/apache/camel-k/pkg/util/kubernetes"
        "github.com/apache/camel-k/pkg/util/test"
@@ -148,8 +147,8 @@ func TestApplyJvmTraitWithKNativeResource(t *testing.T) {
 
 func TestApplyJvmTraitWithDebugEnabled(t *testing.T) {
        trait, environment := 
createNominalJvmTest(v1.IntegrationKitTypePlatform)
-       trait.Debug = util.BoolP(true)
-       trait.DebugSuspend = util.BoolP(true)
+       trait.Debug = BoolP(true)
+       trait.DebugSuspend = BoolP(true)
 
        d := appsv1.Deployment{
                Spec: appsv1.DeploymentSpec{
@@ -257,8 +256,8 @@ func createNominalJvmTest(kitType string) (*jvmTrait, 
*Environment) {
        client, _ := test.NewFakeClient()
 
        trait := newJvmTrait().(*jvmTrait)
-       trait.Enabled = util.BoolP(true)
-       trait.PrintCommand = util.BoolP(false)
+       trait.Enabled = BoolP(true)
+       trait.PrintCommand = BoolP(false)
        trait.Ctx = context.TODO()
        trait.Client = client
 
diff --git a/pkg/trait/knative.go b/pkg/trait/knative.go
index 6a9018c..fe4b1de 100644
--- a/pkg/trait/knative.go
+++ b/pkg/trait/knative.go
@@ -104,7 +104,7 @@ func (t *knativeTrait) IsAllowedInProfile(profile 
v1.TraitProfile) bool {
 }
 
 func (t *knativeTrait) Configure(e *Environment) (bool, error) {
-       if util.IsFalse(t.Enabled) {
+       if IsFalse(t.Enabled) {
                return false, nil
        }
 
@@ -112,7 +112,7 @@ func (t *knativeTrait) Configure(e *Environment) (bool, 
error) {
                return false, nil
        }
 
-       if util.IsNilOrTrue(t.Auto) {
+       if IsNilOrTrue(t.Auto) {
                if len(t.ChannelSources) == 0 {
                        items := make([]string, 0)
                        sources, err := 
kubernetes.ResolveIntegrationSources(e.C, e.Client, e.Integration, e.Resources)
@@ -206,7 +206,7 @@ func (t *knativeTrait) Configure(e *Environment) (bool, 
error) {
 }
 
 func (t *knativeTrait) Apply(e *Environment) error {
-       if util.IsTrue(t.SinkBinding) {
+       if IsTrue(t.SinkBinding) {
                util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, 
"mvn:org.apache.camel.k:camel-k-knative")
        }
 
@@ -264,7 +264,7 @@ func (t *knativeTrait) configureChannels(e *Environment, 
env *knativeapi.CamelEn
                                knativeapi.CamelMetaKnativeKind:       ref.Kind,
                                knativeapi.CamelMetaKnativeReply:      "false",
                        }
-                       if util.IsTrue(t.FilterSourceChannels) {
+                       if IsTrue(t.FilterSourceChannels) {
                                
meta[knativeapi.CamelMetaFilterPrefix+knativeHistoryHeader] = loc.Host
                        }
                        svc := knativeapi.CamelServiceDefinition{
@@ -285,7 +285,7 @@ func (t *knativeTrait) configureChannels(e *Environment, 
env *knativeapi.CamelEn
                return err
        }
 
-       if util.IsNilOrFalse(t.SinkBinding) {
+       if IsNilOrFalse(t.SinkBinding) {
                // Sinks
                err = t.ifServiceMissingDo(e, env, t.ChannelSinks, 
knativeapi.CamelServiceTypeChannel, knativeapi.CamelEndpointKindSink,
                        func(ref *corev1.ObjectReference, serviceURI string, 
urlProvider func() (*url.URL, error)) error {
@@ -345,7 +345,7 @@ func (t *knativeTrait) configureEndpoints(e *Environment, 
env *knativeapi.CamelE
        }
 
        // Sinks
-       if util.IsNilOrFalse(t.SinkBinding) {
+       if IsNilOrFalse(t.SinkBinding) {
                err := t.ifServiceMissingDo(e, env, t.EndpointSinks, 
knativeapi.CamelServiceTypeEndpoint, knativeapi.CamelEndpointKindSink,
                        func(ref *corev1.ObjectReference, serviceURI string, 
urlProvider func() (*url.URL, error)) error {
                                loc, err := urlProvider()
@@ -403,7 +403,7 @@ func (t *knativeTrait) configureEvents(e *Environment, env 
*knativeapi.CamelEnvi
        }
 
        // Sinks
-       if util.IsNilOrFalse(t.SinkBinding) {
+       if IsNilOrFalse(t.SinkBinding) {
                err = t.ifServiceMissingDo(e, env, t.EventSinks, 
knativeapi.CamelServiceTypeEvent, knativeapi.CamelEndpointKindSink,
                        func(ref *corev1.ObjectReference, serviceURI string, 
urlProvider func() (*url.URL, error)) error {
                                loc, err := urlProvider()
@@ -444,7 +444,7 @@ func (t *knativeTrait) isSinkBindingAllowed(e *Environment) 
bool {
 }
 
 func (t *knativeTrait) configureSinkBinding(e *Environment, env 
*knativeapi.CamelEnvironment) error {
-       if util.IsNilOrFalse(t.SinkBinding) {
+       if IsNilOrFalse(t.SinkBinding) {
                return nil
        }
        var serviceType knativeapi.CamelServiceType
diff --git a/pkg/trait/logging.go b/pkg/trait/logging.go
index 808ce1c..90e107b 100644
--- a/pkg/trait/logging.go
+++ b/pkg/trait/logging.go
@@ -59,7 +59,7 @@ func newLoggingTraitTrait() Trait {
 }
 
 func (l loggingTrait) Configure(environment *Environment) (bool, error) {
-       if util.IsFalse(l.Enabled) {
+       if IsFalse(l.Enabled) {
                return false, nil
        }
 
@@ -69,7 +69,7 @@ func (l loggingTrait) Configure(environment *Environment) 
(bool, error) {
 
 func (l loggingTrait) Apply(environment *Environment) error {
        if environment.IntegrationInPhase(v1.IntegrationPhaseInitialization) {
-               if util.IsTrue(l.Json) {
+               if IsTrue(l.Json) {
                        if environment.Integration.Status.Dependencies == nil {
                                environment.Integration.Status.Dependencies = 
make([]string, 0)
                        }
@@ -85,15 +85,15 @@ func (l loggingTrait) Apply(environment *Environment) error 
{
                envvar.SetVal(&environment.EnvVars, 
envVarQuarkusLogConsoleFormat, l.Format)
        }
 
-       if util.IsTrue(l.Json) {
+       if IsTrue(l.Json) {
                envvar.SetVal(&environment.EnvVars, 
envVarQuarkusLogConsoleJson, True)
-               if util.IsTrue(l.JsonPrettyPrint) {
+               if IsTrue(l.JsonPrettyPrint) {
                        envvar.SetVal(&environment.EnvVars, 
envVarQuarkusLogConsoleJsonPrettyPrint, True)
                }
        } else {
                envvar.SetVal(&environment.EnvVars, 
envVarQuarkusLogConsoleJson, False)
 
-               if util.IsNilOrTrue(l.Color) {
+               if IsNilOrTrue(l.Color) {
                        envvar.SetVal(&environment.EnvVars, 
envVarQuarkusLogConsoleColor, True)
                }
        }
diff --git a/pkg/trait/pod_test.go b/pkg/trait/pod_test.go
index 48d20d0..ca4bf0c 100755
--- a/pkg/trait/pod_test.go
+++ b/pkg/trait/pod_test.go
@@ -12,7 +12,6 @@ import (
        metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 
        v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-       "github.com/apache/camel-k/pkg/util"
        "github.com/apache/camel-k/pkg/util/kubernetes"
 )
 
@@ -73,7 +72,7 @@ func TestChangeEnvVariables(t *testing.T) {
 
 func createPodTest(podSpecTemplate string) (*podTrait, *Environment, 
*appsv1.Deployment) {
        trait := newPodTrait().(*podTrait)
-       trait.Enabled = util.BoolP(true)
+       trait.Enabled = BoolP(true)
 
        var podSpec v1.PodSpec
        if podSpecTemplate != "" {
diff --git a/pkg/trait/prometheus.go b/pkg/trait/prometheus.go
index 8ef81b5..8971e75 100644
--- a/pkg/trait/prometheus.go
+++ b/pkg/trait/prometheus.go
@@ -52,7 +52,7 @@ type prometheusTrait struct {
 func newPrometheusTrait() Trait {
        return &prometheusTrait{
                BaseTrait:  NewBaseTrait("prometheus", 1900),
-               PodMonitor: util.BoolP(true),
+               PodMonitor: BoolP(true),
        }
 }
 
@@ -102,7 +102,7 @@ func (t *prometheusTrait) Apply(e *Environment) (err error) 
{
        condition.Message = fmt.Sprintf("%s(%d)", container.Name, 
containerPort.ContainerPort)
 
        // Add the PodMonitor resource
-       if util.IsTrue(t.PodMonitor) {
+       if IsTrue(t.PodMonitor) {
                portName := containerPort.Name
                // Knative defaults to naming the userland container port 
"user-port".
                // Let's rely on that default, granted it is not officially 
part of the Knative
diff --git a/pkg/trait/pull_secret.go b/pkg/trait/pull_secret.go
index 82b3c64..005cdae 100644
--- a/pkg/trait/pull_secret.go
+++ b/pkg/trait/pull_secret.go
@@ -22,7 +22,6 @@ import (
 
        v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
        "github.com/apache/camel-k/pkg/platform"
-       "github.com/apache/camel-k/pkg/util"
        "github.com/apache/camel-k/pkg/util/kubernetes"
        "github.com/apache/camel-k/pkg/util/openshift"
        "github.com/pkg/errors"
@@ -61,7 +60,7 @@ func newPullSecretTrait() Trait {
 }
 
 func (t *pullSecretTrait) Configure(e *Environment) (bool, error) {
-       if util.IsFalse(t.Enabled) {
+       if IsFalse(t.Enabled) {
                return false, nil
        }
 
@@ -69,7 +68,7 @@ func (t *pullSecretTrait) Configure(e *Environment) (bool, 
error) {
                return false, nil
        }
 
-       if util.IsNilOrTrue(t.Auto) {
+       if IsNilOrTrue(t.Auto) {
                if t.SecretName == "" {
                        secret := e.Platform.Status.Build.Registry.Secret
                        if secret != "" {
@@ -99,7 +98,7 @@ func (t *pullSecretTrait) Configure(e *Environment) (bool, 
error) {
                }
        }
 
-       return t.SecretName != "" || util.IsTrue(t.ImagePullerDelegation), nil
+       return t.SecretName != "" || IsTrue(t.ImagePullerDelegation), nil
 }
 
 func (t *pullSecretTrait) Apply(e *Environment) error {
@@ -110,7 +109,7 @@ func (t *pullSecretTrait) Apply(e *Environment) error {
                        })
                })
        }
-       if util.IsTrue(t.ImagePullerDelegation) {
+       if IsTrue(t.ImagePullerDelegation) {
                if err := t.delegateImagePuller(e); err != nil {
                        return err
                }
diff --git a/pkg/trait/toleration.go b/pkg/trait/toleration.go
index bc0fd8e..add1428 100644
--- a/pkg/trait/toleration.go
+++ b/pkg/trait/toleration.go
@@ -23,7 +23,6 @@ import (
        corev1 "k8s.io/api/core/v1"
 
        v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-       "github.com/apache/camel-k/pkg/util"
        "github.com/apache/camel-k/pkg/util/kubernetes"
 )
 
@@ -54,7 +53,7 @@ func newTolerationTrait() Trait {
 }
 
 func (t *tolerationTrait) Configure(e *Environment) (bool, error) {
-       if util.IsNilOrFalse(t.Enabled) {
+       if IsNilOrFalse(t.Enabled) {
                return false, nil
        }
 
diff --git a/pkg/trait/toleration_test.go b/pkg/trait/toleration_test.go
index fcd26af..5e0b46b 100644
--- a/pkg/trait/toleration_test.go
+++ b/pkg/trait/toleration_test.go
@@ -23,8 +23,6 @@ import (
        "github.com/stretchr/testify/assert"
 
        corev1 "k8s.io/api/core/v1"
-
-       "github.com/apache/camel-k/pkg/util"
 )
 
 func TestConfigureTolerationTraitMissingTaint(t *testing.T) {
@@ -128,7 +126,7 @@ func TestTolerationValidTaints(t *testing.T) {
 
 func createNominalTolerationTrait() *tolerationTrait {
        tolerationTrait := newTolerationTrait().(*tolerationTrait)
-       tolerationTrait.Enabled = util.BoolP(true)
+       tolerationTrait.Enabled = BoolP(true)
        tolerationTrait.Taints = make([]string, 0)
 
        return tolerationTrait
diff --git a/pkg/trait/util.go b/pkg/trait/util.go
index af88cc4..630776d 100644
--- a/pkg/trait/util.go
+++ b/pkg/trait/util.go
@@ -220,3 +220,32 @@ func AddSourceDependencies(source v1.SourceSpec, catalog 
*camel.RuntimeCatalog)
 
        return dependencies
 }
+
+/// Bool pointer operations:
+
+// BoolP returns a pointer to a bool value
+func BoolP(b bool) *bool {
+       return &b
+}
+
+// IsTrue checks if the bool pointer is defined and true
+func IsTrue(b *bool) bool {
+       return b != nil && *b
+}
+
+// IsNilOrTrue checks if the bool pointer is nil or true.
+// You can use it if the bool pointer is meant to be true by default.
+func IsNilOrTrue(b *bool) bool {
+       return b == nil || *b
+}
+
+// IsFalse checks if the bool pointer is defined and false
+func IsFalse(b *bool) bool {
+       return b != nil && !*b
+}
+
+// IsNilOrFalse checks if the bool pointer is nil or false.
+// You can use it if the bool pointer is meant to be false by default.
+func IsNilOrFalse(b *bool) bool {
+       return b == nil || !*b
+}
diff --git a/pkg/util/util.go b/pkg/util/util.go
index 7286301..4a2ffe3 100644
--- a/pkg/util/util.go
+++ b/pkg/util/util.go
@@ -498,35 +498,6 @@ func GetEnvironmentVariable(variable string) (string, 
error) {
        return value, nil
 }
 
-/// Bool operations:
-
-// BoolP returns a pointer to a bool value
-func BoolP(b bool) *bool {
-       return &b
-}
-
-// IsTrue checks if the bool pointer is defined and true
-func IsTrue(b *bool) bool {
-       return b != nil && *b
-}
-
-// IsNilOrTrue checks if the bool pointer is nil or true.
-// You can use it if the bool pointer is meant to be true by default.
-func IsNilOrTrue(b *bool) bool {
-       return b == nil || *b
-}
-
-// IsFalse checks if the bool pointer is defined and false
-func IsFalse(b *bool) bool {
-       return b != nil && !*b
-}
-
-// IsNilOrFalse checks if the bool pointer is nil or false.
-// You can use it if the bool pointer is meant to be false by default.
-func IsNilOrFalse(b *bool) bool {
-       return b == nil || !*b
-}
-
 // EvaluateCLIAndLazyEnvVars -- Function that creates a list of environment
 // variables with entries VAR=value that can be passed when running the 
integration.
 func EvaluateCLIAndLazyEnvVars() ([]string, error) {

Reply via email to