You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2019/02/19 11:30:36 UTC

[camel-k] branch master updated: fix(publisher): fix catalog handling

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

lburgazzoli 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 32c9603  fix(publisher): fix catalog handling
32c9603 is described below

commit 32c9603dfdeb66065082ddb24666452045197adc
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Tue Feb 19 12:30:24 2019 +0100

    fix(publisher): fix catalog handling
---
 cmd/util/publisher/publisher.go | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/cmd/util/publisher/publisher.go b/cmd/util/publisher/publisher.go
index 9a3216a..2cf5d70 100644
--- a/cmd/util/publisher/publisher.go
+++ b/cmd/util/publisher/publisher.go
@@ -19,6 +19,7 @@ package main
 
 import (
 	"fmt"
+	"github.com/apache/camel-k/pkg/util/camel"
 	"io/ioutil"
 	"os"
 	"os/exec"
@@ -30,13 +31,11 @@ import (
 
 	"github.com/apache/camel-k/pkg/util/test"
 
-	"github.com/apache/camel-k/deploy"
 	"github.com/apache/camel-k/pkg/apis"
 	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
 	"github.com/apache/camel-k/pkg/builder"
 	"github.com/apache/camel-k/pkg/platform/images"
 	"github.com/apache/camel-k/pkg/util/cancellable"
-	"github.com/apache/camel-k/pkg/util/kubernetes"
 	"github.com/pkg/errors"
 	"github.com/spf13/cobra"
 	clientscheme "k8s.io/client-go/kubernetes/scheme"
@@ -70,11 +69,6 @@ func (options *PublisherOptions) run(_ *cobra.Command, _ []string) {
 	scheme := clientscheme.Scheme
 	panicIfErr(apis.AddToScheme(scheme))
 
-	platRun, err := kubernetes.LoadResourceFromYaml(scheme, deploy.Resources["platform-cr.yaml"])
-	panicIfErr(err)
-
-	p := platRun.(*v1alpha1.IntegrationPlatform)
-
 	started := options.StartWith == ""
 
 	catalog, err := test.DefaultCatalog()
@@ -99,7 +93,7 @@ func (options *PublisherOptions) run(_ *cobra.Command, _ []string) {
 
 			if started {
 				fmt.Printf("building component %s\n", component)
-				options.buildWithAttempts(component, p.Spec.Build.CamelVersion)
+				options.buildWithAttempts(component, catalog)
 			} else {
 				fmt.Printf("skipping component %s\n", component)
 			}
@@ -112,10 +106,10 @@ func (options *PublisherOptions) run(_ *cobra.Command, _ []string) {
 	}
 }
 
-func (options *PublisherOptions) buildWithAttempts(component string, camelVersion string) {
+func (options *PublisherOptions) buildWithAttempts(component string, catalog *camel.RuntimeCatalog) {
 	var err error
 	for i := 0; i < options.BuildAttempts; i++ {
-		err = options.build(component, camelVersion)
+		err = options.build(component, catalog)
 		if err != nil {
 			sleepTime := 5 * (i + 1)
 			fmt.Printf("waiting %d seconds to recover from error %v\n", sleepTime, err)
@@ -127,7 +121,7 @@ func (options *PublisherOptions) buildWithAttempts(component string, camelVersio
 	panicIfErr(errors.Wrap(err, "build failed after maximum number of attempts"))
 }
 
-func (options *PublisherOptions) build(component string, camelVersion string) error {
+func (options *PublisherOptions) build(component string, catalog *camel.RuntimeCatalog) error {
 	dir, err := ioutil.TempDir(os.TempDir(), "camel-k-build-")
 	if err != nil {
 		return err
@@ -141,19 +135,16 @@ func (options *PublisherOptions) build(component string, camelVersion string) er
 	dependencies = append(dependencies, images.BaseDependency)
 	dependencies = append(dependencies, "camel:"+component)
 
-	catalog, err := test.DefaultCatalog()
-	if err != nil {
-		return err
-	}
 
 	ctx := builder.Context{
+		Catalog: catalog,
 		Path: dir,
 		Request: builder.Request{
 			C:       cancellable.NewContext(),
 			Catalog: catalog,
 			Platform: v1alpha1.IntegrationPlatformSpec{
 				Build: v1alpha1.IntegrationPlatformBuildSpec{
-					CamelVersion: camelVersion,
+					CamelVersion: catalog.Version,
 				},
 			},
 			Dependencies: dependencies,