Skip to content

Commit f26aa67

Browse files
committed
OPTIM/MAJOR: go: Optimize struct field alignments
1 parent dd217b3 commit f26aa67

File tree

12 files changed

+31
-31
lines changed

12 files changed

+31
-31
lines changed

pkg/annotations/cfgSnippet.go

+4-4
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

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,20 @@ import (
4343
)
4444

4545
type Builder struct {
46+
store store.K8s
4647
annotations annotations.Annotations
4748
haproxyClient api.HAProxyClient
4849
gatewayManager gateway.GatewayManager
4950
haproxyProcess process.Process
5051
haproxyRules rules.Rules
5152
restClientSet client.Client
53+
updateStatusManager status.UpdateStatusManager
5254
updatePublishServiceFunc func(ingresses []*ingress.Ingress, publishServiceAddresses []string)
5355
eventChan chan k8s.SyncDataEvent
5456
clientSet *kubernetes.Clientset
55-
haproxyEnv env.Env
5657
haproxyCfgFile []byte
57-
store store.K8s
58+
haproxyEnv env.Env
5859
osArgs utils.OSArgs
59-
updateStatusManager status.UpdateStatusManager
6060
}
6161

6262
var defaultEnv = env.Env{

pkg/controller/controller.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,21 @@ var logger = utils.GetLogger()
4040

4141
// HAProxyController is ingress controller
4242
type HAProxyController struct {
43+
store store.K8s
4344
gatewayManager gateway.GatewayManager
4445
annotations annotations.Annotations
46+
updateStatusManager status.UpdateStatusManager
4547
eventChan chan k8s.SyncDataEvent
4648
updatePublishServiceFunc func(ingresses []*ingress.Ingress, publishServiceAddresses []string)
4749
chShutdown chan struct{}
4850
podNamespace string
4951
podPrefix string
50-
haproxy haproxy.HAProxy
5152
updateHandlers []UpdateHandler
52-
store store.K8s
53+
beforeUpdateHandlers []UpdateHandler
54+
haproxy haproxy.HAProxy
5355
osArgs utils.OSArgs
5456
auxCfgModTime int64
5557
ready bool
56-
updateStatusManager status.UpdateStatusManager
57-
beforeUpdateHandlers []UpdateHandler
5858
}
5959

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

pkg/handler/quic.go

+3-3
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/haproxy/api/runtime.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ type RuntimeServerData struct {
1919
BackendName string
2020
ServerName string
2121
IP string
22-
Port int
2322
State string
23+
Port int
2424
}
2525

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

pkg/haproxy/instance/configuration.go

+1-1
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ type k8s struct {
7676
apiExtensionsClient *crdclientset.Clientset
7777
publishSvc *utils.NamespaceValue
7878
gatewayClient *gatewayclientset.Clientset
79+
crdClient *crdclientset.Clientset
7980
podPrefix string
8081
podNamespace string
8182
whiteListedNS []string
8283
syncPeriod time.Duration
8384
cacheResyncPeriod time.Duration
8485
disableSvcExternalName bool // CVE-2021-25740
85-
crdClient *crdclientset.Clientset
8686
gatewayAPIInstalled bool
8787
}
8888

pkg/service/service.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ var logger = utils.GetLogger()
3535
const cookieKey = "ohph7OoGhong"
3636

3737
type Service struct {
38-
path *store.IngressPath
39-
resource *store.Service
40-
backend *models.Backend
41-
certs certs.Certificates
38+
certs certs.Certificates
39+
path *store.IngressPath
40+
resource *store.Service
41+
backend *models.Backend
42+
// ingressName string
43+
// ingressNamespace string
44+
ingress *store.Ingress
4245
annotations []map[string]string
4346
modeTCP bool
4447
newBackend bool
4548
standalone bool
46-
// ingressName string
47-
// ingressNamespace string
48-
ingress *store.Ingress
4949
}
5050

5151
// New returns a Service instance to handle the k8s IngressPath resource given in params.

pkg/status/updatestatus.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ type UpdateStatusManager interface {
1717
}
1818

1919
type UpdateStatusManagerImpl struct {
20-
updateIngresses []*ingress.Ingress
2120
client *kubernetes.Clientset
2221
ingressClass string
22+
updateIngresses []*ingress.Ingress
2323
emptyIngressClass bool
2424
}
2525

pkg/store/store.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ type K8s struct {
3131
SecretsProcessed map[string]struct{}
3232
BackendsProcessed map[string]struct{}
3333
GatewayClasses map[string]*GatewayClass
34+
HaProxyPods map[string]struct{}
35+
BackendsWithNoConfigSnippets map[string]struct{}
3436
GatewayControllerName string
3537
PublishServiceAddresses []string
36-
HaProxyPods map[string]struct{}
3738
UpdateAllIngresses bool
38-
BackendsWithNoConfigSnippets map[string]struct{}
3939
}
4040

4141
type NamespacesWatch struct {

pkg/utils/flags.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ type OSArgs struct {
8181
CfgDir string `long:"config-dir" description:"path to HAProxy configuration directory. NOTE: works only in External mode"`
8282
Program string `long:"program" description:"path to HAProxy program. NOTE: works only with External mode"`
8383
KubeConfig string `long:"kubeconfig" default:"" description:"combined with -e. location of kube config file"`
84+
DisableConfigSnippets string `long:"disable-config-snippets" description:"Allow to disable config snippets. List of comma separated values (possible values: all/global/backend/frontend)"`
8485
Version []bool `short:"v" long:"version" description:"version"`
8586
NamespaceWhitelist []string `long:"namespace-whitelist" description:"whitelisted namespaces"`
8687
NamespaceBlacklist []string `long:"namespace-blacklist" description:"blacklisted namespaces"`
@@ -95,6 +96,8 @@ type OSArgs struct {
9596
SyncPeriod time.Duration `long:"sync-period" default:"5s" description:"Sets the period at which the controller syncs HAProxy configuration file"`
9697
CacheResyncPeriod time.Duration `long:"cache-resync-period" default:"10m" description:"Sets the underlying Shared Informer resync period: resyncing controller with informers cache"`
9798
HealthzBindPort int64 `long:"healthz-bind-port" default:"1042" description:"port to listen on for probes"`
99+
QuicAnnouncePort int64 `long:"quic-announce-port" description:"sets the port in the alt-svc header"`
100+
QuicBindPort int64 `long:"quic-bind-port" description:"sets the binding port for quic in HTTPS frontend"`
98101
LogLevel LogLevelValue `long:"log" default:"info" description:"level of log messages you can see"`
99102
DisableIPV4 bool `long:"disable-ipv4" description:"toggle to disable the IPv4 protocol from all frontends"`
100103
External bool `short:"e" long:"external" description:"use as external Ingress Controller (out of k8s cluster)"`
@@ -107,10 +110,7 @@ type OSArgs struct {
107110
PrometheusEnabled bool `long:"prometheus" description:"enable prometheus of IC data"`
108111
DisableHTTP bool `long:"disable-http" description:"toggle to disable the HTTP frontend"`
109112
DisableIPV6 bool `long:"disable-ipv6" description:"toggle to disable the IPv6 protocol from all frontends"`
110-
DisableConfigSnippets string `long:"disable-config-snippets" description:"Allow to disable config snippets. List of comma separated values (possible values: all/global/backend/frontend)"`
111113
UseWithPebble bool `long:"with-pebble" description:"use pebble to start/stop/reload HAProxy"`
112114
JobCheckCRD bool `long:"job-check-crd" description:"does not execute IC, but adds/updates CRDs"`
113115
DisableQuic bool `long:"disable-quic" description:"disable quic protocol in http frontend bindings"`
114-
QuicAnnouncePort int64 `long:"quic-announce-port" description:"sets the port in the alt-svc header"`
115-
QuicBindPort int64 `long:"quic-bind-port" description:"sets the binding port for quic in HTTPS frontend"`
116116
}

pkg/utils/logging.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ type Logger interface { //nolint:interfacebloat
9292
}
9393

9494
type logger struct {
95+
fields map[string]interface{}
9596
Level LogLevel
9697
FileName bool
97-
fields map[string]interface{}
9898
}
9999

100100
var (

0 commit comments

Comments
 (0)