Simplify annotations
This commit is contained in:
parent
1a92159fa4
commit
f055022e58
51 changed files with 195 additions and 175 deletions
|
|
@ -92,27 +92,27 @@ func (c1 *Config) Equal(c2 *Config) bool {
|
|||
// Parse parses the annotations contained in the ingress
|
||||
// rule used to indicate if the location/s should allows CORS
|
||||
func (c cors) Parse(ing *extensions.Ingress) (interface{}, error) {
|
||||
corsenabled, err := parser.GetBoolAnnotation("enable-cors", ing, c.r)
|
||||
corsenabled, err := parser.GetBoolAnnotation("enable-cors", ing)
|
||||
if err != nil {
|
||||
corsenabled = false
|
||||
}
|
||||
|
||||
corsalloworigin, err := parser.GetStringAnnotation("cors-allow-origin", ing, c.r)
|
||||
corsalloworigin, err := parser.GetStringAnnotation("cors-allow-origin", ing)
|
||||
if err != nil || corsalloworigin == "" || !corsOriginRegex.MatchString(corsalloworigin) {
|
||||
corsalloworigin = "*"
|
||||
}
|
||||
|
||||
corsallowheaders, err := parser.GetStringAnnotation("cors-allow-headers", ing, c.r)
|
||||
corsallowheaders, err := parser.GetStringAnnotation("cors-allow-headers", ing)
|
||||
if err != nil || corsallowheaders == "" || !corsHeadersRegex.MatchString(corsallowheaders) {
|
||||
corsallowheaders = defaultCorsHeaders
|
||||
}
|
||||
|
||||
corsallowmethods, err := parser.GetStringAnnotation("cors-allow-methods", ing, c.r)
|
||||
corsallowmethods, err := parser.GetStringAnnotation("cors-allow-methods", ing)
|
||||
if err != nil || corsallowmethods == "" || !corsMethodsRegex.MatchString(corsallowmethods) {
|
||||
corsallowmethods = defaultCorsMethods
|
||||
}
|
||||
|
||||
corsallowcredentials, err := parser.GetBoolAnnotation("cors-allow-credentials", ing, c.r)
|
||||
corsallowcredentials, err := parser.GetBoolAnnotation("cors-allow-credentials", ing)
|
||||
if err != nil {
|
||||
corsallowcredentials = true
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue