Skip to content

Commit

Permalink
OPTIM/MAJOR: go: Optimize struct field alignments
Browse files Browse the repository at this point in the history
  • Loading branch information
dkorunic committed Aug 14, 2024
1 parent dd217b3 commit f26aa67
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 31 deletions.
8 changes: 4 additions & 4 deletions pkg/annotations/cfgSnippet.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ const (
)

type CfgSnippet struct {
ingress *store.Ingress
service *store.Service
name string
frontend string
backend string
ingress *store.Ingress
service *store.Service
}

type cfgData struct {
status store.Status
value []string
updated []string
disabled bool
status store.Status
}

// CfgSnippetType represents type of a config snippet
Expand Down Expand Up @@ -82,10 +82,10 @@ func InitCfgSnippet() {
}

type ConfigSnippetOptions struct {
Name string
Backend *string
Frontend *string
Ingress *store.Ingress
Name string
}

// DisableConfigSnippets fills a map[cfgSnippetType]struct{} of disabled config snippet types:
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ import (
)

type Builder struct {
store store.K8s
annotations annotations.Annotations
haproxyClient api.HAProxyClient
gatewayManager gateway.GatewayManager
haproxyProcess process.Process
haproxyRules rules.Rules
restClientSet client.Client
updateStatusManager status.UpdateStatusManager
updatePublishServiceFunc func(ingresses []*ingress.Ingress, publishServiceAddresses []string)
eventChan chan k8s.SyncDataEvent
clientSet *kubernetes.Clientset
haproxyEnv env.Env
haproxyCfgFile []byte
store store.K8s
haproxyEnv env.Env
osArgs utils.OSArgs
updateStatusManager status.UpdateStatusManager
}

var defaultEnv = env.Env{
Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ var logger = utils.GetLogger()

// HAProxyController is ingress controller
type HAProxyController struct {
store store.K8s
gatewayManager gateway.GatewayManager
annotations annotations.Annotations
updateStatusManager status.UpdateStatusManager
eventChan chan k8s.SyncDataEvent
updatePublishServiceFunc func(ingresses []*ingress.Ingress, publishServiceAddresses []string)
chShutdown chan struct{}
podNamespace string
podPrefix string
haproxy haproxy.HAProxy
updateHandlers []UpdateHandler
store store.K8s
beforeUpdateHandlers []UpdateHandler
haproxy haproxy.HAProxy
osArgs utils.OSArgs
auxCfgModTime int64
ready bool
updateStatusManager status.UpdateStatusManager
beforeUpdateHandlers []UpdateHandler
}

// Wrapping a Native-Client transaction and commit it.
Expand Down
6 changes: 3 additions & 3 deletions pkg/handler/quic.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ const (
type Quic struct {
AddrIPv4 string
AddrIPv6 string
IPv4 bool
IPv6 bool
CertDir string
QuicAnnouncePort int64
MaxAge string
QuicAnnouncePort int64
QuicBindPort int64
IPv4 bool
IPv6 bool
}

func (q *Quic) Update(k store.K8s, h haproxy.HAProxy, a annotations.Annotations) (err error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/haproxy/api/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ type RuntimeServerData struct {
BackendName string
ServerName string
IP string
Port int
State string
Port int
}

func (c *clientNative) ExecuteRaw(command string) (result []string, err error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/haproxy/instance/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ func NeedAction() bool {
}

type configurationManagerImpl struct {
reload, restart bool
logger utils.Logger
reload, restart bool
}

func NewConfigurationManager() *configurationManagerImpl {
Expand Down
2 changes: 1 addition & 1 deletion pkg/k8s/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ type k8s struct {
apiExtensionsClient *crdclientset.Clientset
publishSvc *utils.NamespaceValue
gatewayClient *gatewayclientset.Clientset
crdClient *crdclientset.Clientset
podPrefix string
podNamespace string
whiteListedNS []string
syncPeriod time.Duration
cacheResyncPeriod time.Duration
disableSvcExternalName bool // CVE-2021-25740
crdClient *crdclientset.Clientset
gatewayAPIInstalled bool
}

Expand Down
14 changes: 7 additions & 7 deletions pkg/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ var logger = utils.GetLogger()
const cookieKey = "ohph7OoGhong"

type Service struct {
path *store.IngressPath
resource *store.Service
backend *models.Backend
certs certs.Certificates
certs certs.Certificates
path *store.IngressPath
resource *store.Service
backend *models.Backend
// ingressName string
// ingressNamespace string
ingress *store.Ingress
annotations []map[string]string
modeTCP bool
newBackend bool
standalone bool
// ingressName string
// ingressNamespace string
ingress *store.Ingress
}

// New returns a Service instance to handle the k8s IngressPath resource given in params.
Expand Down
2 changes: 1 addition & 1 deletion pkg/status/updatestatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ type UpdateStatusManager interface {
}

type UpdateStatusManagerImpl struct {
updateIngresses []*ingress.Ingress
client *kubernetes.Clientset
ingressClass string
updateIngresses []*ingress.Ingress
emptyIngressClass bool
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ type K8s struct {
SecretsProcessed map[string]struct{}
BackendsProcessed map[string]struct{}
GatewayClasses map[string]*GatewayClass
HaProxyPods map[string]struct{}
BackendsWithNoConfigSnippets map[string]struct{}
GatewayControllerName string
PublishServiceAddresses []string
HaProxyPods map[string]struct{}
UpdateAllIngresses bool
BackendsWithNoConfigSnippets map[string]struct{}
}

type NamespacesWatch struct {
Expand Down
6 changes: 3 additions & 3 deletions pkg/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ type OSArgs struct {
CfgDir string `long:"config-dir" description:"path to HAProxy configuration directory. NOTE: works only in External mode"`
Program string `long:"program" description:"path to HAProxy program. NOTE: works only with External mode"`
KubeConfig string `long:"kubeconfig" default:"" description:"combined with -e. location of kube config file"`
DisableConfigSnippets string `long:"disable-config-snippets" description:"Allow to disable config snippets. List of comma separated values (possible values: all/global/backend/frontend)"`
Version []bool `short:"v" long:"version" description:"version"`
NamespaceWhitelist []string `long:"namespace-whitelist" description:"whitelisted namespaces"`
NamespaceBlacklist []string `long:"namespace-blacklist" description:"blacklisted namespaces"`
Expand All @@ -95,6 +96,8 @@ type OSArgs struct {
SyncPeriod time.Duration `long:"sync-period" default:"5s" description:"Sets the period at which the controller syncs HAProxy configuration file"`
CacheResyncPeriod time.Duration `long:"cache-resync-period" default:"10m" description:"Sets the underlying Shared Informer resync period: resyncing controller with informers cache"`
HealthzBindPort int64 `long:"healthz-bind-port" default:"1042" description:"port to listen on for probes"`
QuicAnnouncePort int64 `long:"quic-announce-port" description:"sets the port in the alt-svc header"`
QuicBindPort int64 `long:"quic-bind-port" description:"sets the binding port for quic in HTTPS frontend"`
LogLevel LogLevelValue `long:"log" default:"info" description:"level of log messages you can see"`
DisableIPV4 bool `long:"disable-ipv4" description:"toggle to disable the IPv4 protocol from all frontends"`
External bool `short:"e" long:"external" description:"use as external Ingress Controller (out of k8s cluster)"`
Expand All @@ -107,10 +110,7 @@ type OSArgs struct {
PrometheusEnabled bool `long:"prometheus" description:"enable prometheus of IC data"`
DisableHTTP bool `long:"disable-http" description:"toggle to disable the HTTP frontend"`
DisableIPV6 bool `long:"disable-ipv6" description:"toggle to disable the IPv6 protocol from all frontends"`
DisableConfigSnippets string `long:"disable-config-snippets" description:"Allow to disable config snippets. List of comma separated values (possible values: all/global/backend/frontend)"`
UseWithPebble bool `long:"with-pebble" description:"use pebble to start/stop/reload HAProxy"`
JobCheckCRD bool `long:"job-check-crd" description:"does not execute IC, but adds/updates CRDs"`
DisableQuic bool `long:"disable-quic" description:"disable quic protocol in http frontend bindings"`
QuicAnnouncePort int64 `long:"quic-announce-port" description:"sets the port in the alt-svc header"`
QuicBindPort int64 `long:"quic-bind-port" description:"sets the binding port for quic in HTTPS frontend"`
}
2 changes: 1 addition & 1 deletion pkg/utils/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ type Logger interface { //nolint:interfacebloat
}

type logger struct {
fields map[string]interface{}
Level LogLevel
FileName bool
fields map[string]interface{}
}

var (
Expand Down

0 comments on commit f26aa67

Please sign in to comment.