Skip to content

Commit 5676edd

Browse files
committed
OPTIM/MAJOR: go: Optimize struct field alignments
1 parent 19e7590 commit 5676edd

File tree

16 files changed

+41
-41
lines changed

16 files changed

+41
-41
lines changed

pkg/annotations/cfgSnippet.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ const (
2828
)
2929

3030
type CfgSnippet struct {
31+
ingress *store.Ingress
32+
service *store.Service
3133
name string
3234
frontend string
3335
backend string
34-
ingress *store.Ingress
35-
service *store.Service
3636
}
3737

3838
type cfgData struct {
39+
status store.Status
3940
value []string
4041
updated []string
4142
disabled bool
42-
status store.Status
4343
}
4444

4545
// CfgSnippetType represents type of a config snippet
@@ -82,10 +82,10 @@ func InitCfgSnippet() {
8282
}
8383

8484
type ConfigSnippetOptions struct {
85-
Name string
8685
Backend *string
8786
Frontend *string
8887
Ingress *store.Ingress
88+
Name string
8989
}
9090

9191
// DisableConfigSnippets fills a map[cfgSnippetType]struct{} of disabled config snippet types:

pkg/controller/builder.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,20 @@ import (
4444
)
4545

4646
type Builder struct {
47+
store store.K8s
4748
annotations annotations.Annotations
4849
haproxyClient api.HAProxyClient
4950
gatewayManager gateway.GatewayManager
5051
haproxyProcess process.Process
5152
haproxyRules rules.Rules
5253
restClientSet client.Client
54+
updateStatusManager status.UpdateStatusManager
5355
updatePublishServiceFunc func(ingresses []*ingress.Ingress, publishServiceAddresses []string)
5456
eventChan chan k8ssync.SyncDataEvent
5557
clientSet *kubernetes.Clientset
56-
haproxyEnv env.Env
5758
haproxyCfgFile []byte
58-
store store.K8s
59+
haproxyEnv env.Env
5960
osArgs utils.OSArgs
60-
updateStatusManager status.UpdateStatusManager
6161
}
6262

6363
var defaultEnv = env.Env{

pkg/controller/controller.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,24 @@ var logger = utils.GetLogger()
4141

4242
// HAProxyController is ingress controller
4343
type HAProxyController struct {
44+
store store.K8s
45+
prometheusMetricsManager metrics.PrometheusMetricsManager
4446
gatewayManager gateway.GatewayManager
4547
annotations annotations.Annotations
48+
updateStatusManager status.UpdateStatusManager
4649
eventChan chan k8ssync.SyncDataEvent
4750
updatePublishServiceFunc func(ingresses []*ingress.Ingress, publishServiceAddresses []string)
4851
chShutdown chan struct{}
4952
podNamespace string
5053
podPrefix string
51-
haproxy haproxy.HAProxy
54+
PodIP string
55+
Hostname string
5256
updateHandlers []UpdateHandler
53-
store store.K8s
57+
beforeUpdateHandlers []UpdateHandler
58+
haproxy haproxy.HAProxy
5459
osArgs utils.OSArgs
5560
auxCfgModTime int64
5661
ready bool
57-
updateStatusManager status.UpdateStatusManager
58-
beforeUpdateHandlers []UpdateHandler
59-
prometheusMetricsManager metrics.PrometheusMetricsManager
60-
PodIP string
61-
Hostname string
6262
}
6363

6464
// Wrapping a Native-Client transaction and commit it.

pkg/handler/quic.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ const (
2121
type Quic struct {
2222
AddrIPv4 string
2323
AddrIPv6 string
24-
IPv4 bool
25-
IPv6 bool
2624
CertDir string
27-
QuicAnnouncePort int64
2825
MaxAge string
26+
QuicAnnouncePort int64
2927
QuicBindPort int64
28+
IPv4 bool
29+
IPv6 bool
3030
}
3131

3232
func (q *Quic) Update(k store.K8s, h haproxy.HAProxy, a annotations.Annotations) (err error) {

pkg/handler/tcp-cr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ type TCPCustomResource struct{}
3838

3939
type tcpcontext struct {
4040
k store.K8s
41-
h haproxy.HAProxy
4241
namespace string
42+
h haproxy.HAProxy
4343
}
4444

4545
func (handler TCPCustomResource) Update(k store.K8s, h haproxy.HAProxy, a annotations.Annotations) (err error) {

pkg/haproxy/api/runtime.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ type RuntimeServerData struct {
2020
BackendName string
2121
ServerName string
2222
IP string
23-
Port int
2423
State string
24+
Port int
2525
}
2626

2727
func (c *clientNative) ExecuteRaw(command string) (result []string, err error) {

pkg/haproxy/instance/configuration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ func NeedAction() bool {
4242
}
4343

4444
type configurationManagerImpl struct {
45-
reload, restart bool
4645
logger utils.Logger
46+
reload, restart bool
4747
}
4848

4949
func NewConfigurationManager() *configurationManagerImpl {

pkg/k8s/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ type k8s struct {
7777
apiExtensionsClient *crdclientset.Clientset
7878
publishSvc *utils.NamespaceValue
7979
gatewayClient *gatewayclientset.Clientset
80+
crdClient *crdclientset.Clientset
8081
podPrefix string
8182
podNamespace string
8283
whiteListedNS []string
8384
syncPeriod time.Duration
8485
cacheResyncPeriod time.Duration
8586
disableSvcExternalName bool // CVE-2021-25740
86-
crdClient *crdclientset.Clientset
8787
gatewayAPIInstalled bool
8888
}
8989

pkg/reference-counter/reference-counter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ type (
4343
)
4444

4545
type ResourceCounter struct {
46-
mu sync.Mutex
4746
owners map[HaproxyCfgResourceName]Owners
4847
owned map[OwnerKey]Owned
48+
mu sync.Mutex
4949
}
5050

5151
func NewResourceCounter() *ResourceCounter {

pkg/secret/secret.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ type Manager struct {
2929

3030
type Secret struct {
3131
Name types.NamespacedName
32-
SecretType certs.SecretType
3332
OwnerType OwnerType
3433
OwnerName string
34+
SecretType certs.SecretType
3535
}
3636

3737
// module logger

0 commit comments

Comments
 (0)