You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2018/09/26 06:30:32 UTC

[camel-k] 01/01: Polish and make go-report happy

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

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

commit 34bf2f23252cc00ca015f74bb744637b33c4011a
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Sep 26 08:22:18 2018 +0200

    Polish and make go-report happy
---
 cmd/kamel/kamel.go                             |  7 ++++---
 pkg/build/publish/s2i_incremental_publisher.go |  3 ++-
 pkg/build/publish/s2i_publisher.go             | 11 +++++++----
 pkg/stub/action/integration/deploy.go          |  6 ++++--
 pkg/util/log/annotation_scraper.go             | 17 +++++++++--------
 pkg/util/maven/maven.go                        |  3 +--
 pkg/util/tar/appender.go                       |  6 ++++--
 test/cluster_integration_test.go               |  3 ++-
 test/testing_env.go                            | 16 ++++++++--------
 9 files changed, 41 insertions(+), 31 deletions(-)

diff --git a/cmd/kamel/kamel.go b/cmd/kamel/kamel.go
index 6c0fff2..a89042f 100644
--- a/cmd/kamel/kamel.go
+++ b/cmd/kamel/kamel.go
@@ -18,13 +18,14 @@ limitations under the License.
 package main
 
 import (
+	"context"
 	"fmt"
-	"github.com/apache/camel-k/pkg/client/cmd"
-	_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
 	"math/rand"
 	"os"
-	"context"
 	"time"
+
+	"github.com/apache/camel-k/pkg/client/cmd"
+	_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
 )
 
 func main() {
diff --git a/pkg/build/publish/s2i_incremental_publisher.go b/pkg/build/publish/s2i_incremental_publisher.go
index f3921cc..ae996e4 100644
--- a/pkg/build/publish/s2i_incremental_publisher.go
+++ b/pkg/build/publish/s2i_incremental_publisher.go
@@ -19,6 +19,7 @@ package publish
 
 import (
 	"context"
+
 	"github.com/apache/camel-k/pkg/build"
 )
 
@@ -58,7 +59,7 @@ func (p *s2iIncrementalPublisher) selectArtifactsToUpload(entries []build.Classp
 	}
 
 	bestImage, commonLibs := p.findBestImage(images, entries)
-	if (bestImage != nil) {
+	if bestImage != nil {
 		selectedClasspath := make([]build.ClasspathEntry, 0)
 		for _, entry := range entries {
 			if _, isCommon := commonLibs[entry.ID]; !isCommon {
diff --git a/pkg/build/publish/s2i_publisher.go b/pkg/build/publish/s2i_publisher.go
index 7fd06c2..97147a7 100644
--- a/pkg/build/publish/s2i_publisher.go
+++ b/pkg/build/publish/s2i_publisher.go
@@ -19,6 +19,10 @@ package publish
 
 import (
 	"context"
+	"io/ioutil"
+	"path"
+	"time"
+
 	"github.com/apache/camel-k/pkg/build"
 	"github.com/apache/camel-k/pkg/util/kubernetes"
 	"github.com/apache/camel-k/pkg/util/kubernetes/customclient"
@@ -30,12 +34,9 @@ import (
 	"github.com/operator-framework/operator-sdk/pkg/util/k8sutil"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"
-	"io/ioutil"
 	"k8s.io/api/core/v1"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
-	"path"
-	"time"
 )
 
 const (
@@ -59,7 +60,9 @@ type uploadedArtifactsSelector func([]build.ClasspathEntry) (string, []build.Cla
 
 // NewS2IPublisher creates a new publisher doing a Openshift S2I binary build
 func NewS2IPublisher(ctx context.Context, namespace string) build.Publisher {
-	identitySelector := func(entries []build.ClasspathEntry) (string, []build.ClasspathEntry, error) { return baseImage, entries, nil }
+	identitySelector := func(entries []build.ClasspathEntry) (string, []build.ClasspathEntry, error) {
+		return baseImage, entries, nil
+	}
 	return newS2IPublisher(ctx, namespace, identitySelector)
 }
 
diff --git a/pkg/stub/action/integration/deploy.go b/pkg/stub/action/integration/deploy.go
index b3bce77..a679bbd 100644
--- a/pkg/stub/action/integration/deploy.go
+++ b/pkg/stub/action/integration/deploy.go
@@ -51,10 +51,12 @@ func (action *deployAction) Handle(integration *v1alpha1.Integration) error {
 	if err != nil {
 		return err
 	}
-	if err = createOrUpdateConfigMap(ctx, integration); err != nil {
+	err = createOrUpdateConfigMap(ctx, integration)
+	if err != nil {
 		return err
 	}
-	if err = createOrUpdateDeployment(ctx, integration); err != nil {
+	err = createOrUpdateDeployment(ctx, integration)
+	if err != nil {
 		return err
 	}
 
diff --git a/pkg/util/log/annotation_scraper.go b/pkg/util/log/annotation_scraper.go
index 2e47b5e..d3b4331 100644
--- a/pkg/util/log/annotation_scraper.go
+++ b/pkg/util/log/annotation_scraper.go
@@ -19,16 +19,17 @@ package log
 
 import (
 	"bufio"
-	"io"
 	"context"
-	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-	"github.com/operator-framework/operator-sdk/pkg/sdk"
-	"k8s.io/api/core/v1"
+	"io"
+	"strconv"
 	"sync"
 	"sync/atomic"
-	"strconv"
-	"github.com/sirupsen/logrus"
 	"time"
+
+	"github.com/operator-framework/operator-sdk/pkg/sdk"
+	"github.com/sirupsen/logrus"
+	"k8s.io/api/core/v1"
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 )
 
 // SelectorScraper scrapes all pods with a given selector
@@ -66,7 +67,7 @@ func (s *SelectorScraper) periodicSynchronize(ctx context.Context, out *bufio.Wr
 		logrus.Warn("Could not synchronize log by label " + s.labelSelector)
 	}
 	select {
-	case <- ctx.Done():
+	case <-ctx.Done():
 		// cleanup
 		s.podScrapers.Range(func(k, v interface{}) bool {
 			if canc, isCanc := v.(context.CancelFunc); isCanc {
@@ -76,7 +77,7 @@ func (s *SelectorScraper) periodicSynchronize(ctx context.Context, out *bufio.Wr
 			return true
 		})
 		clientCloser()
-	case <- time.After(2*time.Second):
+	case <-time.After(2 * time.Second):
 		go s.periodicSynchronize(ctx, out, clientCloser)
 	}
 }
diff --git a/pkg/util/maven/maven.go b/pkg/util/maven/maven.go
index e2a9b35..5550122 100644
--- a/pkg/util/maven/maven.go
+++ b/pkg/util/maven/maven.go
@@ -37,8 +37,7 @@ import (
 )
 
 const (
-	buildDirPrefix    = "maven-"
-
+	buildDirPrefix = "maven-"
 )
 
 // BuildResult --
diff --git a/pkg/util/tar/appender.go b/pkg/util/tar/appender.go
index 3e4aebf..965bbc7 100644
--- a/pkg/util/tar/appender.go
+++ b/pkg/util/tar/appender.go
@@ -19,10 +19,11 @@ package tar
 
 import (
 	atar "archive/tar"
-	"github.com/pkg/errors"
 	"io"
 	"os"
 	"path"
+
+	"github.com/pkg/errors"
 )
 
 // Appender provides a high level abstraction over writing tar files
@@ -51,7 +52,8 @@ func (t *Appender) Close() error {
 	if err := t.writer.Close(); err != nil {
 		return err
 	}
-	if err := t.tarFile.Close(); err != nil {
+	err := t.tarFile.Close()
+	if err != nil {
 		return err
 	}
 	return nil
diff --git a/test/cluster_integration_test.go b/test/cluster_integration_test.go
index 810ed67..28fc854 100644
--- a/test/cluster_integration_test.go
+++ b/test/cluster_integration_test.go
@@ -22,9 +22,10 @@ limitations under the License.
 package test
 
 import (
-	"github.com/stretchr/testify/assert"
 	"testing"
+
 	"github.com/apache/camel-k/pkg/install"
+	"github.com/stretchr/testify/assert"
 )
 
 func TestInstallation(t *testing.T) {
diff --git a/test/testing_env.go b/test/testing_env.go
index 10fc8e5..66ff683 100644
--- a/test/testing_env.go
+++ b/test/testing_env.go
@@ -22,14 +22,15 @@ limitations under the License.
 package test
 
 import (
+	"time"
+
 	"github.com/apache/camel-k/pkg/install"
 	"github.com/apache/camel-k/pkg/util/kubernetes"
-	"k8s.io/api/core/v1"
-	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"github.com/operator-framework/operator-sdk/pkg/sdk"
-	"time"
-	k8serrors "k8s.io/apimachinery/pkg/api/errors"
 	appsv1 "k8s.io/api/apps/v1"
+	"k8s.io/api/core/v1"
+	k8serrors "k8s.io/apimachinery/pkg/api/errors"
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 )
 
 func init() {
@@ -94,7 +95,7 @@ func createDummyDeployment(name string, replicas *int32, labelKey string, labelV
 		}
 
 		if len(list.Items) > 0 {
-			time.Sleep(1*time.Second)
+			time.Sleep(1 * time.Second)
 		} else {
 			break
 		}
@@ -110,8 +111,8 @@ func getDummyDeployment(name string, replicas *int32, labelKey string, labelValu
 			APIVersion: appsv1.SchemeGroupVersion.String(),
 		},
 		ObjectMeta: metav1.ObjectMeta{
-			Name:        name,
-			Namespace:   getTargetNamespace(),
+			Name:      name,
+			Namespace: getTargetNamespace(),
 		},
 		Spec: appsv1.DeploymentSpec{
 			Replicas: replicas,
@@ -175,4 +176,3 @@ func getDummyPod(name string, command ...string) v1.Pod {
 		},
 	}
 }
-