Skip to content

Commit

Permalink
Merge pull request #580 from dprince/core_validation_fix
Browse files Browse the repository at this point in the history
Move memcached defaulting into *Core* Default()
  • Loading branch information
dprince authored Jan 11, 2025
2 parents dd114b9 + b5ccb36 commit 43b3bac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 9 additions & 2 deletions api/v1beta1/autoscaling_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1beta1

import (
"fmt"

"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
Expand Down Expand Up @@ -60,6 +61,7 @@ func (r *Autoscaling) Default() {
autoscalinglog.Info("default", "name", r.Name)

r.Spec.Default()
r.Spec.Aodh.AodhCore.Default()
}

// Default - set defaults for this Autoscaling spec
Expand All @@ -76,8 +78,13 @@ func (spec *AutoscalingSpec) Default() {
if spec.Aodh.ListenerImage == "" {
spec.Aodh.ListenerImage = autoscalingDefaults.AodhListenerContainerImageURL
}
if spec.Aodh.MemcachedInstance == "" {
spec.Aodh.MemcachedInstance = "memcached"
}

// Default - note only *Core* versions like this will have validations that are called from the
// Controlplane webhook
func (spec *AodhCore) Default() {
if spec.MemcachedInstance == "" {
spec.MemcachedInstance = "memcached"
}
}

Expand Down
6 changes: 2 additions & 4 deletions api/v1beta1/telemetry_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,12 @@ func (spec *TelemetrySpec) Default() {
if spec.Autoscaling.AutoscalingSpec.Aodh.ListenerImage == "" {
spec.Autoscaling.AutoscalingSpec.Aodh.ListenerImage = telemetryDefaults.AodhListenerContainerImageURL
}
if spec.Autoscaling.AutoscalingSpec.Aodh.MemcachedInstance == "" {
spec.Autoscaling.AutoscalingSpec.Aodh.MemcachedInstance = "memcached"
}
}

// Default - set defaults for this Telemetry spec core
// NOTE: only this version gets called by the Controlplane Webhook
func (spec *TelemetrySpecCore) Default() {
// nothing here yet
spec.Autoscaling.Aodh.Default()
}

// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
Expand Down

0 comments on commit 43b3bac

Please sign in to comment.