Skip to content

Commit

Permalink
updates based on reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
salonichf5 committed Sep 5, 2024
1 parent 64547ff commit beeb01d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions apis/v1alpha1/nginxproxy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,9 @@ type RewriteClientIP struct {
// Sets NGINX directive set_real_ip_from: https://nginx.org/en/docs/http/ngx_http_realip_module.html#set_real_ip_from
// This field is required if mode is set.
// +kubebuilder:validation:MaxItems=16
// +listType=map
// +listType=map
// +listMapKey=type
//
//
// +optional
TrustedAddresses []Address `json:"trustedAddresses,omitempty"`
}
Expand Down Expand Up @@ -201,6 +200,6 @@ type AddressType string

const (
// AddressTypeCIDR specifies that the address is a CIDR block.
// kubebuilder:validation:Pattern=`^[\.a-zA-Z0-9::]*(\/([0-9]?[0-9]?[0-8]))$`
// kubebuilder:validation:Pattern=`^[\.a-zA-Z0-9:]*(\/([0-9]?[0-9]?[0-9]))$`
AddressTypeCIDR AddressType = "cidr"
)
2 changes: 1 addition & 1 deletion internal/mode/static/state/graph/nginxproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func validateRewriteClientIP(npCfg *ngfAPI.NginxProxy) field.ErrorList {
default:
allErrs = append(
allErrs,
field.NotSupported(trustedAddressesPath.Child(addr.Value),
field.NotSupported(trustedAddressesPath.Child("type"),
addr.Type,
[]string{string(ngfAPI.AddressTypeCIDR)},
),
Expand Down
2 changes: 1 addition & 1 deletion internal/mode/static/state/graph/nginxproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ func TestValidateRewriteClientIP(t *testing.T) {
},
},
expectErrCount: 1,
errorString: "spec.rewriteClientIP.trustedAddresses.2001:db8::/129: " +
errorString: "spec.rewriteClientIP.trustedAddresses.type: " +
"Unsupported value: \"invalid\": supported values: \"cidr\"",
},
}
Expand Down
2 changes: 1 addition & 1 deletion site/content/reference/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ string
</thead>
<tbody><tr><td><p>&#34;cidr&#34;</p></td>
<td><p>AddressTypeCIDR specifies that the address is a CIDR block.
kubebuilder:validation:Pattern=<code>^[\.a-zA-Z0-9::]*(\/([0-9]?[0-9]?[0-8]))$</code></p>
kubebuilder:validation:Pattern=<code>^[\.a-zA-Z0-9:]*(\/([0-9]?[0-9]?[0-9]))$</code></p>
</td>
</tr></tbody>
</table>
Expand Down

0 comments on commit beeb01d

Please sign in to comment.