You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by GitBox <gi...@apache.org> on 2018/09/11 06:30:44 UTC
[GitHub] nicolaferraro closed pull request #17: t code
nicolaferraro closed pull request #17: t code
URL: https://github.com/apache/camel-k/pull/17
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/cmd/kamel/kamel.go b/cmd/kamel/kamel.go
index c502427..3328370 100644
--- a/cmd/kamel/kamel.go
+++ b/cmd/kamel/kamel.go
@@ -18,10 +18,10 @@ limitations under the License.
package main
import (
- _ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"fmt"
- "os"
"github.com/apache/camel-k/pkg/client/cmd"
+ _ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
+ "os"
)
func main() {
diff --git a/pkg/apis/camel/v1alpha1/types.go b/pkg/apis/camel/v1alpha1/types.go
index ec30eb9..f531052 100644
--- a/pkg/apis/camel/v1alpha1/types.go
+++ b/pkg/apis/camel/v1alpha1/types.go
@@ -39,12 +39,12 @@ type Integration struct {
}
type IntegrationSpec struct {
- Replicas *int32 `json:"replicas,omitempty"`
- Source SourceSpec `json:"source,omitempty"`
+ Replicas *int32 `json:"replicas,omitempty"`
+ Source SourceSpec `json:"source,omitempty"`
}
type SourceSpec struct {
- Code *string `json:"code,omitempty"`
+ Code *string `json:"code,omitempty"`
}
type IntegrationStatus struct {
@@ -56,8 +56,8 @@ type IntegrationStatus struct {
type IntegrationPhase string
const (
- IntegrationPhaseBuilding IntegrationPhase = "Building"
- IntegrationPhaseDeploying IntegrationPhase = "Deploying"
- IntegrationPhaseRunning IntegrationPhase = "Running"
- IntegrationPhaseError IntegrationPhase = "Error"
-)
\ No newline at end of file
+ IntegrationPhaseBuilding IntegrationPhase = "Building"
+ IntegrationPhaseDeploying IntegrationPhase = "Deploying"
+ IntegrationPhaseRunning IntegrationPhase = "Running"
+ IntegrationPhaseError IntegrationPhase = "Error"
+)
diff --git a/pkg/build/api/types.go b/pkg/build/api/types.go
index 3358a6c..892e526 100644
--- a/pkg/build/api/types.go
+++ b/pkg/build/api/types.go
@@ -19,32 +19,33 @@ package api
// a request to build a specific code
type BuildSource struct {
- Identifier BuildIdentifier
- Code string
+ Identifier BuildIdentifier
+ Code string
}
type BuildIdentifier struct {
- Name string
- Digest string
+ Name string
+ Digest string
}
// represents the result of a build
type BuildResult struct {
- Source *BuildSource
- Status BuildStatus
- Image string
- Error error
+ Source *BuildSource
+ Status BuildStatus
+ Image string
+ Error error
}
// supertype of all builders
type Builder interface {
- Build(BuildSource) <- chan BuildResult
+ Build(BuildSource) <-chan BuildResult
}
type BuildStatus int
+
const (
- BuildStatusNotRequested BuildStatus = iota
+ BuildStatusNotRequested BuildStatus = iota
BuildStatusStarted
BuildStatusCompleted
BuildStatusError
-)
\ No newline at end of file
+)
diff --git a/pkg/build/build_manager.go b/pkg/build/build_manager.go
index 170a5e6..7006053 100644
--- a/pkg/build/build_manager.go
+++ b/pkg/build/build_manager.go
@@ -18,22 +18,22 @@ limitations under the License.
package build
import (
- "sync"
- "github.com/apache/camel-k/pkg/build/local"
"context"
"github.com/apache/camel-k/pkg/build/api"
+ "github.com/apache/camel-k/pkg/build/local"
+ "sync"
)
// main facade to the image build system
type BuildManager struct {
- builds map[api.BuildIdentifier]*api.BuildResult
- mutex sync.Mutex
- builder api.Builder
+ builds map[api.BuildIdentifier]*api.BuildResult
+ mutex sync.Mutex
+ builder api.Builder
}
func NewBuildManager(ctx context.Context, namespace string) *BuildManager {
return &BuildManager{
- builds: make(map[api.BuildIdentifier]*api.BuildResult),
+ builds: make(map[api.BuildIdentifier]*api.BuildResult),
builder: local.NewLocalBuilder(ctx, namespace),
}
}
@@ -77,4 +77,4 @@ func initialBuildInfo(source *api.BuildSource) api.BuildResult {
Source: source,
Status: api.BuildStatusStarted,
}
-}
\ No newline at end of file
+}
diff --git a/pkg/build/build_manager_integration_test.go b/pkg/build/build_manager_integration_test.go
index 5d19201..932b315 100644
--- a/pkg/build/build_manager_integration_test.go
+++ b/pkg/build/build_manager_integration_test.go
@@ -20,13 +20,13 @@ limitations under the License.
package build
import (
- "testing"
"context"
- "github.com/stretchr/testify/assert"
build "github.com/apache/camel-k/pkg/build/api"
- "time"
- "github.com/apache/camel-k/pkg/util/test"
"github.com/apache/camel-k/pkg/util/digest"
+ "github.com/apache/camel-k/pkg/util/test"
+ "github.com/stretchr/testify/assert"
+ "testing"
+ "time"
)
func TestBuild(t *testing.T) {
diff --git a/pkg/build/local/local_builder.go b/pkg/build/local/local_builder.go
index d37a56e..17529b2 100644
--- a/pkg/build/local/local_builder.go
+++ b/pkg/build/local/local_builder.go
@@ -19,24 +19,24 @@ package local
import (
"context"
+ buildv1 "github.com/openshift/api/build/v1"
+ imagev1 "github.com/openshift/api/image/v1"
+ "github.com/operator-framework/operator-sdk/pkg/sdk"
+ "github.com/operator-framework/operator-sdk/pkg/util/k8sutil"
+ "github.com/pkg/errors"
"github.com/sirupsen/logrus"
- "time"
"io/ioutil"
- "github.com/pkg/errors"
- buildv1 "github.com/openshift/api/build/v1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/api/core/v1"
- "github.com/operator-framework/operator-sdk/pkg/sdk"
- imagev1 "github.com/openshift/api/image/v1"
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
- "github.com/operator-framework/operator-sdk/pkg/util/k8sutil"
+ "time"
- _ "github.com/apache/camel-k/pkg/util/openshift"
build "github.com/apache/camel-k/pkg/build/api"
"github.com/apache/camel-k/pkg/util/kubernetes"
- "github.com/apache/camel-k/version"
- "github.com/apache/camel-k/pkg/util/maven"
"github.com/apache/camel-k/pkg/util/kubernetes/customclient"
+ "github.com/apache/camel-k/pkg/util/maven"
+ _ "github.com/apache/camel-k/pkg/util/openshift"
+ "github.com/apache/camel-k/version"
)
type localBuilder struct {
diff --git a/pkg/build/local/local_builder_integration_test.go b/pkg/build/local/local_builder_integration_test.go
index fcb9eb6..8ab1460 100644
--- a/pkg/build/local/local_builder_integration_test.go
+++ b/pkg/build/local/local_builder_integration_test.go
@@ -20,12 +20,12 @@ limitations under the License.
package local
import (
- "testing"
"context"
- "github.com/stretchr/testify/assert"
build "github.com/apache/camel-k/pkg/build/api"
- "github.com/apache/camel-k/pkg/util/test"
"github.com/apache/camel-k/pkg/util/digest"
+ "github.com/apache/camel-k/pkg/util/test"
+ "github.com/stretchr/testify/assert"
+ "testing"
)
func TestBuild(t *testing.T) {
diff --git a/pkg/build/local/scheme.go b/pkg/build/local/scheme.go
index 7fdc19f..465c290 100644
--- a/pkg/build/local/scheme.go
+++ b/pkg/build/local/scheme.go
@@ -95,4 +95,4 @@ func (s basicNegotiatedSerializer) EncoderForVersion(encoder runtime.Encoder, gv
func (s basicNegotiatedSerializer) DecoderToVersion(decoder runtime.Decoder, gv runtime.GroupVersioner) runtime.Decoder {
return versioning.NewDefaultingCodecForScheme(watchScheme, nil, decoder, nil, gv)
-}
\ No newline at end of file
+}
diff --git a/pkg/client/cmd/get.go b/pkg/client/cmd/get.go
index 05be2e3..d5689b0 100644
--- a/pkg/client/cmd/get.go
+++ b/pkg/client/cmd/get.go
@@ -18,13 +18,13 @@ limitations under the License.
package cmd
import (
- "github.com/spf13/cobra"
- "text/tabwriter"
- "os"
"fmt"
"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/operator-framework/operator-sdk/pkg/sdk"
+ "github.com/spf13/cobra"
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "os"
+ "text/tabwriter"
)
type GetCmdOptions struct {
diff --git a/pkg/client/cmd/install.go b/pkg/client/cmd/install.go
index e57257c..27fa96f 100644
--- a/pkg/client/cmd/install.go
+++ b/pkg/client/cmd/install.go
@@ -18,9 +18,10 @@ limitations under the License.
package cmd
import (
- "github.com/spf13/cobra"
- installutils "github.com/apache/camel-k/pkg/install"
"fmt"
+
+ "github.com/apache/camel-k/pkg/install"
+ "github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/api/errors"
)
@@ -43,7 +44,7 @@ func NewCmdInstall(rootCmdOptions *RootCmdOptions) *cobra.Command {
}
func (o *InstallCmdOptions) install(cmd *cobra.Command, args []string) error {
- err := installutils.SetupClusterwideResources()
+ err := install.SetupClusterwideResources()
if err != nil && errors.IsForbidden(err) {
// TODO explain that this is a one time operation and add a flag to do cluster-level operations only when logged as admin
fmt.Println("Current user is not authorized to create cluster-wide objects like custom resource definitions or cluster roles: ", err)
@@ -53,7 +54,7 @@ func (o *InstallCmdOptions) install(cmd *cobra.Command, args []string) error {
namespace := o.Namespace
- err = installutils.InstallOperator(namespace)
+ err = install.Operator(namespace)
if err != nil {
return err
}
diff --git a/pkg/client/cmd/root.go b/pkg/client/cmd/root.go
index 4849a8c..697fbf5 100644
--- a/pkg/client/cmd/root.go
+++ b/pkg/client/cmd/root.go
@@ -20,9 +20,9 @@ package cmd
import (
"os"
- "github.com/spf13/cobra"
"github.com/apache/camel-k/pkg/util/kubernetes"
"github.com/pkg/errors"
+ "github.com/spf13/cobra"
)
type RootCmdOptions struct {
diff --git a/pkg/install/cluster.go b/pkg/install/cluster.go
index a6b60d5..818db03 100644
--- a/pkg/install/cluster.go
+++ b/pkg/install/cluster.go
@@ -18,15 +18,15 @@ limitations under the License.
package install
import (
- "github.com/operator-framework/operator-sdk/pkg/k8sclient"
"github.com/apache/camel-k/deploy"
- "k8s.io/apimachinery/pkg/util/yaml"
- "github.com/apache/camel-k/pkg/util/kubernetes/customclient"
- "k8s.io/apimachinery/pkg/api/errors"
"github.com/apache/camel-k/pkg/util/kubernetes"
+ "github.com/apache/camel-k/pkg/util/kubernetes/customclient"
+ "github.com/operator-framework/operator-sdk/pkg/k8sclient"
"github.com/operator-framework/operator-sdk/pkg/sdk"
"k8s.io/api/rbac/v1"
+ "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/apimachinery/pkg/util/yaml"
)
func SetupClusterwideResources() error {
diff --git a/pkg/install/cluster_integration_test.go b/pkg/install/cluster_integration_test.go
index df9f93c..1f6b6e4 100644
--- a/pkg/install/cluster_integration_test.go
+++ b/pkg/install/cluster_integration_test.go
@@ -18,8 +18,8 @@ limitations under the License.
package install
import (
- "testing"
"github.com/stretchr/testify/assert"
+ "testing"
)
func TestInstallation(t *testing.T) {
diff --git a/pkg/install/operator.go b/pkg/install/operator.go
index ad6d5d6..5934cc3 100644
--- a/pkg/install/operator.go
+++ b/pkg/install/operator.go
@@ -19,13 +19,13 @@ package install
import (
"github.com/apache/camel-k/deploy"
- "github.com/operator-framework/operator-sdk/pkg/sdk"
"github.com/apache/camel-k/pkg/util/kubernetes"
+ "github.com/operator-framework/operator-sdk/pkg/sdk"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
-func InstallOperator(namespace string) error {
+func Operator(namespace string) error {
return installResources(namespace,
"operator-service-account.yaml",
"operator-role.yaml",
diff --git a/pkg/stub/action/action.go b/pkg/stub/action/action.go
index c6d5cc2..08b45b4 100644
--- a/pkg/stub/action/action.go
+++ b/pkg/stub/action/action.go
@@ -31,5 +31,4 @@ type Action interface {
// executes the handling function
Handle(integration *v1alpha1.Integration) error
-
}
diff --git a/pkg/stub/action/build.go b/pkg/stub/action/build.go
index 62517b0..5dd69b8 100644
--- a/pkg/stub/action/build.go
+++ b/pkg/stub/action/build.go
@@ -18,16 +18,16 @@ limitations under the License.
package action
import (
- "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
"context"
+ "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
"github.com/apache/camel-k/pkg/build"
- "github.com/sirupsen/logrus"
- "github.com/operator-framework/operator-sdk/pkg/sdk"
"github.com/apache/camel-k/pkg/build/api"
+ "github.com/operator-framework/operator-sdk/pkg/sdk"
+ "github.com/sirupsen/logrus"
)
type BuildAction struct {
- buildManager *build.BuildManager
+ buildManager *build.BuildManager
}
func NewBuildAction(ctx context.Context, namespace string) *BuildAction {
@@ -46,14 +46,14 @@ func (b *BuildAction) CanHandle(integration *v1alpha1.Integration) bool {
func (b *BuildAction) Handle(integration *v1alpha1.Integration) error {
buildIdentifier := api.BuildIdentifier{
- Name: integration.Name,
+ Name: integration.Name,
Digest: integration.Status.Digest,
}
buildResult := b.buildManager.Get(buildIdentifier)
if buildResult.Status == api.BuildStatusNotRequested {
b.buildManager.Start(api.BuildSource{
Identifier: buildIdentifier,
- Code: *integration.Spec.Source.Code, // FIXME possible panic
+ Code: *integration.Spec.Source.Code, // FIXME possible panic
})
logrus.Info("Build started")
} else if buildResult.Status == api.BuildStatusError {
diff --git a/pkg/stub/action/deploy.go b/pkg/stub/action/deploy.go
index aa9f0df..3d242d9 100644
--- a/pkg/stub/action/deploy.go
+++ b/pkg/stub/action/deploy.go
@@ -19,12 +19,12 @@ package action
import (
"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
+ "github.com/operator-framework/operator-sdk/pkg/sdk"
+ "github.com/pkg/errors"
"k8s.io/api/apps/v1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
corev1 "k8s.io/api/core/v1"
- "github.com/operator-framework/operator-sdk/pkg/sdk"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
- "github.com/pkg/errors"
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
type DeployAction struct {
@@ -51,7 +51,7 @@ func (a *DeployAction) Handle(integration *v1alpha1.Integration) error {
}
if err != nil {
- return errors.Wrap(err, "could not create or replace deployment for integration " + integration.Name)
+ return errors.Wrap(err, "could not create or replace deployment for integration "+integration.Name)
}
target := integration.DeepCopy()
@@ -67,22 +67,22 @@ func (*DeployAction) getDeploymentFor(integration *v1alpha1.Integration) *v1.Dep
}
deployment := v1.Deployment{
TypeMeta: metav1.TypeMeta{
- Kind: "Deployment",
+ Kind: "Deployment",
APIVersion: v1.SchemeGroupVersion.String(),
},
ObjectMeta: metav1.ObjectMeta{
- Name: integration.Name,
- Namespace: integration.Namespace,
- Labels: integration.Labels,
+ Name: integration.Name,
+ Namespace: integration.Namespace,
+ Labels: integration.Labels,
Annotations: integration.Annotations,
OwnerReferences: []metav1.OwnerReference{
{
- APIVersion: integration.APIVersion,
- Kind: integration.Kind,
- Name: integration.Name,
- Controller: &controller,
+ APIVersion: integration.APIVersion,
+ Kind: integration.Kind,
+ Name: integration.Name,
+ Controller: &controller,
BlockOwnerDeletion: &blockOwnerDeletion,
- UID: integration.UID,
+ UID: integration.UID,
},
},
},
@@ -98,7 +98,7 @@ func (*DeployAction) getDeploymentFor(integration *v1alpha1.Integration) *v1.Dep
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
- Name: integration.Name,
+ Name: integration.Name,
Image: integration.Status.Image,
},
},
diff --git a/pkg/stub/action/initialize.go b/pkg/stub/action/initialize.go
index 8b5a445..f0c119a 100644
--- a/pkg/stub/action/initialize.go
+++ b/pkg/stub/action/initialize.go
@@ -19,13 +19,12 @@ package action
import (
"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
- "github.com/operator-framework/operator-sdk/pkg/sdk"
"github.com/apache/camel-k/pkg/util/digest"
+ "github.com/operator-framework/operator-sdk/pkg/sdk"
)
// initializes the integration status to trigger the deployment
type InitializeAction struct {
-
}
func NewInitializeAction() *InitializeAction {
diff --git a/pkg/stub/action/monitor.go b/pkg/stub/action/monitor.go
index deb30d6..9f67307 100644
--- a/pkg/stub/action/monitor.go
+++ b/pkg/stub/action/monitor.go
@@ -19,8 +19,8 @@ package action
import (
"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
- "github.com/operator-framework/operator-sdk/pkg/sdk"
"github.com/apache/camel-k/pkg/util/digest"
+ "github.com/operator-framework/operator-sdk/pkg/sdk"
"github.com/sirupsen/logrus"
)
@@ -47,8 +47,8 @@ func (a *MonitorAction) Handle(integration *v1alpha1.Integration) error {
logrus.Info("Integration ", integration.Name, " needs a rebuild")
target := integration.DeepCopy()
- target.Status.Digest=hash
- target.Status.Phase=v1alpha1.IntegrationPhaseBuilding
+ target.Status.Digest = hash
+ target.Status.Phase = v1alpha1.IntegrationPhaseBuilding
return sdk.Update(target)
}
diff --git a/pkg/stub/handler.go b/pkg/stub/handler.go
index a46c16f..53a2a42 100644
--- a/pkg/stub/handler.go
+++ b/pkg/stub/handler.go
@@ -22,8 +22,8 @@ import (
"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
- "github.com/operator-framework/operator-sdk/pkg/sdk"
"github.com/apache/camel-k/pkg/stub/action"
+ "github.com/operator-framework/operator-sdk/pkg/sdk"
"github.com/sirupsen/logrus"
)
@@ -39,7 +39,7 @@ func NewHandler(ctx context.Context, namespace string) sdk.Handler {
}
type Handler struct {
- actionPool []action.Action
+ actionPool []action.Action
}
func (h *Handler) Handle(ctx context.Context, event sdk.Event) error {
diff --git a/pkg/util/digest/digest.go b/pkg/util/digest/digest.go
index 5354718..ad10e6c 100644
--- a/pkg/util/digest/digest.go
+++ b/pkg/util/digest/digest.go
@@ -18,12 +18,12 @@ limitations under the License.
package digest
import (
- "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
"crypto/sha256"
- "github.com/apache/camel-k/version"
"encoding/base64"
- "strconv"
+ "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
+ "github.com/apache/camel-k/version"
"math/rand"
+ "strconv"
)
// Compute a digest of the fields that are relevant for the deployment
diff --git a/pkg/util/kubernetes/config.go b/pkg/util/kubernetes/config.go
index f01a8de..465b96c 100644
--- a/pkg/util/kubernetes/config.go
+++ b/pkg/util/kubernetes/config.go
@@ -18,10 +18,10 @@ 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"
- "k8s.io/client-go/tools/clientcmd"
- "github.com/operator-framework/operator-sdk/pkg/k8sclient"
)
func InitKubeClient(kubeconfig string) error {
diff --git a/pkg/util/kubernetes/customclient/customclient.go b/pkg/util/kubernetes/customclient/customclient.go
index 9dc0735..9e38b6c 100644
--- a/pkg/util/kubernetes/customclient/customclient.go
+++ b/pkg/util/kubernetes/customclient/customclient.go
@@ -18,9 +18,9 @@ limitations under the License.
package customclient
import (
- "k8s.io/client-go/rest"
- "k8s.io/apimachinery/pkg/runtime/schema"
"github.com/operator-framework/operator-sdk/pkg/k8sclient"
+ "k8s.io/apimachinery/pkg/runtime/schema"
+ "k8s.io/client-go/rest"
)
func GetClientFor(group string, version string) (*rest.RESTClient, error) {
diff --git a/pkg/util/kubernetes/customclient/scheme.go b/pkg/util/kubernetes/customclient/scheme.go
index f20496d..7edcd02 100644
--- a/pkg/util/kubernetes/customclient/scheme.go
+++ b/pkg/util/kubernetes/customclient/scheme.go
@@ -95,4 +95,4 @@ func (s basicNegotiatedSerializer) EncoderForVersion(encoder runtime.Encoder, gv
func (s basicNegotiatedSerializer) DecoderToVersion(decoder runtime.Decoder, gv runtime.GroupVersioner) runtime.Decoder {
return versioning.NewDefaultingCodecForScheme(watchScheme, nil, decoder, nil, gv)
-}
\ No newline at end of file
+}
diff --git a/pkg/util/kubernetes/loader.go b/pkg/util/kubernetes/loader.go
index c1cfc5a..7e00bc7 100644
--- a/pkg/util/kubernetes/loader.go
+++ b/pkg/util/kubernetes/loader.go
@@ -18,10 +18,10 @@ limitations under the License.
package kubernetes
import (
- "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"github.com/operator-framework/operator-sdk/pkg/util/k8sutil"
- "k8s.io/apimachinery/pkg/util/yaml"
+ "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
+ "k8s.io/apimachinery/pkg/util/yaml"
)
func LoadResourceFromYaml(data string) (runtime.Object, error) {
diff --git a/pkg/util/kubernetes/namespace.go b/pkg/util/kubernetes/namespace.go
index 116865d..279f64b 100644
--- a/pkg/util/kubernetes/namespace.go
+++ b/pkg/util/kubernetes/namespace.go
@@ -18,12 +18,12 @@ limitations under the License.
package kubernetes
import (
+ "github.com/pkg/errors"
+ "io/ioutil"
+ "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"
- "io/ioutil"
- "github.com/pkg/errors"
- "k8s.io/apimachinery/pkg/runtime/schema"
)
func GetClientCurrentNamespace(kubeconfig string) (string, error) {
diff --git a/pkg/util/kubernetes/sanitize.go b/pkg/util/kubernetes/sanitize.go
index 37ec58c..cb6b823 100644
--- a/pkg/util/kubernetes/sanitize.go
+++ b/pkg/util/kubernetes/sanitize.go
@@ -18,8 +18,8 @@ limitations under the License.
package kubernetes
import (
- "strings"
"regexp"
+ "strings"
"unicode"
)
@@ -39,4 +39,4 @@ func SanitizeName(name string) string {
func isDisallowedStartEndChar(rune rune) bool {
return !unicode.IsLetter(rune)
-}
\ No newline at end of file
+}
diff --git a/pkg/util/kubernetes/wait.go b/pkg/util/kubernetes/wait.go
index f333b78..1ce55ee 100644
--- a/pkg/util/kubernetes/wait.go
+++ b/pkg/util/kubernetes/wait.go
@@ -1,15 +1,15 @@
package kubernetes
import (
- "time"
+ "github.com/operator-framework/operator-sdk/pkg/sdk"
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/runtime"
- "github.com/operator-framework/operator-sdk/pkg/sdk"
+ "time"
)
-type ResourceRetrieveFunction func()(interface{}, error)
+type ResourceRetrieveFunction func() (interface{}, error)
-type ResourceCheckFunction func(interface{})(bool, error)
+type ResourceCheckFunction func(interface{}) (bool, error)
const (
sleepTime = 400 * time.Millisecond
@@ -36,4 +36,4 @@ func WaitCondition(obj runtime.Object, condition ResourceCheckFunction, maxDurat
return nil
}
return errors.New("timeout while waiting condition")
-}
\ No newline at end of file
+}
diff --git a/pkg/util/maven/maven.go b/pkg/util/maven/maven.go
index 08864ac..590908f 100644
--- a/pkg/util/maven/maven.go
+++ b/pkg/util/maven/maven.go
@@ -18,20 +18,19 @@ limitations under the License.
package maven
import (
- "io/ioutil"
- "os"
"archive/tar"
+ "github.com/pkg/errors"
"github.com/sirupsen/logrus"
"io"
- "github.com/pkg/errors"
+ "io/ioutil"
+ "os"
+ "os/exec"
"path"
"strings"
- "os/exec"
)
-
const (
- buildDirPrefix = "maven-"
+ buildDirPrefix = "maven-"
artifactDirPrefix = "maven-bin-"
)
@@ -84,15 +83,15 @@ func createTar(buildDir string, project Project) (string, error) {
return "", errors.Wrap(err, "could not create temporary dir for maven artifacts")
}
- tarFileName := path.Join(artifactDir, project.ArtifactId + ".tar")
+ tarFileName := path.Join(artifactDir, project.ArtifactId+".tar")
tarFile, err := os.Create(tarFileName)
if err != nil {
- return "", errors.Wrap(err, "cannot create tar file " + tarFileName)
+ return "", errors.Wrap(err, "cannot create tar file "+tarFileName)
}
defer tarFile.Close()
writer := tar.NewWriter(tarFile)
- err = appendToTar(path.Join(buildDir, "target", project.ArtifactId + "-" + project.Version + ".jar"), "", writer)
+ err = appendToTar(path.Join(buildDir, "target", project.ArtifactId+"-"+project.Version+".jar"), "", writer)
if err != nil {
return "", err
}
@@ -138,9 +137,9 @@ func appendToTar(filePath string, tarPath string, writer *tar.Writer) error {
}
writer.WriteHeader(&tar.Header{
- Name: fileName,
- Size: info.Size(),
- Mode: int64(info.Mode()),
+ Name: fileName,
+ Size: info.Size(),
+ Mode: int64(info.Mode()),
ModTime: info.ModTime(),
})
@@ -193,35 +192,33 @@ func writeFile(buildDir string, relativePath string, content string) error {
// Create dir if not present
err := os.MkdirAll(fileDir, 0777)
if err != nil {
- return errors.Wrap(err, "could not create dir for file " + relativePath)
+ return errors.Wrap(err, "could not create dir for file "+relativePath)
}
// Create file
file, err := os.Create(filePath)
if err != nil {
- return errors.Wrap(err, "could not create file " + relativePath)
+ return errors.Wrap(err, "could not create file "+relativePath)
}
defer file.Close()
_, err = file.WriteString(content)
if err != nil {
- errors.Wrap(err, "could not write to file " + relativePath)
+ errors.Wrap(err, "could not write to file "+relativePath)
}
return nil
}
-
func envFileContent(env map[string]string) string {
if env == nil {
return ""
}
content := ""
- for k,v := range env {
+ for k, v := range env {
content = content + "export " + k + "=" + v + "\n"
}
return content
}
-
func pomFileContent(project Project) string {
basePom := `<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
@@ -253,4 +250,4 @@ func pomFileContent(project Project) string {
pom := strings.Replace(basePom, "#dependencies#", depStr, 1)
return pom
-}
\ No newline at end of file
+}
diff --git a/pkg/util/maven/types.go b/pkg/util/maven/types.go
index c34bb84..501f737 100644
--- a/pkg/util/maven/types.go
+++ b/pkg/util/maven/types.go
@@ -28,7 +28,7 @@ type Project struct {
}
type Dependency struct {
- GroupId string
- ArtifactId string
- Version string
-}
\ No newline at end of file
+ GroupId string
+ ArtifactId string
+ Version string
+}
diff --git a/pkg/util/openshift/register.go b/pkg/util/openshift/register.go
index 076db9f..f399bab 100644
--- a/pkg/util/openshift/register.go
+++ b/pkg/util/openshift/register.go
@@ -52,7 +52,6 @@ func addKnownTypes(scheme *runtime.Scheme) error {
err = doAdd(build.AddToScheme, scheme, err)
err = doAdd(authorization.AddToScheme, scheme, err)
-
// Legacy "oapi" resources
err = doAdd(apps.AddToSchemeInCoreGroup, scheme, err)
err = doAdd(template.AddToSchemeInCoreGroup, scheme, err)
@@ -74,4 +73,4 @@ func doAdd(addToScheme registerFunction, scheme *runtime.Scheme, err error) erro
return callErr
}
return err
-}
\ No newline at end of file
+}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services