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

chore: cleanup build #771

Merged
merged 1 commit into from
Jun 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions pkg/apis/camel/v1alpha1/build_types_support.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
10 changes: 4 additions & 6 deletions pkg/controller/integrationkit/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
16 changes: 16 additions & 0 deletions pkg/util/kubernetes/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down