Skip to content

Commit

Permalink
Replace corev1.Handler by corev1.LifecycleHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
thbkrkr committed Dec 15, 2021
1 parent 6b4564d commit 6dd2b16
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pkg/controller/common/container/defaulter.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (d Defaulter) WithVolumeMounts(volumeMounts []corev1.VolumeMount) Defaulter
return d
}

func (d Defaulter) WithPreStopHook(handler *corev1.Handler) Defaulter {
func (d Defaulter) WithPreStopHook(handler *corev1.LifecycleHandler) Defaulter {
if d.base.Lifecycle == nil {
d.base.Lifecycle = &corev1.Lifecycle{}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/common/defaults/pod_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ func (b *PodTemplateBuilder) WithResources(resources corev1.ResourceRequirements
return b
}

func (b *PodTemplateBuilder) WithPreStopHook(handler corev1.Handler) *PodTemplateBuilder {
func (b *PodTemplateBuilder) WithPreStopHook(handler corev1.LifecycleHandler) *PodTemplateBuilder {
b.containerDefaulter.WithPreStopHook(&handler)
return b
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/controller/common/defaults/pod_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1102,14 +1102,14 @@ func TestPodTemplateBuilder_WithDefaultResources(t *testing.T) {

func TestPodTemplateBuilder_WithPreStopHook(t *testing.T) {
containerName := "mycontainer"
defaultHook := corev1.Handler{Exec: &corev1.ExecAction{Command: []string{"default", "command"}}}
userHook := &corev1.Handler{}
defaultHook := corev1.LifecycleHandler{Exec: &corev1.ExecAction{Command: []string{"default", "command"}}}
userHook := &corev1.LifecycleHandler{}
tests := []struct {
name string
podTemplate corev1.PodTemplateSpec
preStopHook corev1.Handler
wantPreStop corev1.Handler
wantPostStart *corev1.Handler
preStopHook corev1.LifecycleHandler
wantPreStop corev1.LifecycleHandler
wantPostStart *corev1.LifecycleHandler
}{
{
name: "no pre stop hook in pod template: use default one",
Expand Down Expand Up @@ -1160,7 +1160,7 @@ func TestPodTemplateBuilder_WithPreStopHook(t *testing.T) {
{
Name: containerName,
Lifecycle: &corev1.Lifecycle{
PostStart: &corev1.Handler{},
PostStart: &corev1.LifecycleHandler{},
PreStop: userHook,
},
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/elasticsearch/nodespec/lifecycle_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/volume"
)

func NewPreStopHook() *v1.Handler {
return &v1.Handler{
func NewPreStopHook() *v1.LifecycleHandler {
return &v1.LifecycleHandler{
Exec: &v1.ExecAction{
Command: []string{"bash", "-c", path.Join(volume.ScriptsVolumeMountPath, PreStopHookScriptConfigKey)}},
}
Expand Down

0 comments on commit 6dd2b16

Please sign in to comment.