Skip to content

Commit

Permalink
Merge pull request #51 from kuidio/syntaxerror
Browse files Browse the repository at this point in the history
updated syntax errors
  • Loading branch information
henderiw authored Nov 25, 2024
2 parents 139cae6 + 39f395e commit e0da2e1
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 e0da2e1

Please sign in to comment.