-
Notifications
You must be signed in to change notification settings - Fork 591
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(admission): validate path with regex supplied in Ingress (#4647)
- Loading branch information
1 parent
896edff
commit 832a7aa
Showing
11 changed files
with
477 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package builder | ||
|
||
import ( | ||
netv1 "k8s.io/api/networking/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
"github.com/kong/kubernetes-ingress-controller/v2/internal/annotations" | ||
) | ||
|
||
type IngressBuilder struct { | ||
ingress netv1.Ingress | ||
} | ||
|
||
// NewIngress builds an Ingress object with the given name and class, when "" is passed as class parameter | ||
// the field .Spec.IngressClassName is not set. | ||
func NewIngress(name string, class string) *IngressBuilder { | ||
var classToSet *string | ||
if class != "" { | ||
classToSet = &class | ||
} | ||
return &IngressBuilder{ | ||
ingress: netv1.Ingress{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: name, | ||
Annotations: make(map[string]string), | ||
}, | ||
Spec: netv1.IngressSpec{ | ||
IngressClassName: classToSet, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func (b *IngressBuilder) Build() *netv1.Ingress { | ||
return &b.ingress | ||
} | ||
|
||
func (b *IngressBuilder) WithLegacyClassAnnotation(class string) *IngressBuilder { | ||
b.ingress.Annotations[annotations.IngressClassKey] = class | ||
return b | ||
} | ||
|
||
func (b *IngressBuilder) WithRules(rules ...netv1.IngressRule) *IngressBuilder { | ||
b.ingress.Spec.Rules = append(b.ingress.Spec.Rules, rules...) | ||
return b | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.