Skip to content

Commit

Permalink
updated syntax errors
Browse files Browse the repository at this point in the history
  • Loading branch information
henderiw committed Nov 25, 2024
1 parent 139cae6 commit 39f395e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (r *dynamicAddressSyntaxValidator) Validate(claim *IPClaim) field.ErrorList
ipPrefixType := claim.GetIPPrefixType()
if ipPrefixType == IPPrefixType_Invalid {
allErrs = append(allErrs, field.Invalid(
field.NewPath("spec.type"),
field.NewPath("spec.prefixType"),
claim,
fmt.Errorf("%s, invalid claim type, got %s", r.name, string(ipPrefixType)).Error(),
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (r *dynamicPrefixSyntaxValidator) Validate(claim *IPClaim) field.ErrorList
ipPrefixType := claim.GetIPPrefixType()
if ipPrefixType == IPPrefixType_Invalid {
allErrs = append(allErrs, field.Invalid(
field.NewPath("spec.type"),
field.NewPath("spec.prefixType"),
claim,
fmt.Errorf("%s, invalid claim type, got %s", r.name, string(ipPrefixType)).Error(),
))
Expand Down
6 changes: 3 additions & 3 deletions apis/backend/ipam/ipclaim_syntaxvalidator_static_prefix.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (r *staticPrefixSyntaxValidator) Validate(claim *IPClaim) field.ErrorList {
ipPrefixType := claim.GetIPPrefixType()
if ipPrefixType == IPPrefixType_Invalid {
allErrs = append(allErrs, field.Invalid(
field.NewPath("spec.type"),
field.NewPath("spec.prefixType"),
claim,
fmt.Errorf("%s, invalid claim type, got %s", r.name, string(ipPrefixType)).Error(),
))
Expand All @@ -80,14 +80,14 @@ func (r *staticPrefixSyntaxValidator) Validate(claim *IPClaim) field.ErrorList {
if claim.Spec.DefaultGateway != nil {
if ipPrefixType != IPPrefixType_Network {
allErrs = append(allErrs, field.Invalid(
field.NewPath("spec.type"),
field.NewPath("spec.defaultGateway"),
claim,
fmt.Errorf("%s cannot have a defaultGateway on a prefix which is not a network type", r.name).Error(),
))
}
if !pi.IsNorLastNorFirst() {
allErrs = append(allErrs, field.Invalid(
field.NewPath("spec.prefix"),
field.NewPath("spec.defaultGateway"),
claim,
fmt.Errorf("%s cannot have a defaultGateway on a prefix which is the first or last ip in the prefix", r.name).Error(),
))
Expand Down
2 changes: 1 addition & 1 deletion apis/backend/ipam/ipclaim_syntaxvalidator_static_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (r *staticRangeSyntaxValidator) Validate(claim *IPClaim) field.ErrorList {
ipPrefixType := claim.GetIPPrefixType()
if ipPrefixType != IPPrefixType_Regular {
allErrs = append(allErrs, field.Invalid(
field.NewPath("spec.type"),
field.NewPath("spec.prefixType"),
claim,
fmt.Errorf("%s invalid claim, expecting %s, got %s", r.name, string(IPPrefixType_Regular), string(ipPrefixType)).Error(),
))
Expand Down
9 changes: 9 additions & 0 deletions examples/ipam/index-vpc3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: ipam.be.kuid.dev/v1alpha1
kind: IPIndex
metadata:
name: vpc3
namespace: default
spec:
prefixes:
- prefix: 10.0.0.0/8
prefixType: network

0 comments on commit 39f395e

Please sign in to comment.