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

fix: Kaniko cache default spec is not updated when calling the status endpoint #975

Merged
merged 1 commit into from
Oct 1, 2019
Merged
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
23 changes: 11 additions & 12 deletions pkg/controller/integrationplatform/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ func (action *initializeAction) CanHandle(platform *v1alpha1.IntegrationPlatform
}

func (action *initializeAction) Handle(ctx context.Context, platform *v1alpha1.IntegrationPlatform) (*v1alpha1.IntegrationPlatform, error) {

duplicate, err := action.isDuplicate(ctx, platform)
if err != nil {
return nil, err
Expand Down Expand Up @@ -109,15 +108,15 @@ func (action *initializeAction) Handle(ctx context.Context, platform *v1alpha1.I
}
}

if platform.Spec.Build.PublishStrategy == v1alpha1.IntegrationPlatformBuildPublishStrategyKaniko && platform.Spec.Build.Registry.Address == "" {
action.L.Info("No registry specified for publishing images")
}

err = action.setDefaults(ctx, platform)
if err != nil {
return nil, err
}

if platform.Spec.Build.PublishStrategy == v1alpha1.IntegrationPlatformBuildPublishStrategyKaniko && platform.Spec.Build.Registry.Address == "" {
action.L.Info("No registry specified for publishing images")
}

if platform.Spec.Build.Maven.Timeout.Duration != 0 {
action.L.Infof("Maven Timeout set to %s", platform.Spec.Build.Maven.Timeout.Duration)
}
Expand All @@ -136,13 +135,6 @@ 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 {
// Create the Kaniko warmer pod that caches the base image into the Camel K builder volume
Expand Down Expand Up @@ -255,6 +247,13 @@ func (action *initializeAction) setDefaults(ctx context.Context, platform *v1alp
}
}

if platform.Spec.Build.PublishStrategy == v1alpha1.IntegrationPlatformBuildPublishStrategyKaniko && platform.Spec.Build.KanikoBuildCache == nil {
// Default to using Kaniko cache warmer
defaultKanikoBuildCache := true
platform.Spec.Build.KanikoBuildCache = &defaultKanikoBuildCache
action.L.Infof("Kaniko cache set to %t", *platform.Spec.Build.KanikoBuildCache)
}

action.L.Infof("CamelVersion set to %s", platform.Spec.Build.CamelVersion)
action.L.Infof("RuntimeVersion set to %s", platform.Spec.Build.RuntimeVersion)
action.L.Infof("BaseImage set to %s", platform.Spec.Build.BaseImage)
Expand Down