This is an automated email from the ASF dual-hosted git repository. lburgazzoli pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 1e3ed1306bdcd91e4aa75875a7d78eb2a792a406 Author: lburgazzoli <lburgazz...@gmail.com> AuthorDate: Fri Dec 7 23:36:12 2018 +0100 chore(lint): fix findings --- pkg/client/cmd/run.go | 16 ++++++++-------- pkg/gzip/compress.go | 8 +++++++- pkg/metadata/http.go | 37 +++++++++++++++++++------------------ pkg/metadata/metadata.go | 3 ++- pkg/metadata/metadata_http_test.go | 5 +---- pkg/metadata/types.go | 3 ++- pkg/trait/catalog.go | 4 ++-- pkg/trait/knative.go | 11 +++++------ pkg/trait/trait_test.go | 4 ++-- pkg/util/kubernetes/replace.go | 2 +- 10 files changed, 49 insertions(+), 44 deletions(-) diff --git a/pkg/client/cmd/run.go b/pkg/client/cmd/run.go index dd13705..8df8eea 100644 --- a/pkg/client/cmd/run.go +++ b/pkg/client/cmd/run.go @@ -100,23 +100,23 @@ func newCmdRun(rootCmdOptions *RootCmdOptions) *cobra.Command { type runCmdOptions struct { *RootCmdOptions + Compression bool + Wait bool + Logs bool + Sync bool + Dev bool IntegrationContext string Runtime string IntegrationName string + Profile string + OutputFormat string Dependencies []string Properties []string ConfigMaps []string Secrets []string Repositories []string - Wait bool - Logs bool - Sync bool - Dev bool - Profile string Traits []string LoggingLevels []string - OutputFormat string - Compression bool } func (o *runCmdOptions) validateArgs(cmd *cobra.Command, args []string) error { @@ -257,8 +257,8 @@ func (o *runCmdOptions) createIntegration(args []string) (*v1alpha1.Integration, return o.updateIntegrationCode(args) } +// nolint: gocyclo func (o *runCmdOptions) updateIntegrationCode(sources []string) (*v1alpha1.Integration, error) { - namespace := o.Namespace name := "" diff --git a/pkg/gzip/compress.go b/pkg/gzip/compress.go index c272003..584f945 100644 --- a/pkg/gzip/compress.go +++ b/pkg/gzip/compress.go @@ -45,6 +45,9 @@ func Compress(buffer io.Writer, data []byte) error { func Uncompress(buffer io.Writer, data []byte) error { b := bytes.NewBuffer(data) gz, err := g.NewReader(b) + if err != nil { + return err + } defer gz.Close() @@ -53,7 +56,10 @@ func Uncompress(buffer io.Writer, data []byte) error { return err } - buffer.Write(data) + _, err = buffer.Write(data) + if err != nil { + return err + } return nil } diff --git a/pkg/metadata/http.go b/pkg/metadata/http.go index 6ca7065..2b8d50a 100644 --- a/pkg/metadata/http.go +++ b/pkg/metadata/http.go @@ -18,29 +18,30 @@ limitations under the License. package metadata import ( - "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" "regexp" "strings" + + "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" ) var httpURIs = map[string]bool{ "ahc": true, "ahc-ws": true, "atmosphere-websocket": true, - "cxf": true, - "cxfrs": true, - "grpc": true, - "jetty": true, - "netty-http": true, - "netty4-http": true, - "rest": true, - "restlet": true, - "servlet": true, - "spark-rest": true, - "spring-ws": true, - "undertow": true, - "websocket": true, - "knative": true, + "cxf": true, + "cxfrs": true, + "grpc": true, + "jetty": true, + "netty-http": true, + "netty4-http": true, + "rest": true, + "restlet": true, + "servlet": true, + "spark-rest": true, + "spring-ws": true, + "undertow": true, + "websocket": true, + "knative": true, } var passiveURIs = map[string]bool{ @@ -65,8 +66,8 @@ var passiveURIs = map[string]bool{ "vm": true, } -var restIndicator = regexp.MustCompile(".*rest\\s*\\([^)]*\\).*") -var xmlRestIndicator = regexp.MustCompile(".*<\\s*rest\\s+[^>]*>.*") +var restIndicator = regexp.MustCompile(`.*rest\s*\([^)]*\).*`) +var xmlRestIndicator = regexp.MustCompile(`.*<\s*rest\s+[^>]*>.*`) // requiresHTTPService returns true if the integration needs to expose itself through HTTP func requiresHTTPService(source v1alpha1.SourceSpec, fromURIs []string) bool { @@ -77,7 +78,7 @@ func requiresHTTPService(source v1alpha1.SourceSpec, fromURIs []string) bool { } // hasOnlyPassiveEndpoints returns true if the integration has no endpoint that needs to remain always active -func hasOnlyPassiveEndpoints(source v1alpha1.SourceSpec, fromURIs []string) bool { +func hasOnlyPassiveEndpoints(_ v1alpha1.SourceSpec, fromURIs []string) bool { passivePlusHTTP := make(map[string]bool) for k, v := range passiveURIs { passivePlusHTTP[k] = v diff --git a/pkg/metadata/metadata.go b/pkg/metadata/metadata.go index 9eec7bd..30263e9 100644 --- a/pkg/metadata/metadata.go +++ b/pkg/metadata/metadata.go @@ -18,8 +18,9 @@ limitations under the License. package metadata import ( - "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" "sort" + + "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" ) // ExtractAll returns metadata information from all listed source codes diff --git a/pkg/metadata/metadata_http_test.go b/pkg/metadata/metadata_http_test.go index d75f57b..59cc1cd 100644 --- a/pkg/metadata/metadata_http_test.go +++ b/pkg/metadata/metadata_http_test.go @@ -82,7 +82,6 @@ func TestHttpOnlyJavaSourceRest2(t *testing.T) { assert.True(t, meta.PassiveEndpoints) } - func TestNoHttpGroovySource(t *testing.T) { code := v1alpha1.SourceSpec{ Name: "Request.groovy", @@ -143,8 +142,6 @@ func TestHttpOnlyXMLSource(t *testing.T) { assert.True(t, meta.PassiveEndpoints) } - - func TestMultilangHTTPOnlySource(t *testing.T) { codes := []v1alpha1.SourceSpec{ { @@ -192,4 +189,4 @@ func TestMultilangHTTPSource(t *testing.T) { meta := ExtractAll(codes) assert.True(t, meta.RequiresHTTPService) assert.False(t, meta.PassiveEndpoints) -} \ No newline at end of file +} diff --git a/pkg/metadata/types.go b/pkg/metadata/types.go index 04ebe1c..2874eaf 100644 --- a/pkg/metadata/types.go +++ b/pkg/metadata/types.go @@ -31,6 +31,7 @@ type IntegrationMetadata struct { Language v1alpha1.Language // RequiresHTTPService indicates if the integration needs to be invoked through HTTP RequiresHTTPService bool - // PassiveEndpoints indicates that the integration contains only passive endpoints that are activated from external calls, including HTTP (useful to determine if the integration can scale to 0) + // PassiveEndpoints indicates that the integration contains only passive endpoints that are activated from + // external calls, including HTTP (useful to determine if the integration can scale to 0) PassiveEndpoints bool } diff --git a/pkg/trait/catalog.go b/pkg/trait/catalog.go index 796670a..39ebdfd 100644 --- a/pkg/trait/catalog.go +++ b/pkg/trait/catalog.go @@ -39,7 +39,7 @@ type Catalog struct { tOwner Trait tBuilder Trait tSpringBoot Trait - tIstio Trait + tIstio Trait } // NewCatalog creates a new trait Catalog @@ -55,7 +55,7 @@ func NewCatalog() *Catalog { tOwner: newOwnerTrait(), tBuilder: newBuilderTrait(), tSpringBoot: newSpringBootTrait(), - tIstio: newIstioTrait(), + tIstio: newIstioTrait(), } } diff --git a/pkg/trait/knative.go b/pkg/trait/knative.go index eecec1b..17293a7 100644 --- a/pkg/trait/knative.go +++ b/pkg/trait/knative.go @@ -87,11 +87,10 @@ func (t *knativeTrait) apply(e *Environment) error { for _, sub := range t.getSubscriptionsFor(e) { e.Resources.Add(sub) } - svc, err := t.getServiceFor(e) - if err != nil { - return err - } + + svc := t.getServiceFor(e) e.Resources.Add(svc) + return nil } @@ -105,7 +104,7 @@ func (t *knativeTrait) prepareEnvVars(e *Environment) error { return nil } -func (t *knativeTrait) getServiceFor(e *Environment) (*serving.Service, error) { +func (t *knativeTrait) getServiceFor(e *Environment) *serving.Service { // combine properties of integration with context, integration // properties have the priority properties := CombineConfigurationAsMap("property", e.Context, e.Integration) @@ -198,7 +197,7 @@ func (t *knativeTrait) getServiceFor(e *Environment) (*serving.Service, error) { }, } - return &svc, nil + return &svc } func (t *knativeTrait) getSubscriptionsFor(e *Environment) []*eventing.Subscription { diff --git a/pkg/trait/trait_test.go b/pkg/trait/trait_test.go index a770e76..c6df05d 100644 --- a/pkg/trait/trait_test.go +++ b/pkg/trait/trait_test.go @@ -174,9 +174,9 @@ func createTestEnv(cluster v1alpha1.IntegrationPlatformCluster, script string) * Spec: v1alpha1.IntegrationSpec{ Sources: []v1alpha1.SourceSpec{ { + Name: "file.groovy", Language: v1alpha1.LanguageGroovy, - Name: "file.groovy", - Content: script, + Content: script, }, }, }, diff --git a/pkg/util/kubernetes/replace.go b/pkg/util/kubernetes/replace.go index ec14b16..6d8ea49 100644 --- a/pkg/util/kubernetes/replace.go +++ b/pkg/util/kubernetes/replace.go @@ -18,6 +18,7 @@ limitations under the License. package kubernetes import ( + eventing "github.com/knative/eventing/pkg/apis/eventing/v1alpha1" routev1 "github.com/openshift/api/route/v1" "github.com/operator-framework/operator-sdk/pkg/sdk" "github.com/pkg/errors" @@ -25,7 +26,6 @@ import ( k8serrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - eventing "github.com/knative/eventing/pkg/apis/eventing/v1alpha1" ) // ReplaceResources allows to completely replace a list of resources on Kubernetes, taking care of immutable fields and resource versions