@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
14
14
limitations under the License.
15
15
*/
16
16
17
- package clientbodybuffersize
17
+ package client
18
18
19
19
import (
20
20
networking "k8s.io/api/networking/v1"
@@ -27,7 +27,7 @@ const (
27
27
clientBodyBufferSizeAnnotation = "client-body-buffer-size"
28
28
)
29
29
30
- var clientBodyBufferSizeConfig = parser.Annotation {
30
+ var clientAnnotations = parser.Annotation {
31
31
Group : "backend" ,
32
32
Annotations : parser.AnnotationFields {
33
33
clientBodyBufferSizeAnnotation : {
@@ -42,30 +42,54 @@ var clientBodyBufferSizeConfig = parser.Annotation{
42
42
},
43
43
}
44
44
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 {
46
65
r resolver.Resolver
47
66
annotationConfig parser.Annotation
48
67
}
49
68
50
- // NewParser creates a new clientBodyBufferSize annotation parser
69
+ // NewParser creates a new client annotation parser
51
70
func NewParser (r resolver.Resolver ) parser.IngressAnnotation {
52
- return clientBodyBufferSize {
71
+ return client {
53
72
r : r ,
54
- annotationConfig : clientBodyBufferSizeConfig ,
73
+ annotationConfig : clientAnnotations ,
55
74
}
56
75
}
57
76
58
- func (cbbs clientBodyBufferSize ) GetDocumentation () parser.AnnotationFields {
59
- return cbbs .annotationConfig .Annotations
77
+ func (c client ) GetDocumentation () parser.AnnotationFields {
78
+ return c .annotationConfig .Annotations
60
79
}
61
80
62
81
// 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
66
90
}
67
91
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 )
71
95
}
0 commit comments