@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
1616
17- package clientbodybuffersize
17+ package client
1818
1919import (
2020 networking "k8s.io/api/networking/v1"
@@ -27,7 +27,7 @@ const (
2727 clientBodyBufferSizeAnnotation = "client-body-buffer-size"
2828)
2929
30- var clientBodyBufferSizeConfig = parser.Annotation {
30+ var clientAnnotations = parser.Annotation {
3131 Group : "backend" ,
3232 Annotations : parser.AnnotationFields {
3333 clientBodyBufferSizeAnnotation : {
@@ -42,30 +42,54 @@ var clientBodyBufferSizeConfig = parser.Annotation{
4242 },
4343}
4444
45- type clientBodyBufferSize struct {
45+ type Config struct {
46+ BodyBufferSize string `json:"bodyBufferSize"`
47+ }
48+
49+ // Equal tests for equality between two Configuration types
50+ func (l1 * Config ) Equal (l2 * Config ) bool {
51+ if l1 == l2 {
52+ return true
53+ }
54+ if l1 == nil || l2 == nil {
55+ return false
56+ }
57+ if l1 .BodyBufferSize != l2 .BodyBufferSize {
58+ return false
59+ }
60+
61+ return true
62+ }
63+
64+ type client struct {
4665 r resolver.Resolver
4766 annotationConfig parser.Annotation
4867}
4968
50- // NewParser creates a new clientBodyBufferSize annotation parser
69+ // NewParser creates a new client annotation parser
5170func NewParser (r resolver.Resolver ) parser.IngressAnnotation {
52- return clientBodyBufferSize {
71+ return client {
5372 r : r ,
54- annotationConfig : clientBodyBufferSizeConfig ,
73+ annotationConfig : clientAnnotations ,
5574 }
5675}
5776
58- func (cbbs clientBodyBufferSize ) GetDocumentation () parser.AnnotationFields {
59- return cbbs .annotationConfig .Annotations
77+ func (c client ) GetDocumentation () parser.AnnotationFields {
78+ return c .annotationConfig .Annotations
6079}
6180
6281// Parse parses the annotations contained in the ingress rule
63- // used to add an client-body-buffer-size to the provided locations
64- func (cbbs clientBodyBufferSize ) Parse (ing * networking.Ingress ) (interface {}, error ) {
65- return parser .GetStringAnnotation (clientBodyBufferSizeAnnotation , ing , cbbs .annotationConfig .Annotations )
82+ // used to add an client related configuration to the provided locations.
83+ func (c client ) Parse (ing * networking.Ingress ) (interface {}, error ) {
84+ config := & Config {}
85+
86+ var err error
87+ config .BodyBufferSize , err = parser .GetStringAnnotation (clientBodyBufferSizeAnnotation , ing , c .annotationConfig .Annotations )
88+
89+ return config , err
6690}
6791
68- func (cbbs clientBodyBufferSize ) Validate (anns map [string ]string ) error {
69- maxrisk := parser .StringRiskToRisk (cbbs .r .GetSecurityConfiguration ().AnnotationsRiskLevel )
70- return parser .CheckAnnotationRisk (anns , maxrisk , clientBodyBufferSizeConfig .Annotations )
92+ func (c client ) Validate (annotations map [string ]string ) error {
93+ maxRisk := parser .StringRiskToRisk (c .r .GetSecurityConfiguration ().AnnotationsRiskLevel )
94+ return parser .CheckAnnotationRisk (annotations , maxRisk , clientAnnotations .Annotations )
7195}
0 commit comments