Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
Default number of seeds to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
kragniz committed Feb 27, 2018
1 parent c7d6d0a commit 5d712ff
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/apis/navigator/validation/cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ func ValidateCassandraClusterNodePool(np *navigator.CassandraClusterNodePool, fl
)
}

if np.Seeds < 0 {
allErrs = append(allErrs,
field.Invalid(fldPath.Child("seeds"), np.Seeds, "number of seeds must be 1 or greater"),
)
}

return allErrs
}

Expand Down
13 changes: 13 additions & 0 deletions pkg/registry/navigator/cassandracluster/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,23 @@ func (cassandraClusterStrategy) NamespaceScoped() bool {
return true
}

func defaultSeeds(new *navigator.CassandraCluster) {
// default to 1 seed if not specified
for i := 0; i < len(new.Spec.NodePools); i++ {
if new.Spec.NodePools[i].Seeds == 0 {
new.Spec.NodePools[i].Seeds = 1
}
}
}

func (cassandraClusterStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) {
new := obj.(*navigator.CassandraCluster)
defaultSeeds(new)
}

func (cassandraClusterStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) {
new := obj.(*navigator.CassandraCluster)
defaultSeeds(new)
}

func (cassandraClusterStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList {
Expand Down

0 comments on commit 5d712ff

Please sign in to comment.