Skip to content

Commit 9034c1e

Browse files
committed
REORG/MINOR: move haproxy certs under haproxy/certs
1 parent 86c0350 commit 9034c1e

File tree

9 files changed

+25
-25
lines changed

9 files changed

+25
-25
lines changed

controller/annotations/annotations.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/haproxytech/kubernetes-ingress/controller/annotations/global"
1111
"github.com/haproxytech/kubernetes-ingress/controller/annotations/ingress"
1212
"github.com/haproxytech/kubernetes-ingress/controller/annotations/service"
13-
"github.com/haproxytech/kubernetes-ingress/controller/haproxy"
13+
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/certs"
1414
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/maps"
1515
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/rules"
1616
"github.com/haproxytech/kubernetes-ingress/controller/store"
@@ -97,7 +97,7 @@ func Frontend(i store.Ingress, r *rules.Rules, m maps.MapFiles) []Annotation {
9797
}
9898
}
9999

100-
func Backend(b *models.Backend, s store.K8s, certs *haproxy.Certificates) []Annotation {
100+
func Backend(b *models.Backend, s store.K8s, c *certs.Certificates) []Annotation {
101101
annotations := []Annotation{
102102
service.NewAbortOnClose("abortonclose", b),
103103
service.NewTimeoutCheck("timeout-check", b),
@@ -109,8 +109,8 @@ func Backend(b *models.Backend, s store.K8s, certs *haproxy.Certificates) []Anno
109109
service.NewSendProxy("send-proxy-protocol", b),
110110
// Order is important for ssl annotations so they don't conflict
111111
service.NewSSL("server-ssl", b),
112-
service.NewCrt("server-crt", certs, b),
113-
service.NewCA("server-ca", certs, b),
112+
service.NewCrt("server-crt", c, b),
113+
service.NewCA("server-ca", c, b),
114114
service.NewProto("server-proto", b),
115115
}
116116
if b.Mode == "http" {

controller/annotations/service/ca.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ import (
44
"github.com/haproxytech/client-native/v2/models"
55

66
"github.com/haproxytech/kubernetes-ingress/controller/annotations/common"
7-
"github.com/haproxytech/kubernetes-ingress/controller/haproxy"
7+
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/certs"
88
"github.com/haproxytech/kubernetes-ingress/controller/store"
99
)
1010

1111
type CA struct {
1212
name string
13-
haproxyCerts *haproxy.Certificates
13+
haproxyCerts *certs.Certificates
1414
backend *models.Backend
1515
}
1616

17-
func NewCA(n string, c *haproxy.Certificates, b *models.Backend) *CA {
17+
func NewCA(n string, c *certs.Certificates, b *models.Backend) *CA {
1818
return &CA{
1919
name: n,
2020
haproxyCerts: c,
@@ -39,7 +39,7 @@ func (a *CA) Process(k store.K8s, annotations ...map[string]string) error {
3939
// Other values from serverSSL annotation are kept
4040
return nil
4141
}
42-
caFile, err = a.haproxyCerts.HandleTLSSecret(secret, haproxy.CA_CERT)
42+
caFile, err = a.haproxyCerts.HandleTLSSecret(secret, certs.CA_CERT)
4343
if err != nil {
4444
return err
4545
}

controller/annotations/service/crt.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ import (
44
"github.com/haproxytech/client-native/v2/models"
55

66
"github.com/haproxytech/kubernetes-ingress/controller/annotations/common"
7-
"github.com/haproxytech/kubernetes-ingress/controller/haproxy"
7+
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/certs"
88
"github.com/haproxytech/kubernetes-ingress/controller/store"
99
)
1010

1111
type Crt struct {
1212
name string
13-
haproxyCerts *haproxy.Certificates
13+
haproxyCerts *certs.Certificates
1414
backend *models.Backend
1515
}
1616

17-
func NewCrt(n string, c *haproxy.Certificates, b *models.Backend) *Crt {
17+
func NewCrt(n string, c *certs.Certificates, b *models.Backend) *Crt {
1818
return &Crt{
1919
name: n,
2020
haproxyCerts: c,
@@ -39,7 +39,7 @@ func (a *Crt) Process(k store.K8s, annotations ...map[string]string) error {
3939
// Other values from serverSSL annotation are kept
4040
return nil
4141
}
42-
crtFile, err = a.haproxyCerts.HandleTLSSecret(secret, haproxy.BD_CERT)
42+
crtFile, err = a.haproxyCerts.HandleTLSSecret(secret, certs.BD_CERT)
4343
if err != nil {
4444
return err
4545
}

controller/configuration/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
"os"
2020
"path/filepath"
2121

22-
"github.com/haproxytech/kubernetes-ingress/controller/haproxy"
22+
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/certs"
2323
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/maps"
2424
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/rules"
2525
"github.com/haproxytech/kubernetes-ingress/controller/utils"
@@ -28,7 +28,7 @@ import (
2828
type ControllerCfg struct {
2929
MapFiles *maps.MapFiles
3030
HAProxyRules *rules.SectionRules
31-
Certificates *haproxy.Certificates
31+
Certificates *certs.Certificates
3232
ActiveBackends map[string]struct{}
3333
RateLimitTables []string
3434
FrontHTTP string
@@ -73,7 +73,7 @@ func (c *ControllerCfg) Init() (err error) {
7373
if err := c.haproxyRulesInit(); err != nil {
7474
return err
7575
}
76-
c.Certificates = haproxy.NewCertificates(c.Env.CaCertDir, c.Env.FrontendCertDir, c.Env.BackendCertDir)
76+
c.Certificates = certs.NewCertificates(c.Env.CaCertDir, c.Env.FrontendCertDir, c.Env.BackendCertDir)
7777
c.ActiveBackends = make(map[string]struct{})
7878
return nil
7979
}

controller/controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020

2121
"github.com/haproxytech/client-native/v2/models"
2222
config "github.com/haproxytech/kubernetes-ingress/controller/configuration"
23-
"github.com/haproxytech/kubernetes-ingress/controller/haproxy"
2423
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/api"
24+
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/certs"
2525
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/process"
2626
"github.com/haproxytech/kubernetes-ingress/controller/route"
2727
"github.com/haproxytech/kubernetes-ingress/controller/status"
@@ -192,7 +192,7 @@ func (c *HAProxyController) updateHAProxy() {
192192
logger.Warningf("ingress '%s/%s': %s", ingress.Namespace, ingress.Name, secErr)
193193
continue
194194
}
195-
_, err = c.Cfg.Certificates.HandleTLSSecret(secret, haproxy.FT_CERT)
195+
_, err = c.Cfg.Certificates.HandleTLSSecret(secret, certs.FT_CERT)
196196
logger.Error(err)
197197
}
198198
// Ingress annotations

controller/global.go

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

2222
"github.com/haproxytech/kubernetes-ingress/controller/annotations"
2323
"github.com/haproxytech/kubernetes-ingress/controller/configuration"
24-
"github.com/haproxytech/kubernetes-ingress/controller/haproxy"
24+
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/certs"
2525
"github.com/haproxytech/kubernetes-ingress/controller/store"
2626
)
2727

@@ -176,6 +176,6 @@ func (c *HAProxyController) handleDefaultCert() {
176176
if secret == nil {
177177
return
178178
}
179-
_, err = c.Cfg.Certificates.HandleTLSSecret(secret, haproxy.FT_DEFAULT_CERT)
179+
_, err = c.Cfg.Certificates.HandleTLSSecret(secret, certs.FT_DEFAULT_CERT)
180180
logger.Error(err)
181181
}

controller/handler/https.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import (
2222

2323
"github.com/haproxytech/kubernetes-ingress/controller/annotations"
2424
config "github.com/haproxytech/kubernetes-ingress/controller/configuration"
25-
"github.com/haproxytech/kubernetes-ingress/controller/haproxy"
2625
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/api"
26+
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/certs"
2727
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/maps"
2828
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/rules"
2929
"github.com/haproxytech/kubernetes-ingress/controller/store"
@@ -90,7 +90,7 @@ func (h HTTPS) handleClientTLSAuth(k store.K8s, cfg *config.ControllerCfg, api a
9090
if secret == nil {
9191
return
9292
}
93-
caFile, err = cfg.Certificates.HandleTLSSecret(secret, haproxy.CA_CERT)
93+
caFile, err = cfg.Certificates.HandleTLSSecret(secret, certs.CA_CERT)
9494
if err != nil {
9595
err = fmt.Errorf("client TLS Auth: %w", err)
9696
return

controller/haproxy/certificates.go renamed to controller/haproxy/certs/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package haproxy
1+
package certs
22

33
import (
44
"errors"

controller/service/service.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import (
2323
"github.com/haproxytech/client-native/v2/models"
2424

2525
"github.com/haproxytech/kubernetes-ingress/controller/annotations"
26-
"github.com/haproxytech/kubernetes-ingress/controller/haproxy"
2726
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/api"
27+
"github.com/haproxytech/kubernetes-ingress/controller/haproxy/certs"
2828
"github.com/haproxytech/kubernetes-ingress/controller/store"
2929
"github.com/haproxytech/kubernetes-ingress/controller/utils"
3030
)
@@ -37,12 +37,12 @@ type SvcContext struct {
3737
path *store.IngressPath
3838
service *store.Service
3939
backend *models.Backend
40-
certs *haproxy.Certificates
40+
certs *certs.Certificates
4141
modeTCP bool
4242
newBackend bool
4343
}
4444

45-
func NewCtx(k8s store.K8s, ingress *store.Ingress, path *store.IngressPath, certs *haproxy.Certificates, tcpService bool) (*SvcContext, error) {
45+
func NewCtx(k8s store.K8s, ingress *store.Ingress, path *store.IngressPath, certs *certs.Certificates, tcpService bool) (*SvcContext, error) {
4646
service, err := getService(k8s, ingress.Namespace, path.SvcName)
4747
if err != nil {
4848
return nil, err

0 commit comments

Comments
 (0)