You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2018/09/19 13:54:25 UTC

[camel-k] branch master updated (6139f4f -> 8db26ed)

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

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


    from 6139f4f  Merge pull request #101 from apache/caffeine-sample
     new 5a780dd  chore: fix golint findings for pkg/install
     new 1655892  fix golint findings for pkg/client
     new 8c5ca85  fix golint findings for pkg/stub/action
     new c92031d  fix golint findings for pkg/util/kubernetes
     new 5fa0938  fix golint findings for pkg/util/maven
     new 529a25d  fix golint findings for pkg/util/openshift
     new 7501383  fix golint findings for pkg/util/watch
     new 8c61e3b  fix golint findings for pkg/util/sync
     new 8db26ed  chore: remove unused code

The 9 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 pkg/apis/camel/v1alpha1/register.go              |  7 +-
 pkg/build/local/local_builder.go                 | 26 +++----
 pkg/build/local/local_builder_test.go            | 14 ++--
 pkg/build/local/scheme.go                        | 98 ------------------------
 pkg/client/cmd/context.go                        |  3 +-
 pkg/client/cmd/get.go                            |  8 +-
 pkg/client/cmd/install.go                        |  5 +-
 pkg/client/cmd/root.go                           | 10 +--
 pkg/client/cmd/run.go                            | 10 +--
 pkg/client/cmd/version.go                        |  2 +-
 pkg/install/cluster.go                           |  7 +-
 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 ++--
 pkg/util/kubernetes/config.go                    | 10 ++-
 pkg/util/kubernetes/customclient/customclient.go |  1 +
 pkg/util/kubernetes/customclient/scheme.go       | 33 --------
 pkg/util/kubernetes/loader.go                    |  5 +-
 pkg/util/kubernetes/namespace.go                 |  6 +-
 pkg/util/kubernetes/sanitize.go                  |  1 +
 pkg/util/kubernetes/wait.go                      | 23 +++++-
 pkg/util/maven/maven.go                          | 31 +++++---
 pkg/util/maven/maven_test.go                     | 28 +++----
 pkg/util/maven/types.go                          | 33 +++++---
 pkg/util/openshift/register.go                   |  8 +-
 pkg/util/sync/file.go                            |  3 +-
 pkg/util/watch/watch.go                          | 13 ++--
 30 files changed, 176 insertions(+), 258 deletions(-)
 delete mode 100644 pkg/build/local/scheme.go


[camel-k] 05/09: fix golint findings for pkg/util/maven

Posted by nf...@apache.org.
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 5fa09384f69718825cc5acbbbdc7b2b53ca6d38a
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Wed Sep 19 12:07:52 2018 +0200

    fix golint findings for pkg/util/maven
---
 pkg/build/local/local_builder.go      | 26 +++++++++++++-------------
 pkg/build/local/local_builder_test.go | 14 +++++++-------
 pkg/util/maven/maven.go               | 31 +++++++++++++++++++------------
 pkg/util/maven/maven_test.go          | 28 ++++++++++++++--------------
 pkg/util/maven/types.go               | 33 +++++++++++++++++++++------------
 5 files changed, 74 insertions(+), 58 deletions(-)

diff --git a/pkg/build/local/local_builder.go b/pkg/build/local/local_builder.go
index 0274c12..c341274 100644
--- a/pkg/build/local/local_builder.go
+++ b/pkg/build/local/local_builder.go
@@ -111,11 +111,11 @@ func (b *localBuilder) buildCycle(ctx context.Context) {
 }
 
 func (b *localBuilder) execute(source build.Request) (string, error) {
-	project, err := generateProjectDefinition(source)
+	integration, err := generateIntegration(source)
 	if err != nil {
 		return "", err
 	}
-	tarFileName, err := maven.Build(project)
+	tarFileName, err := maven.Build(integration)
 	if err != nil {
 		return "", err
 	}
@@ -254,24 +254,24 @@ func (b *localBuilder) publish(tarFile string, source build.Request) (string, er
 	return is.Status.DockerImageRepository + ":" + source.Identifier.Qualifier, nil
 }
 
-func generateProjectDefinition(source build.Request) (maven.ProjectDefinition, error) {
-	project := maven.ProjectDefinition{
+func generateIntegration(source build.Request) (maven.Integration, error) {
+	integration := maven.Integration{
 		Project: maven.Project{
 			XMLName:           xml.Name{Local: "project"},
-			XmlNs:             "http://maven.apache.org/POM/4.0.0",
-			XmlNsXsi:          "http://www.w3.org/2001/XMLSchema-instance",
+			XMLNs:             "http://maven.apache.org/POM/4.0.0",
+			XMLNsXsi:          "http://www.w3.org/2001/XMLSchema-instance",
 			XsiSchemaLocation: "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd",
 			ModelVersion:      "4.0.0",
-			GroupId:           "org.apache.camel.k.integration",
-			ArtifactId:        "camel-k-integration",
+			GroupID:           "org.apache.camel.k.integration",
+			ArtifactID:        "camel-k-integration",
 			Version:           version.Version,
 			DependencyManagement: maven.DependencyManagement{
 				Dependencies: maven.Dependencies{
 					Dependencies: []maven.Dependency{
 						{
 							//TODO: camel version should be retrieved from an external source or provided as static version
-							GroupId:    "org.apache.camel",
-							ArtifactId: "camel-bom",
+							GroupID:    "org.apache.camel",
+							ArtifactID: "camel-bom",
 							Version:    "2.22.1",
 							Type:       "pom",
 							Scope:      "import",
@@ -291,7 +291,7 @@ func generateProjectDefinition(source build.Request) (maven.ProjectDefinition, e
 	// set-up dependencies
 	//
 
-	deps := &project.Project.Dependencies
+	deps := &integration.Project.Dependencies
 	deps.AddGAV("org.apache.camel.k", "camel-k-runtime-jvm", version.Version)
 
 	for _, d := range source.Dependencies {
@@ -309,9 +309,9 @@ func generateProjectDefinition(source build.Request) (maven.ProjectDefinition, e
 
 			deps.AddEncodedGAV(gav)
 		} else {
-			return maven.ProjectDefinition{}, fmt.Errorf("unknown dependency type: %s", d)
+			return maven.Integration{}, fmt.Errorf("unknown dependency type: %s", d)
 		}
 	}
 
-	return project, nil
+	return integration, nil
 }
diff --git a/pkg/build/local/local_builder_test.go b/pkg/build/local/local_builder_test.go
index 790c124..c5fd33d 100644
--- a/pkg/build/local/local_builder_test.go
+++ b/pkg/build/local/local_builder_test.go
@@ -43,16 +43,16 @@ func TestProjectGeneration(t *testing.T) {
 		},
 	}
 
-	prj, err := generateProjectDefinition(source)
+	prj, err := generateIntegration(source)
 	assert.Nil(t, err)
 	assert.NotNil(t, prj)
 	assert.Equal(t, len(prj.Project.Dependencies.Dependencies), 5)
-	assert.Equal(t, prj.Project.Dependencies.Dependencies[0].ArtifactId, "camel-k-runtime-jvm")
-	assert.Equal(t, prj.Project.Dependencies.Dependencies[1].ArtifactId, "camel-mail")
-	assert.Equal(t, prj.Project.Dependencies.Dependencies[2].ArtifactId, "camel-netty4")
-	assert.Equal(t, prj.Project.Dependencies.Dependencies[3].ArtifactId, "camel-servicenow")
+	assert.Equal(t, prj.Project.Dependencies.Dependencies[0].ArtifactID, "camel-k-runtime-jvm")
+	assert.Equal(t, prj.Project.Dependencies.Dependencies[1].ArtifactID, "camel-mail")
+	assert.Equal(t, prj.Project.Dependencies.Dependencies[2].ArtifactID, "camel-netty4")
+	assert.Equal(t, prj.Project.Dependencies.Dependencies[3].ArtifactID, "camel-servicenow")
 	assert.Equal(t, prj.Project.Dependencies.Dependencies[3].Version, "2.21.1")
-	assert.Equal(t, prj.Project.Dependencies.Dependencies[4].ArtifactId, "camel-salesforce")
+	assert.Equal(t, prj.Project.Dependencies.Dependencies[4].ArtifactID, "camel-salesforce")
 	assert.Equal(t, prj.Project.Dependencies.Dependencies[4].Version, "")
 }
 
@@ -75,6 +75,6 @@ func TestProjectGenerationWithFailure(t *testing.T) {
 		},
 	}
 
-	_, err := generateProjectDefinition(source)
+	_, err := generateIntegration(source)
 	assert.NotNil(t, err)
 }
diff --git a/pkg/util/maven/maven.go b/pkg/util/maven/maven.go
index 32e1317..c54ebd2 100644
--- a/pkg/util/maven/maven.go
+++ b/pkg/util/maven/maven.go
@@ -38,15 +38,15 @@ const (
 	artifactDirPrefix = "maven-bin-"
 )
 
-// Takes a project description and returns a binary tar with the built artifacts
-func Build(project ProjectDefinition) (string, error) {
+// Build takes a project description and returns a binary tar with the built artifacts
+func Build(integration Integration) (string, error) {
 	buildDir, err := ioutil.TempDir("", buildDirPrefix)
 	if err != nil {
 		return "", errors.Wrap(err, "could not create temporary dir for maven source files")
 	}
 	defer os.RemoveAll(buildDir)
 
-	err = createMavenStructure(buildDir, project)
+	err = createMavenStructure(buildDir, integration)
 	if err != nil {
 		return "", errors.Wrap(err, "could not write maven source files")
 	}
@@ -54,7 +54,7 @@ func Build(project ProjectDefinition) (string, error) {
 	if err != nil {
 		return "", err
 	}
-	tarfile, err := createTar(buildDir, project)
+	tarfile, err := createTar(buildDir, integration)
 	if err != nil {
 		return "", err
 	}
@@ -90,13 +90,13 @@ func mavenExtraOptions() string {
 	return "-Dcamel.noop=true"
 }
 
-func createTar(buildDir string, project ProjectDefinition) (string, error) {
+func createTar(buildDir string, integration Integration) (string, error) {
 	artifactDir, err := ioutil.TempDir("", artifactDirPrefix)
 	if err != nil {
 		return "", errors.Wrap(err, "could not create temporary dir for maven artifacts")
 	}
 
-	tarFileName := path.Join(artifactDir, project.Project.ArtifactId+".tar")
+	tarFileName := path.Join(artifactDir, integration.Project.ArtifactID+".tar")
 	tarFile, err := os.Create(tarFileName)
 	if err != nil {
 		return "", errors.Wrap(err, "cannot create tar file "+tarFileName)
@@ -104,14 +104,14 @@ func createTar(buildDir string, project ProjectDefinition) (string, error) {
 	defer tarFile.Close()
 
 	writer := tar.NewWriter(tarFile)
-	err = appendToTar(path.Join(buildDir, "target", project.Project.ArtifactId+"-"+project.Project.Version+".jar"), "", writer)
+	err = appendToTar(path.Join(buildDir, "target", integration.Project.ArtifactID+"-"+integration.Project.Version+".jar"), "", writer)
 	if err != nil {
 		return "", err
 	}
 
 	// Environment variables
-	if project.Env != nil {
-		err = writeFile(buildDir, "run-env.sh", envFileContent(project.Env))
+	if integration.Env != nil {
+		err = writeFile(buildDir, "run-env.sh", envFileContent(integration.Env))
 		if err != nil {
 			return "", err
 		}
@@ -169,7 +169,7 @@ func appendToTar(filePath string, tarPath string, writer *tar.Writer) error {
 	return nil
 }
 
-func createMavenStructure(buildDir string, project ProjectDefinition) error {
+func createMavenStructure(buildDir string, project Integration) error {
 	pom, err := GeneratePomFileContent(project.Project)
 	if err != nil {
 		return err
@@ -236,6 +236,7 @@ func envFileContent(env map[string]string) string {
 	return content
 }
 
+// GeneratePomFileContent generate a pom.xml file from the given project definition
 func GeneratePomFileContent(project Project) (string, error) {
 	w := &bytes.Buffer{}
 	w.WriteString(xml.Header)
@@ -251,14 +252,20 @@ func GeneratePomFileContent(project Project) (string, error) {
 	return w.String(), nil
 }
 
+// ParseGAV decode a maven artifact id to a dependency definition.
+//
+// The artifact id is in the form of:
+//
+//     <groupId>:<artifactId>[:<packagingType>[:<classifier>]]:(<version>|'?')
+//
 func ParseGAV(gav string) (Dependency, error) {
 	// <groupId>:<artifactId>[:<packagingType>[:<classifier>]]:(<version>|'?')
 	dep := Dependency{}
 	rex := regexp.MustCompile("([^: ]+):([^: ]+)(:([^: ]*)(:([^: ]+))?)?(:([^: ]+))?")
 	res := rex.FindStringSubmatch(gav)
 
-	dep.GroupId = res[1]
-	dep.ArtifactId = res[2]
+	dep.GroupID = res[1]
+	dep.ArtifactID = res[2]
 	dep.Type = "jar"
 
 	cnt := strings.Count(gav, ":")
diff --git a/pkg/util/maven/maven_test.go b/pkg/util/maven/maven_test.go
index 7e59e54..05cff20 100644
--- a/pkg/util/maven/maven_test.go
+++ b/pkg/util/maven/maven_test.go
@@ -53,19 +53,19 @@ const expectedPom = `<?xml version="1.0" encoding="UTF-8"?>
 func TestPomGeneration(t *testing.T) {
 	project := Project{
 		XMLName:           xml.Name{Local: "project"},
-		XmlNs:             "http://maven.apache.org/POM/4.0.0",
-		XmlNsXsi:          "http://www.w3.org/2001/XMLSchema-instance",
+		XMLNs:             "http://maven.apache.org/POM/4.0.0",
+		XMLNsXsi:          "http://www.w3.org/2001/XMLSchema-instance",
 		XsiSchemaLocation: "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd",
 		ModelVersion:      "4.0.0",
-		GroupId:           "org.apache.camel.k.integration",
-		ArtifactId:        "camel-k-integration",
+		GroupID:           "org.apache.camel.k.integration",
+		ArtifactID:        "camel-k-integration",
 		Version:           "1.0.0",
 		DependencyManagement: DependencyManagement{
 			Dependencies: Dependencies{
 				Dependencies: []Dependency{
 					{
-						GroupId:    "org.apache.camel",
-						ArtifactId: "camel-bom",
+						GroupID:    "org.apache.camel",
+						ArtifactID: "camel-bom",
 						Version:    "2.22.1",
 						Type:       "pom",
 						Scope:      "import",
@@ -76,8 +76,8 @@ func TestPomGeneration(t *testing.T) {
 		Dependencies: Dependencies{
 			Dependencies: []Dependency{
 				{
-					GroupId:    "org.apache.camel.k",
-					ArtifactId: "camel-k-runtime-jvm",
+					GroupID:    "org.apache.camel.k",
+					ArtifactID: "camel-k-runtime-jvm",
 					Version:    "1.0.0",
 				},
 			},
@@ -96,8 +96,8 @@ func TestParseSimpleGAV(t *testing.T) {
 	dep, err := ParseGAV("org.apache.camel:camel-core:2.21.1")
 
 	assert.Nil(t, err)
-	assert.Equal(t, dep.GroupId, "org.apache.camel")
-	assert.Equal(t, dep.ArtifactId, "camel-core")
+	assert.Equal(t, dep.GroupID, "org.apache.camel")
+	assert.Equal(t, dep.ArtifactID, "camel-core")
 	assert.Equal(t, dep.Version, "2.21.1")
 	assert.Equal(t, dep.Type, "jar")
 	assert.Equal(t, dep.Classifier, "")
@@ -107,8 +107,8 @@ func TestParseGAVWithType(t *testing.T) {
 	dep, err := ParseGAV("org.apache.camel:camel-core:war:2.21.1")
 
 	assert.Nil(t, err)
-	assert.Equal(t, dep.GroupId, "org.apache.camel")
-	assert.Equal(t, dep.ArtifactId, "camel-core")
+	assert.Equal(t, dep.GroupID, "org.apache.camel")
+	assert.Equal(t, dep.ArtifactID, "camel-core")
 	assert.Equal(t, dep.Version, "2.21.1")
 	assert.Equal(t, dep.Type, "war")
 	assert.Equal(t, dep.Classifier, "")
@@ -118,8 +118,8 @@ func TestParseGAVWithClassifierAndType(t *testing.T) {
 	dep, err := ParseGAV("org.apache.camel:camel-core:war:test:2.21.1")
 
 	assert.Nil(t, err)
-	assert.Equal(t, dep.GroupId, "org.apache.camel")
-	assert.Equal(t, dep.ArtifactId, "camel-core")
+	assert.Equal(t, dep.GroupID, "org.apache.camel")
+	assert.Equal(t, dep.ArtifactID, "camel-core")
 	assert.Equal(t, dep.Version, "2.21.1")
 	assert.Equal(t, dep.Type, "war")
 	assert.Equal(t, dep.Classifier, "test")
diff --git a/pkg/util/maven/types.go b/pkg/util/maven/types.go
index 5b1158e..db4b897 100644
--- a/pkg/util/maven/types.go
+++ b/pkg/util/maven/types.go
@@ -21,42 +21,49 @@ import (
 	"encoding/xml"
 )
 
-type ProjectDefinition struct {
+// Integration --
+type Integration struct {
 	Project     Project
 	JavaSources map[string]string
 	Resources   map[string]string
 	Env         map[string]string // TODO: should we deprecate it ? env are set on deployment
 }
 
+// Project represent a maven project
 type Project struct {
 	XMLName              xml.Name
-	XmlNs                string               `xml:"xmlns,attr"`
-	XmlNsXsi             string               `xml:"xmlns:xsi,attr"`
+	XMLNs                string               `xml:"xmlns,attr"`
+	XMLNsXsi             string               `xml:"xmlns:xsi,attr"`
 	XsiSchemaLocation    string               `xml:"xsi:schemaLocation,attr"`
 	ModelVersion         string               `xml:"modelVersion"`
-	GroupId              string               `xml:"groupId"`
-	ArtifactId           string               `xml:"artifactId"`
+	GroupID              string               `xml:"groupId"`
+	ArtifactID           string               `xml:"artifactId"`
 	Version              string               `xml:"version"`
 	DependencyManagement DependencyManagement `xml:"dependencyManagement"`
 	Dependencies         Dependencies         `xml:"dependencies"`
 }
 
+// DependencyManagement represent maven's dependency management block
 type DependencyManagement struct {
 	Dependencies Dependencies `xml:"dependencies"`
 }
 
+// Dependencies --
 type Dependencies struct {
 	Dependencies []Dependency `xml:"dependency"`
 }
 
+// Add a dependency to maven's dependencies
 func (deps *Dependencies) Add(dep Dependency) {
 	deps.Dependencies = append(deps.Dependencies, dep)
 }
 
-func (deps *Dependencies) AddGAV(groupId string, artifactId string, version string) {
-	deps.Add(NewDependency(groupId, artifactId, version))
+// AddGAV a dependency to maven's dependencies
+func (deps *Dependencies) AddGAV(groupID string, artifactID string, version string) {
+	deps.Add(NewDependency(groupID, artifactID, version))
 }
 
+// AddEncodedGAV a dependency to maven's dependencies
 func (deps *Dependencies) AddEncodedGAV(gav string) {
 	if d, err := ParseGAV(gav); err == nil {
 		// TODO: error handling
@@ -64,19 +71,21 @@ func (deps *Dependencies) AddEncodedGAV(gav string) {
 	}
 }
 
+// Dependency represent a maven's dependency
 type Dependency struct {
-	GroupId    string `xml:"groupId"`
-	ArtifactId string `xml:"artifactId"`
+	GroupID    string `xml:"groupId"`
+	ArtifactID string `xml:"artifactId"`
 	Version    string `xml:"version,omitempty"`
 	Type       string `xml:"type,omitempty"`
 	Classifier string `xml:"classifier,omitempty"`
 	Scope      string `xml:"scope,omitempty"`
 }
 
-func NewDependency(groupId string, artifactId string, version string) Dependency {
+// NewDependency create an new dependency from the given gav info
+func NewDependency(groupID string, artifactID string, version string) Dependency {
 	return Dependency{
-		GroupId:    groupId,
-		ArtifactId: artifactId,
+		GroupID:    groupID,
+		ArtifactID: artifactID,
 		Version:    version,
 		Type:       "jar",
 		Classifier: "",


[camel-k] 03/09: fix golint findings for pkg/stub/action

Posted by nf...@apache.org.
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 <lb...@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 {


[camel-k] 01/09: chore: fix golint findings for pkg/install

Posted by nf...@apache.org.
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 5a780dd4cda861445a31c0a939b8d324934a6cb7
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Wed Sep 19 11:34:27 2018 +0200

    chore: fix golint findings for pkg/install
---
 pkg/install/cluster.go | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/pkg/install/cluster.go b/pkg/install/cluster.go
index 4fddf54..855d8f6 100644
--- a/pkg/install/cluster.go
+++ b/pkg/install/cluster.go
@@ -29,6 +29,7 @@ import (
 	"k8s.io/apimachinery/pkg/util/yaml"
 )
 
+// SetupClusterwideResources --
 func SetupClusterwideResources() error {
 
 	// Install CRD for Integration Context (if needed)
@@ -56,6 +57,7 @@ func SetupClusterwideResources() error {
 	return nil
 }
 
+// IsCRDInstalled check if the given CRT kind is installed
 func IsCRDInstalled(kind string) (bool, error) {
 	lst, err := k8sclient.GetKubeClient().Discovery().ServerResourcesForGroupVersion("camel.apache.org/v1alpha1")
 	if err != nil && errors.IsNotFound(err) {
@@ -82,7 +84,7 @@ func installCRD(kind string, resourceName string) error {
 	}
 
 	crd := []byte(deploy.Resources[resourceName])
-	crdJson, err := yaml.ToJSON(crd)
+	crdJSON, err := yaml.ToJSON(crd)
 	if err != nil {
 		return err
 	}
@@ -93,7 +95,7 @@ func installCRD(kind string, resourceName string) error {
 	// Post using dynamic client
 	result := restClient.
 		Post().
-		Body(crdJson).
+		Body(crdJSON).
 		Resource("customresourcedefinitions").
 		Do()
 	// Check result
@@ -104,6 +106,7 @@ func installCRD(kind string, resourceName string) error {
 	return nil
 }
 
+// IsClusterRoleInstalled check if cluster role camel-k:edit is installed
 func IsClusterRoleInstalled() (bool, error) {
 	clusterRole := v1.ClusterRole{
 		TypeMeta: metav1.TypeMeta{


[camel-k] 09/09: chore: remove unused code

Posted by nf...@apache.org.
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 8db26ed3089100ac327aa841f0884f4ba229f864
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Wed Sep 19 12:23:01 2018 +0200

    chore: remove unused code
---
 pkg/apis/camel/v1alpha1/register.go              |  7 +-
 pkg/build/local/scheme.go                        | 98 ------------------------
 pkg/util/kubernetes/customclient/customclient.go |  1 +
 pkg/util/kubernetes/customclient/scheme.go       | 33 --------
 4 files changed, 5 insertions(+), 134 deletions(-)

diff --git a/pkg/apis/camel/v1alpha1/register.go b/pkg/apis/camel/v1alpha1/register.go
index 52af408..460dd4c 100644
--- a/pkg/apis/camel/v1alpha1/register.go
+++ b/pkg/apis/camel/v1alpha1/register.go
@@ -31,14 +31,15 @@ const (
 )
 
 var (
-	SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
-	AddToScheme   = SchemeBuilder.AddToScheme
 	// SchemeGroupVersion is the group version used to register these objects.
 	SchemeGroupVersion = schema.GroupVersion{Group: groupName, Version: version}
 )
 
 func init() {
-	sdkK8sutil.AddToSDKScheme(AddToScheme)
+	schemeBuilder := runtime.NewSchemeBuilder(addKnownTypes)
+	addToScheme := schemeBuilder.AddToScheme
+
+	sdkK8sutil.AddToSDKScheme(addToScheme)
 }
 
 // addKnownTypes adds the set of types defined in this package to the supplied scheme.
diff --git a/pkg/build/local/scheme.go b/pkg/build/local/scheme.go
deleted file mode 100644
index 465c290..0000000
--- a/pkg/build/local/scheme.go
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
-Copyright 2018 The Kubernetes Authors.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package local
-
-import (
-	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-	"k8s.io/apimachinery/pkg/runtime"
-	"k8s.io/apimachinery/pkg/runtime/schema"
-	"k8s.io/apimachinery/pkg/runtime/serializer"
-	"k8s.io/apimachinery/pkg/runtime/serializer/json"
-	"k8s.io/apimachinery/pkg/runtime/serializer/versioning"
-)
-
-var watchScheme = runtime.NewScheme()
-var basicScheme = runtime.NewScheme()
-var deleteScheme = runtime.NewScheme()
-var parameterScheme = runtime.NewScheme()
-var deleteOptionsCodec = serializer.NewCodecFactory(deleteScheme)
-var dynamicParameterCodec = runtime.NewParameterCodec(parameterScheme)
-
-var versionV1 = schema.GroupVersion{Version: "v1"}
-
-func init() {
-	metav1.AddToGroupVersion(watchScheme, versionV1)
-	metav1.AddToGroupVersion(basicScheme, versionV1)
-	metav1.AddToGroupVersion(parameterScheme, versionV1)
-	metav1.AddToGroupVersion(deleteScheme, versionV1)
-}
-
-var watchJsonSerializerInfo = runtime.SerializerInfo{
-	MediaType:        "application/json",
-	EncodesAsText:    true,
-	Serializer:       json.NewSerializer(json.DefaultMetaFactory, watchScheme, watchScheme, false),
-	PrettySerializer: json.NewSerializer(json.DefaultMetaFactory, watchScheme, watchScheme, true),
-	StreamSerializer: &runtime.StreamSerializerInfo{
-		EncodesAsText: true,
-		Serializer:    json.NewSerializer(json.DefaultMetaFactory, watchScheme, watchScheme, false),
-		Framer:        json.Framer,
-	},
-}
-
-// watchNegotiatedSerializer is used to read the wrapper of the watch stream
-type watchNegotiatedSerializer struct{}
-
-var watchNegotiatedSerializerInstance = watchNegotiatedSerializer{}
-
-func (s watchNegotiatedSerializer) SupportedMediaTypes() []runtime.SerializerInfo {
-	return []runtime.SerializerInfo{watchJsonSerializerInfo}
-}
-
-func (s watchNegotiatedSerializer) EncoderForVersion(encoder runtime.Encoder, gv runtime.GroupVersioner) runtime.Encoder {
-	return versioning.NewDefaultingCodecForScheme(watchScheme, encoder, nil, gv, nil)
-}
-
-func (s watchNegotiatedSerializer) DecoderToVersion(decoder runtime.Decoder, gv runtime.GroupVersioner) runtime.Decoder {
-	return versioning.NewDefaultingCodecForScheme(watchScheme, nil, decoder, nil, gv)
-}
-
-// basicNegotiatedSerializer is used to handle discovery and error handling serialization
-type basicNegotiatedSerializer struct{}
-
-func (s basicNegotiatedSerializer) SupportedMediaTypes() []runtime.SerializerInfo {
-	return []runtime.SerializerInfo{
-		{
-			MediaType:        "application/json",
-			EncodesAsText:    true,
-			Serializer:       json.NewSerializer(json.DefaultMetaFactory, basicScheme, basicScheme, false),
-			PrettySerializer: json.NewSerializer(json.DefaultMetaFactory, basicScheme, basicScheme, true),
-			StreamSerializer: &runtime.StreamSerializerInfo{
-				EncodesAsText: true,
-				Serializer:    json.NewSerializer(json.DefaultMetaFactory, basicScheme, basicScheme, false),
-				Framer:        json.Framer,
-			},
-		},
-	}
-}
-
-func (s basicNegotiatedSerializer) EncoderForVersion(encoder runtime.Encoder, gv runtime.GroupVersioner) runtime.Encoder {
-	return versioning.NewDefaultingCodecForScheme(watchScheme, encoder, nil, gv, nil)
-}
-
-func (s basicNegotiatedSerializer) DecoderToVersion(decoder runtime.Decoder, gv runtime.GroupVersioner) runtime.Decoder {
-	return versioning.NewDefaultingCodecForScheme(watchScheme, nil, decoder, nil, gv)
-}
diff --git a/pkg/util/kubernetes/customclient/customclient.go b/pkg/util/kubernetes/customclient/customclient.go
index 9e38b6c..c0e3b64 100644
--- a/pkg/util/kubernetes/customclient/customclient.go
+++ b/pkg/util/kubernetes/customclient/customclient.go
@@ -23,6 +23,7 @@ import (
 	"k8s.io/client-go/rest"
 )
 
+// GetClientFor returns a RESTClient for the given group and version
 func GetClientFor(group string, version string) (*rest.RESTClient, error) {
 	inConfig := k8sclient.GetKubeConfig()
 	config := rest.CopyConfig(inConfig)
diff --git a/pkg/util/kubernetes/customclient/scheme.go b/pkg/util/kubernetes/customclient/scheme.go
index 7edcd02..9f62c42 100644
--- a/pkg/util/kubernetes/customclient/scheme.go
+++ b/pkg/util/kubernetes/customclient/scheme.go
@@ -20,7 +20,6 @@ import (
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/apimachinery/pkg/runtime"
 	"k8s.io/apimachinery/pkg/runtime/schema"
-	"k8s.io/apimachinery/pkg/runtime/serializer"
 	"k8s.io/apimachinery/pkg/runtime/serializer/json"
 	"k8s.io/apimachinery/pkg/runtime/serializer/versioning"
 )
@@ -29,9 +28,6 @@ var watchScheme = runtime.NewScheme()
 var basicScheme = runtime.NewScheme()
 var deleteScheme = runtime.NewScheme()
 var parameterScheme = runtime.NewScheme()
-var deleteOptionsCodec = serializer.NewCodecFactory(deleteScheme)
-var dynamicParameterCodec = runtime.NewParameterCodec(parameterScheme)
-
 var versionV1 = schema.GroupVersion{Version: "v1"}
 
 func init() {
@@ -41,35 +37,6 @@ func init() {
 	metav1.AddToGroupVersion(deleteScheme, versionV1)
 }
 
-var watchJsonSerializerInfo = runtime.SerializerInfo{
-	MediaType:        "application/json",
-	EncodesAsText:    true,
-	Serializer:       json.NewSerializer(json.DefaultMetaFactory, watchScheme, watchScheme, false),
-	PrettySerializer: json.NewSerializer(json.DefaultMetaFactory, watchScheme, watchScheme, true),
-	StreamSerializer: &runtime.StreamSerializerInfo{
-		EncodesAsText: true,
-		Serializer:    json.NewSerializer(json.DefaultMetaFactory, watchScheme, watchScheme, false),
-		Framer:        json.Framer,
-	},
-}
-
-// watchNegotiatedSerializer is used to read the wrapper of the watch stream
-type watchNegotiatedSerializer struct{}
-
-var watchNegotiatedSerializerInstance = watchNegotiatedSerializer{}
-
-func (s watchNegotiatedSerializer) SupportedMediaTypes() []runtime.SerializerInfo {
-	return []runtime.SerializerInfo{watchJsonSerializerInfo}
-}
-
-func (s watchNegotiatedSerializer) EncoderForVersion(encoder runtime.Encoder, gv runtime.GroupVersioner) runtime.Encoder {
-	return versioning.NewDefaultingCodecForScheme(watchScheme, encoder, nil, gv, nil)
-}
-
-func (s watchNegotiatedSerializer) DecoderToVersion(decoder runtime.Decoder, gv runtime.GroupVersioner) runtime.Decoder {
-	return versioning.NewDefaultingCodecForScheme(watchScheme, nil, decoder, nil, gv)
-}
-
 // basicNegotiatedSerializer is used to handle discovery and error handling serialization
 type basicNegotiatedSerializer struct{}
 


[camel-k] 02/09: fix golint findings for pkg/client

Posted by nf...@apache.org.
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 165589212ebe55820bdff1da6ab781bf0da5158e
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Wed Sep 19 11:37:47 2018 +0200

    fix golint findings for pkg/client
---
 pkg/client/cmd/context.go |  3 +--
 pkg/client/cmd/get.go     |  8 ++++----
 pkg/client/cmd/install.go |  5 ++---
 pkg/client/cmd/root.go    | 10 +++++-----
 pkg/client/cmd/run.go     |  8 ++++----
 pkg/client/cmd/version.go |  2 +-
 6 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/pkg/client/cmd/context.go b/pkg/client/cmd/context.go
index 949dab0..7fa66ed 100644
--- a/pkg/client/cmd/context.go
+++ b/pkg/client/cmd/context.go
@@ -21,8 +21,7 @@ import (
 	"github.com/spf13/cobra"
 )
 
-// NewCmdContext --
-func NewCmdContext(rootCmdOptions *RootCmdOptions) *cobra.Command {
+func newCmdContext(rootCmdOptions *RootCmdOptions) *cobra.Command {
 	cmd := cobra.Command{
 		Use:   "context",
 		Short: "Configure an Integration Context",
diff --git a/pkg/client/cmd/get.go b/pkg/client/cmd/get.go
index 7ae35ce..5b68adc 100644
--- a/pkg/client/cmd/get.go
+++ b/pkg/client/cmd/get.go
@@ -28,12 +28,12 @@ import (
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 )
 
-type GetCmdOptions struct {
+type getCmdOptions struct {
 	*RootCmdOptions
 }
 
-func NewCmdGet(rootCmdOptions *RootCmdOptions) *cobra.Command {
-	options := GetCmdOptions{
+func newCmdGet(rootCmdOptions *RootCmdOptions) *cobra.Command {
+	options := getCmdOptions{
 		RootCmdOptions: rootCmdOptions,
 	}
 	cmd := cobra.Command{
@@ -46,7 +46,7 @@ func NewCmdGet(rootCmdOptions *RootCmdOptions) *cobra.Command {
 	return &cmd
 }
 
-func (o *GetCmdOptions) run(cmd *cobra.Command, args []string) error {
+func (o *getCmdOptions) run(cmd *cobra.Command, args []string) error {
 	integrationList := v1alpha1.IntegrationList{
 		TypeMeta: metav1.TypeMeta{
 			APIVersion: v1alpha1.SchemeGroupVersion.String(),
diff --git a/pkg/client/cmd/install.go b/pkg/client/cmd/install.go
index cd84fbd..2ca05ba 100644
--- a/pkg/client/cmd/install.go
+++ b/pkg/client/cmd/install.go
@@ -23,13 +23,12 @@ import (
 	"os"
 
 	"github.com/apache/camel-k/pkg/install"
+	"github.com/pkg/errors"
 	"github.com/spf13/cobra"
 	k8serrors "k8s.io/apimachinery/pkg/api/errors"
-	"github.com/pkg/errors"
 )
 
-// NewCmdInstall --
-func NewCmdInstall(rootCmdOptions *RootCmdOptions) *cobra.Command {
+func newCmdInstall(rootCmdOptions *RootCmdOptions) *cobra.Command {
 	options := installCmdOptions{
 		RootCmdOptions: rootCmdOptions,
 	}
diff --git a/pkg/client/cmd/root.go b/pkg/client/cmd/root.go
index dfbbfd9..7fbeeef 100644
--- a/pkg/client/cmd/root.go
+++ b/pkg/client/cmd/root.go
@@ -73,11 +73,11 @@ func NewKamelCommand(ctx context.Context) (*cobra.Command, error) {
 	}
 
 	cmd.AddCommand(newCmdCompletion(&cmd))
-	cmd.AddCommand(NewCmdVersion())
-	cmd.AddCommand(NewCmdRun(&options))
-	cmd.AddCommand(NewCmdGet(&options))
-	cmd.AddCommand(NewCmdInstall(&options))
-	cmd.AddCommand(NewCmdContext(&options))
+	cmd.AddCommand(newCmdVersion())
+	cmd.AddCommand(newCmdRun(&options))
+	cmd.AddCommand(newCmdGet(&options))
+	cmd.AddCommand(newCmdInstall(&options))
+	cmd.AddCommand(newCmdContext(&options))
 
 	return &cmd, nil
 }
diff --git a/pkg/client/cmd/run.go b/pkg/client/cmd/run.go
index 47e23fe..2275e8b 100644
--- a/pkg/client/cmd/run.go
+++ b/pkg/client/cmd/run.go
@@ -20,13 +20,14 @@ package cmd
 import (
 	"errors"
 	"fmt"
-	"github.com/apache/camel-k/pkg/util/sync"
-	"github.com/sirupsen/logrus"
 	"io/ioutil"
 	"os"
 	"strconv"
 	"strings"
 
+	"github.com/apache/camel-k/pkg/util/sync"
+	"github.com/sirupsen/logrus"
+
 	"io"
 
 	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
@@ -39,8 +40,7 @@ import (
 	"k8s.io/apimachinery/pkg/apis/meta/v1"
 )
 
-// NewCmdRun --
-func NewCmdRun(rootCmdOptions *RootCmdOptions) *cobra.Command {
+func newCmdRun(rootCmdOptions *RootCmdOptions) *cobra.Command {
 	options := runCmdOptions{
 		RootCmdOptions: rootCmdOptions,
 	}
diff --git a/pkg/client/cmd/version.go b/pkg/client/cmd/version.go
index 1424a37..2153107 100644
--- a/pkg/client/cmd/version.go
+++ b/pkg/client/cmd/version.go
@@ -24,7 +24,7 @@ import (
 	"github.com/spf13/cobra"
 )
 
-func NewCmdVersion() *cobra.Command {
+func newCmdVersion() *cobra.Command {
 	return &cobra.Command{
 		Use:   "version",
 		Short: "Display client version",


[camel-k] 08/09: fix golint findings for pkg/util/sync

Posted by nf...@apache.org.
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 8c61e3b04ec9658c8a017b660950fb56ce790523
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Wed Sep 19 12:12:08 2018 +0200

    fix golint findings for pkg/util/sync
---
 pkg/util/sync/file.go | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/pkg/util/sync/file.go b/pkg/util/sync/file.go
index 1be83b8..d40ebe2 100644
--- a/pkg/util/sync/file.go
+++ b/pkg/util/sync/file.go
@@ -20,9 +20,10 @@ package sync
 
 import (
 	"context"
+	"time"
+
 	"github.com/radovskyb/watcher"
 	"github.com/sirupsen/logrus"
-	"time"
 )
 
 // File returns a channel that signals each time the content of the file changes


[camel-k] 06/09: fix golint findings for pkg/util/openshift

Posted by nf...@apache.org.
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 529a25daa06cf2c551349df42be8dc4aee0bacf8
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Wed Sep 19 12:09:16 2018 +0200

    fix golint findings for pkg/util/openshift
---
 pkg/util/openshift/register.go | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/pkg/util/openshift/register.go b/pkg/util/openshift/register.go
index f399bab..83b08aa 100644
--- a/pkg/util/openshift/register.go
+++ b/pkg/util/openshift/register.go
@@ -15,7 +15,6 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */
 
-// Register all Openshift types that we want to manage.
 package openshift
 
 import (
@@ -30,14 +29,11 @@ import (
 	"k8s.io/apimachinery/pkg/runtime"
 )
 
+// Register all Openshift types that we want to manage.
 func init() {
-	k8sutil.AddToSDKScheme(AddToScheme)
+	k8sutil.AddToSDKScheme(addKnownTypes)
 }
 
-var (
-	AddToScheme = addKnownTypes
-)
-
 type registerFunction func(*runtime.Scheme) error
 
 func addKnownTypes(scheme *runtime.Scheme) error {


[camel-k] 04/09: fix golint findings for pkg/util/kubernetes

Posted by nf...@apache.org.
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 c92031dd642afd991cc3de4b7e1c3f1796a7a4ab
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Wed Sep 19 11:50:25 2018 +0200

    fix golint findings for pkg/util/kubernetes
---
 pkg/util/kubernetes/config.go    | 10 ++++++----
 pkg/util/kubernetes/loader.go    |  5 +++--
 pkg/util/kubernetes/namespace.go |  6 ++++--
 pkg/util/kubernetes/sanitize.go  |  1 +
 pkg/util/kubernetes/wait.go      | 23 ++++++++++++++++++++++-
 5 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/pkg/util/kubernetes/config.go b/pkg/util/kubernetes/config.go
index 465b96c..b5d7393 100644
--- a/pkg/util/kubernetes/config.go
+++ b/pkg/util/kubernetes/config.go
@@ -18,15 +18,17 @@ limitations under the License.
 package kubernetes
 
 import (
-	"github.com/operator-framework/operator-sdk/pkg/k8sclient"
-	"k8s.io/client-go/tools/clientcmd"
 	"os/user"
 	"path/filepath"
+
+	"github.com/operator-framework/operator-sdk/pkg/k8sclient"
+	"k8s.io/client-go/tools/clientcmd"
 )
 
+// InitKubeClient initialize the k8s client
 func InitKubeClient(kubeconfig string) error {
 	if kubeconfig == "" {
-		kubeconfig = GetDefaultKubeConfigFile()
+		kubeconfig = getDefaultKubeConfigFile()
 	}
 
 	// use the current context in kubeconfig
@@ -39,7 +41,7 @@ func InitKubeClient(kubeconfig string) error {
 	return nil
 }
 
-func GetDefaultKubeConfigFile() string {
+func getDefaultKubeConfigFile() string {
 	usr, err := user.Current()
 	if err != nil {
 		panic(err) // TODO handle error
diff --git a/pkg/util/kubernetes/loader.go b/pkg/util/kubernetes/loader.go
index 7e00bc7..fdc1fb8 100644
--- a/pkg/util/kubernetes/loader.go
+++ b/pkg/util/kubernetes/loader.go
@@ -24,14 +24,15 @@ import (
 	"k8s.io/apimachinery/pkg/util/yaml"
 )
 
+// LoadResourceFromYaml loads a k8s resource from a yaml definition
 func LoadResourceFromYaml(data string) (runtime.Object, error) {
 	role := []byte(data)
-	roleJson, err := yaml.ToJSON(role)
+	roleJSON, err := yaml.ToJSON(role)
 	if err != nil {
 		return nil, err
 	}
 	u := unstructured.Unstructured{}
-	err = u.UnmarshalJSON(roleJson)
+	err = u.UnmarshalJSON(roleJSON)
 	if err != nil {
 		return nil, err
 	}
diff --git a/pkg/util/kubernetes/namespace.go b/pkg/util/kubernetes/namespace.go
index 279f64b..664330c 100644
--- a/pkg/util/kubernetes/namespace.go
+++ b/pkg/util/kubernetes/namespace.go
@@ -18,17 +18,19 @@ limitations under the License.
 package kubernetes
 
 import (
-	"github.com/pkg/errors"
 	"io/ioutil"
+
+	"github.com/pkg/errors"
 	"k8s.io/apimachinery/pkg/runtime/schema"
 	"k8s.io/client-go/tools/clientcmd"
 	clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
 	clientcmdlatest "k8s.io/client-go/tools/clientcmd/api/latest"
 )
 
+// GetClientCurrentNamespace --
 func GetClientCurrentNamespace(kubeconfig string) (string, error) {
 	if kubeconfig == "" {
-		kubeconfig = GetDefaultKubeConfigFile()
+		kubeconfig = getDefaultKubeConfigFile()
 	}
 	if kubeconfig == "" {
 		return "default", nil
diff --git a/pkg/util/kubernetes/sanitize.go b/pkg/util/kubernetes/sanitize.go
index e42c554..3021103 100644
--- a/pkg/util/kubernetes/sanitize.go
+++ b/pkg/util/kubernetes/sanitize.go
@@ -32,6 +32,7 @@ func init() {
 	disallowedChars = regexp.MustCompile("[^a-z0-9-]")
 }
 
+// SanitizeName sanitizes the given name to be compatible with k8s
 func SanitizeName(name string) string {
 	name = strings.Split(name, ".")[0]
 	name = path.Base(name)
diff --git a/pkg/util/kubernetes/wait.go b/pkg/util/kubernetes/wait.go
index 1ce55ee..9ae6948 100644
--- a/pkg/util/kubernetes/wait.go
+++ b/pkg/util/kubernetes/wait.go
@@ -1,20 +1,41 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
 package kubernetes
 
 import (
+	"time"
+
 	"github.com/operator-framework/operator-sdk/pkg/sdk"
 	"github.com/pkg/errors"
 	"k8s.io/apimachinery/pkg/runtime"
-	"time"
 )
 
+// ResourceRetrieveFunction --
 type ResourceRetrieveFunction func() (interface{}, error)
 
+// ResourceCheckFunction --
 type ResourceCheckFunction func(interface{}) (bool, error)
 
 const (
 	sleepTime = 400 * time.Millisecond
 )
 
+// WaitCondition --
 func WaitCondition(obj runtime.Object, condition ResourceCheckFunction, maxDuration time.Duration) error {
 	start := time.Now()
 


[camel-k] 07/09: fix golint findings for pkg/util/watch

Posted by nf...@apache.org.
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 7501383a711e9a5d5dcaa562a03fe52ed68998d5
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Wed Sep 19 12:10:19 2018 +0200

    fix golint findings for pkg/util/watch
---
 pkg/client/cmd/run.go   |  2 +-
 pkg/util/watch/watch.go | 13 +++++++------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/pkg/client/cmd/run.go b/pkg/client/cmd/run.go
index 2275e8b..37d06bb 100644
--- a/pkg/client/cmd/run.go
+++ b/pkg/client/cmd/run.go
@@ -134,7 +134,7 @@ func (o *runCmdOptions) run(cmd *cobra.Command, args []string) error {
 
 func (o *runCmdOptions) waitForIntegrationReady(integration *v1alpha1.Integration) error {
 	// Block this goroutine until the integration is in a final status
-	changes, err := watch.WatchStateChanges(o.Context, integration)
+	changes, err := watch.StateChanges(o.Context, integration)
 	if err != nil {
 		return err
 	}
diff --git a/pkg/util/watch/watch.go b/pkg/util/watch/watch.go
index 3ec0bda..1ed9671 100644
--- a/pkg/util/watch/watch.go
+++ b/pkg/util/watch/watch.go
@@ -18,18 +18,19 @@ limitations under the License.
 package watch
 
 import (
-	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
 	"context"
+
+	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
 	"github.com/operator-framework/operator-sdk/pkg/k8sclient"
-	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-	"k8s.io/apimachinery/pkg/runtime"
 	"github.com/operator-framework/operator-sdk/pkg/util/k8sutil"
-	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
 	"github.com/sirupsen/logrus"
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
+	"k8s.io/apimachinery/pkg/runtime"
 )
 
-// Watches a integration resource and send it through a channel when its status changes
-func WatchStateChanges(ctx context.Context, integration *v1alpha1.Integration) (<-chan *v1alpha1.Integration, error) {
+// StateChanges watches a integration resource and send it through a channel when its status changes
+func StateChanges(ctx context.Context, integration *v1alpha1.Integration) (<-chan *v1alpha1.Integration, error) {
 	resourceClient, _, err := k8sclient.GetResourceClient(integration.APIVersion, integration.Kind, integration.Namespace)
 	if err != nil {
 		return nil, err