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 2019/06/26 08:58:53 UTC

[camel-k] branch master updated: chore: cleanup build

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


The following commit(s) were added to refs/heads/master by this push:
     new c16ed2c  chore: cleanup build
c16ed2c is described below

commit c16ed2ce2811cc7d378fd1eb2f5f7399eb0b18bf
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Sun Jun 23 22:12:26 2019 +0200

    chore: cleanup build
---
 pkg/apis/camel/v1alpha1/build_types_support.go | 17 +++++++++++++++++
 pkg/controller/integrationkit/build.go         | 10 ++++------
 pkg/util/kubernetes/util.go                    | 16 ++++++++++++++++
 3 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/pkg/apis/camel/v1alpha1/build_types_support.go b/pkg/apis/camel/v1alpha1/build_types_support.go
index d70be26..a49a4aa 100644
--- a/pkg/apis/camel/v1alpha1/build_types_support.go
+++ b/pkg/apis/camel/v1alpha1/build_types_support.go
@@ -1,3 +1,20 @@
+/*
+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 v1alpha1
 
 import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
diff --git a/pkg/controller/integrationkit/build.go b/pkg/controller/integrationkit/build.go
index 31de1e8..c0df680 100644
--- a/pkg/controller/integrationkit/build.go
+++ b/pkg/controller/integrationkit/build.go
@@ -21,10 +21,10 @@ import (
 	"context"
 	"fmt"
 
+	"github.com/apache/camel-k/pkg/util/kubernetes"
+
 	k8serrors "k8s.io/apimachinery/pkg/api/errors"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-	"k8s.io/apimachinery/pkg/types"
-
 	k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
 	"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
 
@@ -64,8 +64,7 @@ func (action *buildAction) Handle(ctx context.Context, kit *v1alpha1.Integration
 }
 
 func (action *buildAction) handleBuildSubmitted(ctx context.Context, kit *v1alpha1.IntegrationKit) error {
-	build := &v1alpha1.Build{}
-	err := action.client.Get(ctx, types.NamespacedName{Namespace: kit.Namespace, Name: kit.Name}, build)
+	build, err := kubernetes.GetBuild(ctx, action.client, kit.Name, kit.Namespace)
 	if err != nil && !k8serrors.IsNotFound(err) {
 		return err
 	}
@@ -133,8 +132,7 @@ func (action *buildAction) handleBuildSubmitted(ctx context.Context, kit *v1alph
 }
 
 func (action *buildAction) handleBuildRunning(ctx context.Context, kit *v1alpha1.IntegrationKit) error {
-	build := &v1alpha1.Build{}
-	err := action.client.Get(ctx, types.NamespacedName{Namespace: kit.Namespace, Name: kit.Name}, build)
+	build, err := kubernetes.GetBuild(ctx, action.client, kit.Name, kit.Namespace)
 	if err != nil {
 		return err
 	}
diff --git a/pkg/util/kubernetes/util.go b/pkg/util/kubernetes/util.go
index 1545497..b55b56d 100644
--- a/pkg/util/kubernetes/util.go
+++ b/pkg/util/kubernetes/util.go
@@ -151,6 +151,22 @@ func GetIntegration(context context.Context, client client.Client, name string,
 	return &answer, nil
 }
 
+// GetBuild --
+func GetBuild(context context.Context, client client.Client, name string, namespace string) (*v1alpha1.Build, error) {
+	key := k8sclient.ObjectKey{
+		Name:      name,
+		Namespace: namespace,
+	}
+
+	answer := v1alpha1.NewBuild(namespace, name)
+
+	if err := client.Get(context, key, &answer); err != nil {
+		return nil, err
+	}
+
+	return &answer, nil
+}
+
 // GetService --
 func GetService(context context.Context, client client.Client, name string, namespace string) (*corev1.Service, error) {
 	key := k8sclient.ObjectKey{