Skip to content

Commit 86c0350

Browse files
committed
REORG/MINOR: move haproxy rules under haproxy/rules
1 parent c7161e4 commit 86c0350

31 files changed

+130
-145
lines changed

controller/annotations/annotations.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/haproxytech/kubernetes-ingress/controller/annotations/service"
1313
"github.com/haproxytech/kubernetes-ingress/controller/haproxy"
1414
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/maps"
15+
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/rules"
1516
"github.com/haproxytech/kubernetes-ingress/controller/store"
1617
"github.com/haproxytech/kubernetes-ingress/controller/utils"
1718
)
@@ -58,7 +59,7 @@ func Defaults(d *models.Defaults) []Annotation {
5859
}
5960
}
6061

61-
func Frontend(i store.Ingress, r *haproxy.Rules, m maps.MapFiles) []Annotation {
62+
func Frontend(i store.Ingress, r *rules.Rules, m maps.MapFiles) []Annotation {
6263
reqRateLimit := ingress.NewReqRateLimit(r)
6364
httpsRedirect := ingress.NewHTTPSRedirect(r, i)
6465
hostRedirect := ingress.NewHostRedirect(r)

controller/annotations/ingress/1

Whitespace-only changes.

controller/annotations/ingress/accessControl.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"strings"
77

88
"github.com/haproxytech/kubernetes-ingress/controller/annotations/common"
9-
"github.com/haproxytech/kubernetes-ingress/controller/haproxy"
109
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/maps"
1110
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/rules"
1211
"github.com/haproxytech/kubernetes-ingress/controller/store"
@@ -15,17 +14,17 @@ import (
1514

1615
type AccessControl struct {
1716
name string
18-
rules *haproxy.Rules
17+
rules *rules.Rules
1918
maps maps.MapFiles
2019
whitelist bool
2120
}
2221

23-
func NewBlackList(n string, rules *haproxy.Rules, m maps.MapFiles) *AccessControl {
24-
return &AccessControl{name: n, rules: rules, maps: m}
22+
func NewBlackList(n string, r *rules.Rules, m maps.MapFiles) *AccessControl {
23+
return &AccessControl{name: n, rules: r, maps: m}
2524
}
2625

27-
func NewWhiteList(n string, rules *haproxy.Rules, m maps.MapFiles) *AccessControl {
28-
return &AccessControl{name: n, rules: rules, maps: m, whitelist: true}
26+
func NewWhiteList(n string, r *rules.Rules, m maps.MapFiles) *AccessControl {
27+
return &AccessControl{name: n, rules: r, maps: m, whitelist: true}
2928
}
3029

3130
func (a *AccessControl) GetName() string {

controller/annotations/ingress/basicAuth.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ import (
55
"strings"
66

77
"github.com/haproxytech/kubernetes-ingress/controller/annotations/common"
8-
"github.com/haproxytech/kubernetes-ingress/controller/haproxy"
98
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/rules"
109
"github.com/haproxytech/kubernetes-ingress/controller/store"
1110
)
1211

1312
type ReqAuth struct {
1413
authRule *rules.ReqBasicAuth
15-
rules *haproxy.Rules
14+
rules *rules.Rules
1615
ingress store.Ingress
1716
}
1817

@@ -21,8 +20,8 @@ type ReqAuthAnn struct {
2120
parent *ReqAuth
2221
}
2322

24-
func NewReqAuth(rules *haproxy.Rules, i store.Ingress) *ReqAuth {
25-
return &ReqAuth{rules: rules, ingress: i}
23+
func NewReqAuth(r *rules.Rules, i store.Ingress) *ReqAuth {
24+
return &ReqAuth{rules: r, ingress: i}
2625
}
2726

2827
func (p *ReqAuth) NewAnnotation(n string) ReqAuthAnn {

controller/annotations/ingress/hostRedirect.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,22 @@ import (
55
"strconv"
66

77
"github.com/haproxytech/kubernetes-ingress/controller/annotations/common"
8-
"github.com/haproxytech/kubernetes-ingress/controller/haproxy"
98
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/rules"
109
"github.com/haproxytech/kubernetes-ingress/controller/store"
1110
)
1211

1312
type HostRedirect struct {
1413
redirect *rules.RequestRedirect
15-
rules *haproxy.Rules
14+
rules *rules.Rules
1615
}
1716

1817
type HostRedirectAnn struct {
1918
name string
2019
parent *HostRedirect
2120
}
2221

23-
func NewHostRedirect(rules *haproxy.Rules) *HostRedirect {
24-
return &HostRedirect{rules: rules}
22+
func NewHostRedirect(r *rules.Rules) *HostRedirect {
23+
return &HostRedirect{rules: r}
2524
}
2625

2726
func (p *HostRedirect) NewAnnotation(n string) HostRedirectAnn {

controller/annotations/ingress/httpsRedirect.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ import (
55
"strconv"
66

77
"github.com/haproxytech/kubernetes-ingress/controller/annotations/common"
8-
"github.com/haproxytech/kubernetes-ingress/controller/haproxy"
98
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/rules"
109
"github.com/haproxytech/kubernetes-ingress/controller/store"
1110
"github.com/haproxytech/kubernetes-ingress/controller/utils"
1211
)
1312

1413
type HTTPSRedirect struct {
1514
redirect *rules.RequestRedirect
16-
rules *haproxy.Rules
15+
rules *rules.Rules
1716
ingress store.Ingress
1817
}
1918

@@ -22,8 +21,8 @@ type HTTPSRedirectAnn struct {
2221
parent *HTTPSRedirect
2322
}
2423

25-
func NewHTTPSRedirect(rules *haproxy.Rules, i store.Ingress) *HTTPSRedirect {
26-
return &HTTPSRedirect{rules: rules, ingress: i}
24+
func NewHTTPSRedirect(r *rules.Rules, i store.Ingress) *HTTPSRedirect {
25+
return &HTTPSRedirect{rules: r, ingress: i}
2726
}
2827

2928
func (p *HTTPSRedirect) NewAnnotation(n string) HTTPSRedirectAnn {

controller/annotations/ingress/reqCapture.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,22 @@ import (
66
"strings"
77

88
"github.com/haproxytech/kubernetes-ingress/controller/annotations/common"
9-
"github.com/haproxytech/kubernetes-ingress/controller/haproxy"
109
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/rules"
1110
"github.com/haproxytech/kubernetes-ingress/controller/store"
1211
)
1312

1413
type ReqCapture struct {
1514
capture []*rules.ReqCapture
16-
rules *haproxy.Rules
15+
rules *rules.Rules
1716
}
1817

1918
type ReqCaptureAnn struct {
2019
name string
2120
parent *ReqCapture
2221
}
2322

24-
func NewReqCapture(rules *haproxy.Rules) *ReqCapture {
25-
return &ReqCapture{rules: rules}
23+
func NewReqCapture(r *rules.Rules) *ReqCapture {
24+
return &ReqCapture{rules: r}
2625
}
2726

2827
func (p *ReqCapture) NewAnnotation(n string) ReqCaptureAnn {

controller/annotations/ingress/reqPathRewrite.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@ import (
55
"strings"
66

77
"github.com/haproxytech/kubernetes-ingress/controller/annotations/common"
8-
"github.com/haproxytech/kubernetes-ingress/controller/haproxy"
98
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/rules"
109
"github.com/haproxytech/kubernetes-ingress/controller/store"
1110
)
1211

1312
type ReqPathRewrite struct {
1413
name string
15-
rules *haproxy.Rules
14+
rules *rules.Rules
1615
}
1716

18-
func NewReqPathRewrite(n string, rules *haproxy.Rules) *ReqPathRewrite {
19-
return &ReqPathRewrite{name: n, rules: rules}
17+
func NewReqPathRewrite(n string, r *rules.Rules) *ReqPathRewrite {
18+
return &ReqPathRewrite{name: n, rules: r}
2019
}
2120

2221
func (a *ReqPathRewrite) GetName() string {

controller/annotations/ingress/reqRateLimit.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"strconv"
66

77
"github.com/haproxytech/kubernetes-ingress/controller/annotations/common"
8-
"github.com/haproxytech/kubernetes-ingress/controller/haproxy"
98
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/rules"
109
"github.com/haproxytech/kubernetes-ingress/controller/store"
1110
"github.com/haproxytech/kubernetes-ingress/controller/utils"
@@ -14,16 +13,16 @@ import (
1413
type ReqRateLimit struct {
1514
limit *rules.ReqRateLimit
1615
track *rules.ReqTrack
17-
rules *haproxy.Rules
16+
rules *rules.Rules
1817
}
1918

2019
type ReqRateLimitAnn struct {
2120
name string
2221
parent *ReqRateLimit
2322
}
2423

25-
func NewReqRateLimit(rules *haproxy.Rules) *ReqRateLimit {
26-
return &ReqRateLimit{rules: rules}
24+
func NewReqRateLimit(r *rules.Rules) *ReqRateLimit {
25+
return &ReqRateLimit{rules: r}
2726
}
2827

2928
func (p *ReqRateLimit) NewAnnotation(n string) ReqRateLimitAnn {

controller/annotations/ingress/reqSetHdr.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,22 @@ import (
55
"strings"
66

77
"github.com/haproxytech/kubernetes-ingress/controller/annotations/common"
8-
"github.com/haproxytech/kubernetes-ingress/controller/haproxy"
98
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/rules"
109
"github.com/haproxytech/kubernetes-ingress/controller/store"
1110
)
1211

1312
type SetHdr struct {
1413
name string
15-
rules *haproxy.Rules
14+
rules *rules.Rules
1615
response bool
1716
}
1817

19-
func NewReqSetHdr(n string, rules *haproxy.Rules) *SetHdr {
20-
return &SetHdr{name: n, rules: rules}
18+
func NewReqSetHdr(n string, r *rules.Rules) *SetHdr {
19+
return &SetHdr{name: n, rules: r}
2120
}
2221

23-
func NewResSetHdr(n string, rules *haproxy.Rules) *SetHdr {
24-
return &SetHdr{name: n, rules: rules, response: true}
22+
func NewResSetHdr(n string, r *rules.Rules) *SetHdr {
23+
return &SetHdr{name: n, rules: r, response: true}
2524
}
2625

2726
func (a *SetHdr) GetName() string {

controller/annotations/ingress/reqSetHost.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@ package ingress
22

33
import (
44
"github.com/haproxytech/kubernetes-ingress/controller/annotations/common"
5-
"github.com/haproxytech/kubernetes-ingress/controller/haproxy"
65
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/rules"
76
"github.com/haproxytech/kubernetes-ingress/controller/store"
87
)
98

109
type ReqSetHost struct {
1110
name string
12-
rules *haproxy.Rules
11+
rules *rules.Rules
1312
}
1413

15-
func NewReqSetHost(n string, rules *haproxy.Rules) *ReqSetHost {
16-
return &ReqSetHost{name: n, rules: rules}
14+
func NewReqSetHost(n string, r *rules.Rules) *ReqSetHost {
15+
return &ReqSetHost{name: n, rules: r}
1716
}
1817

1918
func (a *ReqSetHost) GetName() string {

controller/annotations/ingress/resSetCORS.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"strings"
66

77
"github.com/haproxytech/kubernetes-ingress/controller/annotations/common"
8-
"github.com/haproxytech/kubernetes-ingress/controller/haproxy"
98
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/rules"
109
"github.com/haproxytech/kubernetes-ingress/controller/store"
1110
"github.com/haproxytech/kubernetes-ingress/controller/utils"
@@ -14,7 +13,7 @@ import (
1413
const corsVarName = "cors-origin"
1514

1615
type ResSetCORS struct {
17-
rules *haproxy.Rules
16+
rules *rules.Rules
1817
acl string
1918
methods map[string]struct{}
2019
}
@@ -24,9 +23,9 @@ type ResSetCORSAnn struct {
2423
parent *ResSetCORS
2524
}
2625

27-
func NewResSetCORS(rules *haproxy.Rules) *ResSetCORS {
26+
func NewResSetCORS(r *rules.Rules) *ResSetCORS {
2827
return &ResSetCORS{
29-
rules: rules,
28+
rules: r,
3029
methods: map[string]struct{}{"GET": {}, "POST": {}, "PUT": {}, "DELETE": {}, "HEAD": {}, "CONNECT": {}, "OPTIONS": {}, "TRACE": {}, "PATCH": {}},
3130
}
3231
}

controller/annotations/ingress/srcIPHdr.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@ package ingress
22

33
import (
44
"github.com/haproxytech/kubernetes-ingress/controller/annotations/common"
5-
"github.com/haproxytech/kubernetes-ingress/controller/haproxy"
65
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/rules"
76
"github.com/haproxytech/kubernetes-ingress/controller/store"
87
)
98

109
type SrcIPHdr struct {
1110
name string
12-
rules *haproxy.Rules
11+
rules *rules.Rules
1312
}
1413

15-
func NewSrcIPHdr(n string, rules *haproxy.Rules) *SrcIPHdr {
16-
return &SrcIPHdr{name: n, rules: rules}
14+
func NewSrcIPHdr(n string, r *rules.Rules) *SrcIPHdr {
15+
return &SrcIPHdr{name: n, rules: r}
1716
}
1817

1918
func (a *SrcIPHdr) GetName() string {

controller/configuration/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727

2828
type ControllerCfg struct {
2929
MapFiles *maps.MapFiles
30-
HAProxyRules haproxy.SectionRules
30+
HAProxyRules *rules.SectionRules
3131
Certificates *haproxy.Certificates
3232
ActiveBackends map[string]struct{}
3333
RateLimitTables []string
@@ -80,7 +80,7 @@ func (c *ControllerCfg) Init() (err error) {
8080

8181
func (c *ControllerCfg) haproxyRulesInit() error {
8282
if c.HAProxyRules == nil {
83-
c.HAProxyRules = haproxy.NewRules()
83+
c.HAProxyRules = rules.New()
8484
} else {
8585
c.HAProxyRules.Clean(c.FrontHTTP, c.FrontHTTPS, c.FrontSSL)
8686
}

controller/haproxy/certificates.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"strings"
1010

1111
"github.com/haproxytech/kubernetes-ingress/controller/store"
12+
"github.com/haproxytech/kubernetes-ingress/controller/utils"
1213
)
1314

1415
type Certificates struct {
@@ -26,6 +27,9 @@ type cert struct {
2627

2728
type SecretType int
2829

30+
// module logger
31+
var logger = utils.GetLogger()
32+
2933
//nolint:golint,stylecheck
3034
const (
3135
NONE_CERT SecretType = iota

0 commit comments

Comments
 (0)