-
Notifications
You must be signed in to change notification settings - Fork 350
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
Refactor kaniko settings #3032
Refactor kaniko settings #3032
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should get rid of IsKanikoCacheEnabled()
so we can really have no reference to any implementation detail. If you need to check if cache is enabled, you may just check the new map property.
You should format also running gofmt
to have the changes formatted properly
pkg/platform/defaults.go
Outdated
@@ -169,8 +170,11 @@ func setPlatformDefaults(p *v1.IntegrationPlatform, verbose bool) error { | |||
"-Dstyle.color=never", | |||
} | |||
} | |||
if p.Status.Build.PersistentVolumeClaim == "" { | |||
p.Status.Build.PersistentVolumeClaim = p.Name | |||
//if p.Status.Build.PersistentVolumeClaim == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove those comments to keep the source code more readable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok but I think that now with the map in place we have to have some additional logic to check if the key is present and then parsing the value. In this case IsKanikoCacheEnabled()
helps because we don't need to do it everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can generalize that with IsOptionEnabled(key string) bool
? the main goal is to hide any implementation detail from the API definition.
153f805
to
b889082
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few little improvements, but for the rest looks okay, thanks!
if b.KanikoBuildCache == nil { | ||
// Cache is disabled by default | ||
return false | ||
// IsOptionEnabled tells if the KanikoCache is enabled on the integration platform build spec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still reference to Kaniko. As it now is a general purpose we should change the comment as well
@@ -70,7 +70,11 @@ func (action *initializeAction) Handle(ctx context.Context, platform *v1.Integra | |||
} | |||
|
|||
if platform.Status.Build.PublishStrategy == v1.IntegrationPlatformBuildPublishStrategyKaniko { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can comment this block with // nolint: staticcheck
to avoid lint complains (due to the deprecation)
@@ -40,6 +40,11 @@ func createKanikoCacheWarmerPod(ctx context.Context, client client.Client, platf | |||
// See: | |||
// - https://kubernetes.io/docs/concepts/storage/persistent-volumes/#node-affinity | |||
// - https://kubernetes.io/docs/concepts/storage/volumes/#local | |||
pvcName := platform.Status.Build.PersistentVolumeClaim |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nolint comments as above
pkg/platform/defaults.go
Outdated
@@ -169,8 +173,8 @@ func setPlatformDefaults(p *v1.IntegrationPlatform, verbose bool) error { | |||
"-Dstyle.color=never", | |||
} | |||
} | |||
if p.Status.Build.PersistentVolumeClaim == "" { | |||
p.Status.Build.PersistentVolumeClaim = p.Name | |||
if _, ok := p.Status.Build.PublishStrategyOptions["persistentVolumeClaim"]; !ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not better use builder.KanikoPVCName
constant?
@@ -189,15 +193,15 @@ func setPlatformDefaults(p *v1.IntegrationPlatform, verbose bool) error { | |||
Duration: 5 * time.Minute, | |||
} | |||
} | |||
|
|||
if p.Status.Build.PublishStrategy == v1.IntegrationPlatformBuildPublishStrategyKaniko && p.Status.Build.KanikoBuildCache == nil { | |||
_, cacheEnabled := p.Status.Build.PublishStrategyOptions["KanikoBuildCache"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not better use builder.KanikoBuildCacheEnabled
constant?
@@ -113,6 +113,18 @@ func (t *builderTrait) Apply(e *Environment) error { | |||
}}) | |||
|
|||
case v1.IntegrationPlatformBuildPublishStrategyKaniko: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nolint here
@squakez thanks for your feedback! I updated the PR accordingly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
Refactor kaniko settings by moving existing fields into map[string] field.
fix #3005
Release Note