Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix golint findings, remove unused code #103

Merged
merged 9 commits into from
Sep 19, 2018
7 changes: 4 additions & 3 deletions pkg/apis/camel/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
26 changes: 13 additions & 13 deletions pkg/build/local/local_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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",
Expand All @@ -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 {
Expand All @@ -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
}
14 changes: 7 additions & 7 deletions pkg/build/local/local_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "")
}

Expand All @@ -75,6 +75,6 @@ func TestProjectGenerationWithFailure(t *testing.T) {
},
}

_, err := generateProjectDefinition(source)
_, err := generateIntegration(source)
assert.NotNil(t, err)
}
98 changes: 0 additions & 98 deletions pkg/build/local/scheme.go

This file was deleted.

3 changes: 1 addition & 2 deletions pkg/client/cmd/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions pkg/client/cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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(),
Expand Down
5 changes: 2 additions & 3 deletions pkg/client/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/client/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
10 changes: 5 additions & 5 deletions pkg/client/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
}
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 5 additions & 2 deletions pkg/install/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"k8s.io/apimachinery/pkg/util/yaml"
)

// SetupClusterwideResources --
func SetupClusterwideResources() error {

// Install CRD for Integration Context (if needed)
Expand Down Expand Up @@ -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) {
Expand All @@ -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
}
Expand All @@ -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
Expand All @@ -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{
Expand Down
1 change: 1 addition & 0 deletions pkg/stub/action/context/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading