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

astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 0ae900eae665efe77f8f6ecd8474ec571266da30
Author: asifdxtreme <mohammad.asif.siddiq...@huawei.com>
AuthorDate: Mon Sep 30 11:40:03 2019 +0530

    Make KanikoBuildCache *Bool
---
 pkg/apis/camel/v1alpha1/integrationplatform_types.go | 2 +-
 pkg/builder/kaniko/publisher.go                      | 2 +-
 pkg/cmd/install.go                                   | 6 ++++--
 pkg/controller/integrationplatform/initialize.go     | 9 ++++++++-
 4 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/pkg/apis/camel/v1alpha1/integrationplatform_types.go 
b/pkg/apis/camel/v1alpha1/integrationplatform_types.go
index 5c4674d..3c6d5c9 100644
--- a/pkg/apis/camel/v1alpha1/integrationplatform_types.go
+++ b/pkg/apis/camel/v1alpha1/integrationplatform_types.go
@@ -105,7 +105,7 @@ type IntegrationPlatformBuildSpec struct {
        PersistentVolumeClaim string                                  
`json:"persistentVolumeClaim,omitempty"`
        Maven                 MavenSpec                               
`json:"maven,omitempty"`
        HTTPProxySecret       string                                  
`json:"httpProxySecret,omitempty"`
-       KanikoBuildCache      bool                                    
`json:"kanikoBuildCache,omitempty"`
+       KanikoBuildCache      *bool                                   
`json:"kanikoBuildCache,omitempty"`
 }
 
 // IntegrationPlatformRegistrySpec --
diff --git a/pkg/builder/kaniko/publisher.go b/pkg/builder/kaniko/publisher.go
index 82b7fce..488fe6d 100644
--- a/pkg/builder/kaniko/publisher.go
+++ b/pkg/builder/kaniko/publisher.go
@@ -80,7 +80,7 @@ func publisher(ctx *builder.Context) error {
                "--dockerfile=Dockerfile",
                "--context=" + contextDir,
                "--destination=" + image,
-               "--cache=" + 
strconv.FormatBool(ctx.Build.Platform.Build.KanikoBuildCache),
+               "--cache=" + 
strconv.FormatBool(*ctx.Build.Platform.Build.KanikoBuildCache),
                "--cache-dir=/workspace/cache",
        }
 
diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go
index 162c211..65f65c3 100644
--- a/pkg/cmd/install.go
+++ b/pkg/cmd/install.go
@@ -239,10 +239,12 @@ func (o *installCmdOptions) install(cobraCmd 
*cobra.Command, _ []string) error {
 
                kanikoBuildCacheFlag := 
cobraCmd.Flags().Lookup("kaniko-build-cache")
 
+               defaultKanikoBuildCache := true
+
                if kanikoBuildCacheFlag.Changed {
-                       platform.Spec.Build.KanikoBuildCache = 
o.kanikoBuildCache
+                       platform.Spec.Build.KanikoBuildCache = 
&o.kanikoBuildCache
                } else {
-                       platform.Spec.Build.KanikoBuildCache = true
+                       platform.Spec.Build.KanikoBuildCache = 
&defaultKanikoBuildCache
                }
 
                platform.Spec.Resources.Kits = o.kits
diff --git a/pkg/controller/integrationplatform/initialize.go 
b/pkg/controller/integrationplatform/initialize.go
index 1a270db..a331027 100644
--- a/pkg/controller/integrationplatform/initialize.go
+++ b/pkg/controller/integrationplatform/initialize.go
@@ -136,8 +136,15 @@ func (action *initializeAction) Handle(ctx 
context.Context, platform *v1alpha1.I
                        return nil, err
                }
 
+               defaultKanikoBuildCache := true
+               // Check if the KanikoBuildCache has been initialized
+               if platform.Spec.Build.KanikoBuildCache == nil {
+                       //if not initialized then default it to true
+                       platform.Spec.Build.KanikoBuildCache = 
&defaultKanikoBuildCache
+               }
+
                // Check if the operator is running in the same namespace 
before starting the cache warmer
-               if platform.Namespace == platformutil.GetOperatorNamespace() && 
platform.Spec.Build.KanikoBuildCache {
+               if platform.Namespace == platformutil.GetOperatorNamespace() && 
*platform.Spec.Build.KanikoBuildCache {
                        // Create the Kaniko warmer pod that caches the base 
image into the Camel K builder volume
                        action.L.Info("Create Kaniko cache warmer pod")
                        err = createKanikoCacheWarmerPod(ctx, action.client, 
platform)

Reply via email to