Skip to content

Commit 2eda323

Browse files
committed
OPTIM/MINOR: go: Optimize struct field alignments
1 parent 7996549 commit 2eda323

18 files changed

+110
-108
lines changed

adapters/adapters.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ type Adapter func(http.Handler) http.Handler
3333

3434
type frame struct {
3535
File string
36-
Line int
3736
Name string
37+
Line int
3838
}
3939

4040
type stack []frame

configuration/cluster_sync.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const DataplaneAPIType = "community"
4848

4949
// Node is structure required for connection to cluster
5050
type Node struct {
51+
Facts map[string]string `json:"facts"`
5152
Address string `json:"address"`
5253
APIBasePath string `json:"api_base_path"`
5354
APIPassword string `json:"api_password"`
@@ -56,10 +57,9 @@ type Node struct {
5657
Description string `json:"description,omitempty"`
5758
ID string `json:"id,omitempty"`
5859
Name string `json:"name"`
59-
Port int64 `json:"port,omitempty"`
6060
Status string `json:"status"`
6161
Type string `json:"type"`
62-
Facts map[string]string `json:"facts"`
62+
Port int64 `json:"port,omitempty"`
6363
}
6464

6565
// ClusterSync fetches certificates for joining cluster

configuration/configuration.go

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -36,45 +36,45 @@ import (
3636
var cfg *Configuration
3737

3838
type HAProxyConfiguration struct {
39-
ConfigFile string `short:"c" long:"config-file" description:"Path to the haproxy configuration file" default:"/etc/haproxy/haproxy.cfg" group:"haproxy"`
40-
Userlist string `short:"u" long:"userlist" description:"Userlist in HAProxy configuration to use for API Basic Authentication" default:"controller" group:"userlist"`
39+
SpoeDir string `long:"spoe-dir" description:"Path to SPOE directory." default:"/etc/haproxy/spoe" group:"resources"`
40+
ServiceName string `long:"service" description:"Name of the HAProxy service" group:"reload"`
4141
HAProxy string `short:"b" long:"haproxy-bin" description:"Path to the haproxy binary file" default:"haproxy" group:"haproxy"`
42-
ReloadDelay int `short:"d" long:"reload-delay" description:"Minimum delay between two reloads (in s)" default:"5" group:"reload"`
42+
UserListFile string `long:"userlist-file" description:"Path to the dataplaneapi userlist file. By default userlist is read from HAProxy conf. When specified userlist would be read from this file" group:"userlist"`
4343
ReloadCmd string `short:"r" long:"reload-cmd" description:"Reload command" group:"reload"`
4444
RestartCmd string `short:"s" long:"restart-cmd" description:"Restart command" group:"reload"`
4545
StatusCmd string `long:"status-cmd" description:"Status command" group:"reload"`
46-
ServiceName string `long:"service" description:"Name of the HAProxy service" group:"reload"`
47-
ReloadRetention int `long:"reload-retention" description:"Reload retention in days, every older reload id will be deleted" default:"1" group:"reload"`
46+
NodeIDFile string `long:"fid" description:"Path to file that will dataplaneapi use to write its id (not a pid) that was given to him after joining a cluster" group:"haproxy"`
47+
PIDFile string `long:"pid-file" description:"Path to file that will dataplaneapi use to write its pid" group:"dataplaneapi" example:"/tmp/dataplane.pid"`
4848
ReloadStrategy string `long:"reload-strategy" description:"Either systemd, s6 or custom" default:"custom" group:"reload"`
4949
TransactionDir string `short:"t" long:"transaction-dir" description:"Path to the transaction directory" default:"/tmp/haproxy" group:"transaction"`
50-
BackupsNumber int `short:"n" long:"backups-number" description:"Number of backup configuration files you want to keep, stored in the config dir with version number suffix" default:"0" group:"transaction"`
50+
ValidateCmd string `long:"validate-cmd" description:"Executes a custom command to perform the HAProxy configuration check" group:"reload"`
5151
BackupsDir string `long:"backups-dir" description:"Path to directory in which to place backup files" group:"transaction"`
52-
MasterRuntime string `short:"m" long:"master-runtime" description:"Path to the master Runtime API socket" group:"haproxy"`
53-
ShowSystemInfo bool `short:"i" long:"show-system-info" description:"Show system info on info endpoint" group:"dataplaneapi"`
54-
DataplaneConfig string `short:"f" description:"Path to the dataplane configuration file" default:"/etc/haproxy/dataplaneapi.hcl" yaml:"-"`
55-
UserListFile string `long:"userlist-file" description:"Path to the dataplaneapi userlist file. By default userlist is read from HAProxy conf. When specified userlist would be read from this file" group:"userlist"`
56-
NodeIDFile string `long:"fid" description:"Path to file that will dataplaneapi use to write its id (not a pid) that was given to him after joining a cluster" group:"haproxy"`
5752
MapsDir string `short:"p" long:"maps-dir" description:"Path to directory of map files managed by dataplane" default:"/etc/haproxy/maps" group:"resources"`
53+
SpoeTransactionDir string `long:"spoe-transaction-dir" description:"Path to the SPOE transaction directory" default:"/tmp/spoe-haproxy" group:"resources"`
54+
DataplaneConfig string `short:"f" description:"Path to the dataplane configuration file" default:"/etc/haproxy/dataplaneapi.hcl" yaml:"-"`
55+
ConfigFile string `short:"c" long:"config-file" description:"Path to the haproxy configuration file" default:"/etc/haproxy/haproxy.cfg" group:"haproxy"`
56+
Userlist string `short:"u" long:"userlist" description:"Userlist in HAProxy configuration to use for API Basic Authentication" default:"controller" group:"userlist"`
57+
MasterRuntime string `short:"m" long:"master-runtime" description:"Path to the master Runtime API socket" group:"haproxy"`
5858
SSLCertsDir string `long:"ssl-certs-dir" description:"Path to SSL certificates directory" default:"/etc/haproxy/ssl" group:"resources"`
5959
GeneralStorageDir string `long:"general-storage-dir" description:"Path to general storage directory" default:"/etc/haproxy/general" group:"resources"`
60-
UpdateMapFiles bool `long:"update-map-files" description:"Flag used for syncing map files with runtime maps values" group:"resources"`
61-
UpdateMapFilesPeriod int64 `long:"update-map-files-period" description:"Elapsed time in seconds between two maps syncing operations" default:"10" group:"resources"`
6260
ClusterTLSCertDir string `long:"cluster-tls-dir" description:"Path where cluster tls certificates will be stored. Defaults to same directory as dataplane configuration file" group:"cluster"`
63-
SpoeDir string `long:"spoe-dir" description:"Path to SPOE directory." default:"/etc/haproxy/spoe" group:"resources"`
64-
SpoeTransactionDir string `long:"spoe-transaction-dir" description:"Path to the SPOE transaction directory" default:"/tmp/spoe-haproxy" group:"resources"`
65-
MasterWorkerMode bool `long:"master-worker-mode" description:"Flag to enable helpers when running within HAProxy" group:"haproxy"`
61+
UpdateMapFilesPeriod int64 `long:"update-map-files-period" description:"Elapsed time in seconds between two maps syncing operations" default:"10" group:"resources"`
62+
ReloadDelay int `short:"d" long:"reload-delay" description:"Minimum delay between two reloads (in s)" default:"5" group:"reload"`
6663
MaxOpenTransactions int64 `long:"max-open-transactions" description:"Limit for active transaction in pending state" default:"20" group:"transaction"`
67-
ValidateCmd string `long:"validate-cmd" description:"Executes a custom command to perform the HAProxy configuration check" group:"reload"`
68-
DisableInotify bool `long:"disable-inotify" description:"Disables inotify watcher for the configuration file" group:"dataplaneapi"`
69-
PIDFile string `long:"pid-file" description:"Path to file that will dataplaneapi use to write its pid" group:"dataplaneapi" example:"/tmp/dataplane.pid"`
64+
BackupsNumber int `short:"n" long:"backups-number" description:"Number of backup configuration files you want to keep, stored in the config dir with version number suffix" default:"0" group:"transaction"`
65+
ReloadRetention int `long:"reload-retention" description:"Reload retention in days, every older reload id will be deleted" default:"1" group:"reload"`
7066
UID int `long:"uid" description:"User id value to set on start" group:"dataplaneapi" example:"1000"`
7167
GID int `long:"gid" description:"Group id value to set on start" group:"dataplaneapi" example:"1000"`
68+
UpdateMapFiles bool `long:"update-map-files" description:"Flag used for syncing map files with runtime maps values" group:"resources"`
69+
ShowSystemInfo bool `short:"i" long:"show-system-info" description:"Show system info on info endpoint" group:"dataplaneapi"`
70+
MasterWorkerMode bool `long:"master-worker-mode" description:"Flag to enable helpers when running within HAProxy" group:"haproxy"`
71+
DisableInotify bool `long:"disable-inotify" description:"Disables inotify watcher for the configuration file" group:"dataplaneapi"`
7272
}
7373

7474
type User struct {
7575
Name string `long:"name" description:"User name" group:"user" hcl:"name,key" example:"admin"`
76-
Insecure bool `long:"insecure" description:"insecure password" group:"user" example:"true"`
7776
Password string `long:"password" description:"password" group:"user" example:"adminpwd"`
77+
Insecure bool `long:"insecure" description:"insecure password" group:"user" example:"true"`
7878
}
7979

8080
type APIConfiguration struct {
@@ -83,22 +83,22 @@ type APIConfiguration struct {
8383
}
8484

8585
type ClusterConfiguration struct {
86-
ID AtomicString `yaml:"id,omitempty" group:"cluster" save:"true"`
87-
BootstrapKey AtomicString `yaml:"bootstrap_key,omitempty" group:"cluster" save:"true"`
86+
APIRegisterPath AtomicString `yaml:"api_register_path,omitempty" group:"cluster" save:"true"`
87+
APIBasePath AtomicString `yaml:"api_base_path,omitempty" group:"cluster" save:"true"`
8888
ActiveBootstrapKey AtomicString `yaml:"active_bootstrap_key,omitempty" group:"cluster" save:"true"`
8989
Token AtomicString `yaml:"token,omitempty" group:"cluster" save:"true"`
90-
URL AtomicString `yaml:"url,omitempty" group:"cluster" save:"true"`
90+
ID AtomicString `yaml:"id,omitempty" group:"cluster" save:"true"`
9191
Port AtomicInt `yaml:"port,omitempty" group:"cluster" save:"true"`
92-
APIBasePath AtomicString `yaml:"api_base_path,omitempty" group:"cluster" save:"true"`
92+
BootstrapKey AtomicString `yaml:"bootstrap_key,omitempty" group:"cluster" save:"true"`
9393
APINodesPath AtomicString `yaml:"api_nodes_path,omitempty" group:"cluster" save:"true"`
94-
APIRegisterPath AtomicString `yaml:"api_register_path,omitempty" group:"cluster" save:"true"`
94+
URL AtomicString `yaml:"url,omitempty" group:"cluster" save:"true"`
9595
StorageDir AtomicString `yaml:"storage_dir,omitempty" group:"cluster" save:"true"`
9696
CertificateDir AtomicString `yaml:"cert_path,omitempty" group:"cluster" save:"true"`
9797
CertificateFetched AtomicBool `yaml:"cert_fetched,omitempty" group:"cluster" save:"true" example:"false"`
9898
Name AtomicString `yaml:"name,omitempty" group:"cluster" save:"true"`
9999
Description AtomicString `yaml:"description,omitempty" group:"cluster" save:"true"`
100-
ClusterLogTargets []*models.ClusterLogTarget `yaml:"cluster_log_targets,omitempty" group:"cluster" save:"true"`
101100
ClusterID AtomicString `yaml:"cluster_id,omitempty" group:"cluster" save:"true"`
101+
ClusterLogTargets []*models.ClusterLogTarget `yaml:"cluster_log_targets,omitempty" group:"cluster" save:"true"`
102102
}
103103

104104
func (c *ClusterConfiguration) Clear() {
@@ -118,8 +118,8 @@ func (c *ClusterConfiguration) Clear() {
118118

119119
type RuntimeData struct {
120120
Host string
121-
Port int
122121
APIBasePath string
122+
Port int
123123
}
124124

125125
type NotifyConfiguration struct {
@@ -131,34 +131,34 @@ type NotifyConfiguration struct {
131131
}
132132

133133
type ServiceDiscovery struct {
134+
Consuls []*models.Consul `yaml:"consuls" group:"service_discovery" save:"true"`
135+
AWSRegions []*models.AwsRegion `yaml:"aws-regions" group:"service_discovery" save:"true"`
134136
consulMu sync.Mutex
135-
Consuls []*models.Consul `yaml:"consuls" group:"service_discovery" save:"true"`
136137
awsMu sync.Mutex
137-
AWSRegions []*models.AwsRegion `yaml:"aws-regions" group:"service_discovery" save:"true"`
138138
}
139139

140140
//nolint:staticcheck
141141
type Configuration struct {
142-
Name AtomicString `yaml:"name" example:"famous_condor"`
143-
storage Storage `yaml:"-"`
144-
HAProxy HAProxyConfiguration `yaml:"-"`
145-
Logging log.LoggingOptions `yaml:"-"`
146-
LogTargets log.Targets `yaml:"log_targets,omitempty" hcl:"log_targets" group:"log"`
147-
Syslog log.SyslogOptions `yaml:"-"`
148-
APIOptions APIConfiguration `yaml:"-"`
149142
Cluster ClusterConfiguration `yaml:"-"`
150-
RuntimeData RuntimeData `yaml:"-"`
151143
Notify NotifyConfiguration `yaml:"-"`
152-
ServiceDiscovery ServiceDiscovery `yaml:"-"`
153-
Users []User `yaml:"-"`
154144
Mode AtomicString `yaml:"mode" default:"single"`
155-
DeprecatedBootstrapKey AtomicString `yaml:"bootstrap_key,omitempty" deprecated:"true"` // deprecated - use Cluster.BootstrapKey
156-
Status AtomicString `yaml:"status,omitempty"`
145+
storage Storage `yaml:"-"`
146+
Name AtomicString `yaml:"name" example:"famous_condor"`
157147
Cmdline AtomicString `yaml:"-"`
148+
Status AtomicString `yaml:"status,omitempty"`
149+
DeprecatedBootstrapKey AtomicString `yaml:"bootstrap_key,omitempty" deprecated:"true"`
150+
reloadSignal chan os.Signal
151+
shutdownSignal chan os.Signal
158152
MapSync *MapSync `yaml:"-"`
153+
Syslog log.SyslogOptions `yaml:"-"`
154+
Logging log.LoggingOptions `yaml:"-"`
155+
RuntimeData RuntimeData `yaml:"-"`
156+
ServiceDiscovery ServiceDiscovery `yaml:"-"`
157+
Users []User `yaml:"-"`
158+
APIOptions APIConfiguration `yaml:"-"`
159+
LogTargets log.Targets `yaml:"log_targets,omitempty" hcl:"log_targets" group:"log"`
160+
HAProxy HAProxyConfiguration `yaml:"-"`
159161
mutex sync.Mutex
160-
shutdownSignal chan os.Signal
161-
reloadSignal chan os.Signal
162162
}
163163

164164
var cfgInitOnce sync.Once

0 commit comments

Comments
 (0)