camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nferr...@apache.org
Subject [camel-k] 03/09: fix golint findings for pkg/stub/action
Date Wed, 19 Sep 2018 13:54:28 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 8c5ca8538ed1ffacdb649a2542086a714b6c9468
Author: lburgazzoli <lburgazzoli@gmail.com>
AuthorDate: Wed Sep 19 11:44:29 2018 +0200

    fix golint findings for pkg/stub/action
---
 pkg/stub/action/context/action.go         |  1 +
 pkg/stub/action/context/initialize.go     | 11 ++++++-----
 pkg/stub/action/context/monitor.go        |  1 +
 pkg/stub/action/integration/action.go     |  1 +
 pkg/stub/action/integration/initialize.go | 22 +++++++++++-----------
 pkg/stub/action/integration/monitor.go    | 13 +++++++------
 6 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/pkg/stub/action/context/action.go b/pkg/stub/action/context/action.go
index c35b84c..23b0f10 100644
--- a/pkg/stub/action/context/action.go
+++ b/pkg/stub/action/context/action.go
@@ -21,6 +21,7 @@ import (
 	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
 )
 
+// IntegrationContextAction --
 type IntegrationContextAction interface {
 
 	// a user friendly name for the action
diff --git a/pkg/stub/action/context/initialize.go b/pkg/stub/action/context/initialize.go
index 5803b38..64d7647 100644
--- a/pkg/stub/action/context/initialize.go
+++ b/pkg/stub/action/context/initialize.go
@@ -23,22 +23,23 @@ import (
 	"github.com/operator-framework/operator-sdk/pkg/sdk"
 )
 
+// NewIntegrationContextInitializeAction creates a new initialization handling action for
the context
 func NewIntegrationContextInitializeAction() IntegrationContextAction {
-	return &integrationContexInitializeAction{}
+	return &integrationContextInitializeAction{}
 }
 
-type integrationContexInitializeAction struct {
+type integrationContextInitializeAction struct {
 }
 
-func (action *integrationContexInitializeAction) Name() string {
+func (action *integrationContextInitializeAction) Name() string {
 	return "initialize"
 }
 
-func (action *integrationContexInitializeAction) CanHandle(context *v1alpha1.IntegrationContext)
bool {
+func (action *integrationContextInitializeAction) CanHandle(context *v1alpha1.IntegrationContext)
bool {
 	return context.Status.Phase == ""
 }
 
-func (action *integrationContexInitializeAction) Handle(context *v1alpha1.IntegrationContext)
error {
+func (action *integrationContextInitializeAction) Handle(context *v1alpha1.IntegrationContext)
error {
 	target := context.DeepCopy()
 
 	// update the status
diff --git a/pkg/stub/action/context/monitor.go b/pkg/stub/action/context/monitor.go
index 138900b..e30a1ea 100644
--- a/pkg/stub/action/context/monitor.go
+++ b/pkg/stub/action/context/monitor.go
@@ -24,6 +24,7 @@ import (
 	"github.com/sirupsen/logrus"
 )
 
+// NewIntegrationContextMonitorAction creates a new monitoring handling action for the context
 func NewIntegrationContextMonitorAction() IntegrationContextAction {
 	return &integrationContextMonitorAction{}
 }
diff --git a/pkg/stub/action/integration/action.go b/pkg/stub/action/integration/action.go
index c1c7935..9e4a69c 100644
--- a/pkg/stub/action/integration/action.go
+++ b/pkg/stub/action/integration/action.go
@@ -21,6 +21,7 @@ import (
 	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
 )
 
+// IntegrationAction --
 type IntegrationAction interface {
 
 	// a user friendly name for the action
diff --git a/pkg/stub/action/integration/initialize.go b/pkg/stub/action/integration/initialize.go
index 25322fd..44bac89 100644
--- a/pkg/stub/action/integration/initialize.go
+++ b/pkg/stub/action/integration/initialize.go
@@ -18,34 +18,34 @@ limitations under the License.
 package action
 
 import (
+	"sort"
+
 	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
 	"github.com/apache/camel-k/pkg/discover"
 	"github.com/apache/camel-k/pkg/util/digest"
 	"github.com/operator-framework/operator-sdk/pkg/sdk"
-	"sort"
 )
 
-// InitializeAction initializes the integration status to trigger the deployment
-type InitializeAction struct {
-}
-
 // NewInitializeAction creates a new inititialize action
 func NewInitializeAction() IntegrationAction {
-	return &InitializeAction{}
+	return &initializeAction{}
+}
+
+type initializeAction struct {
 }
 
 // Name returns a common name of the action
-func (b *InitializeAction) Name() string {
+func (action *initializeAction) Name() string {
 	return "initialize"
 }
 
 // CanHandle tells whether this action can handle the integration
-func (b *InitializeAction) CanHandle(integration *v1alpha1.Integration) bool {
+func (action *initializeAction) CanHandle(integration *v1alpha1.Integration) bool {
 	return integration.Status.Phase == ""
 }
 
 // Handle handles the integratios
-func (b *InitializeAction) Handle(integration *v1alpha1.Integration) error {
+func (action *initializeAction) Handle(integration *v1alpha1.Integration) error {
 	target := integration.DeepCopy()
 	// set default values
 	if target.Spec.Replicas == nil {
@@ -62,7 +62,7 @@ func (b *InitializeAction) Handle(integration *v1alpha1.Integration) error
{
 	}
 	if *target.Spec.DependenciesAutoDiscovery {
 		discovered := discover.Dependencies(target.Spec.Source)
-		target.Spec.Dependencies = b.mergeDependencies(target.Spec.Dependencies, discovered)
+		target.Spec.Dependencies = action.mergeDependencies(target.Spec.Dependencies, discovered)
 	}
 	// sort the dependencies to get always the same list if they don't change
 	sort.Strings(target.Spec.Dependencies)
@@ -72,7 +72,7 @@ func (b *InitializeAction) Handle(integration *v1alpha1.Integration) error
{
 	return sdk.Update(target)
 }
 
-func (b *InitializeAction) mergeDependencies(list1 []string, list2 []string) []string {
+func (action *initializeAction) mergeDependencies(list1 []string, list2 []string) []string
{
 	set := make(map[string]bool, 0)
 	for _, d := range list1 {
 		set[d] = true
diff --git a/pkg/stub/action/integration/monitor.go b/pkg/stub/action/integration/monitor.go
index b12600a..483212e 100644
--- a/pkg/stub/action/integration/monitor.go
+++ b/pkg/stub/action/integration/monitor.go
@@ -24,23 +24,24 @@ import (
 	"github.com/sirupsen/logrus"
 )
 
-type MonitorAction struct {
+// NewMonitorAction creates a new monitoring action for an integration
+func NewMonitorAction() IntegrationAction {
+	return &monitorAction{}
 }
 
-func NewMonitorAction() IntegrationAction {
-	return &MonitorAction{}
+type monitorAction struct {
 }
 
-func (b *MonitorAction) Name() string {
+func (action *monitorAction) Name() string {
 	return "monitor"
 }
 
-func (a *MonitorAction) CanHandle(integration *v1alpha1.Integration) bool {
+func (action *monitorAction) CanHandle(integration *v1alpha1.Integration) bool {
 	return integration.Status.Phase == v1alpha1.IntegrationPhaseRunning ||
 		integration.Status.Phase == v1alpha1.IntegrationPhaseError
 }
 
-func (a *MonitorAction) Handle(integration *v1alpha1.Integration) error {
+func (action *monitorAction) Handle(integration *v1alpha1.Integration) error {
 
 	hash := digest.ComputeForIntegration(integration)
 	if hash != integration.Status.Digest {


Mime
View raw message