2019-03-14 14:56:06 +00:00
|
|
|
package ingress
|
|
|
|
|
2023-04-03 08:06:06 +00:00
|
|
|
import netv1 "k8s.io/api/networking/v1"
|
2019-03-14 14:56:06 +00:00
|
|
|
|
2023-04-03 08:06:06 +00:00
|
|
|
func buildIngress(opts ...func(*netv1.Ingress)) *netv1.Ingress {
|
|
|
|
i := &netv1.Ingress{}
|
2019-03-14 14:56:06 +00:00
|
|
|
i.Kind = "Ingress"
|
|
|
|
for _, opt := range opts {
|
|
|
|
opt(i)
|
|
|
|
}
|
|
|
|
return i
|
|
|
|
}
|
|
|
|
|
2023-04-03 08:06:06 +00:00
|
|
|
func iNamespace(value string) func(*netv1.Ingress) {
|
|
|
|
return func(i *netv1.Ingress) {
|
2019-03-14 14:56:06 +00:00
|
|
|
i.Namespace = value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-03 08:06:06 +00:00
|
|
|
func iRules(opts ...func(*netv1.IngressSpec)) func(*netv1.Ingress) {
|
|
|
|
return func(i *netv1.Ingress) {
|
|
|
|
s := &netv1.IngressSpec{}
|
2019-03-14 14:56:06 +00:00
|
|
|
for _, opt := range opts {
|
|
|
|
opt(s)
|
|
|
|
}
|
|
|
|
i.Spec = *s
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-03 08:06:06 +00:00
|
|
|
func iRule(opts ...func(*netv1.IngressRule)) func(*netv1.IngressSpec) {
|
|
|
|
return func(spec *netv1.IngressSpec) {
|
|
|
|
r := &netv1.IngressRule{}
|
2019-03-14 14:56:06 +00:00
|
|
|
for _, opt := range opts {
|
|
|
|
opt(r)
|
|
|
|
}
|
|
|
|
spec.Rules = append(spec.Rules, *r)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-03 08:06:06 +00:00
|
|
|
func iHost(name string) func(*netv1.IngressRule) {
|
|
|
|
return func(rule *netv1.IngressRule) {
|
2019-03-14 14:56:06 +00:00
|
|
|
rule.Host = name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-03 08:06:06 +00:00
|
|
|
func iTLSes(opts ...func(*netv1.IngressTLS)) func(*netv1.Ingress) {
|
|
|
|
return func(i *netv1.Ingress) {
|
2019-03-14 14:56:06 +00:00
|
|
|
for _, opt := range opts {
|
2023-04-03 08:06:06 +00:00
|
|
|
iTLS := netv1.IngressTLS{}
|
2019-03-14 14:56:06 +00:00
|
|
|
opt(&iTLS)
|
|
|
|
i.Spec.TLS = append(i.Spec.TLS, iTLS)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-03 08:06:06 +00:00
|
|
|
func iTLS(secret string, hosts ...string) func(*netv1.IngressTLS) {
|
|
|
|
return func(i *netv1.IngressTLS) {
|
2019-03-14 14:56:06 +00:00
|
|
|
i.SecretName = secret
|
|
|
|
i.Hosts = hosts
|
|
|
|
}
|
|
|
|
}
|