perf: apply fieldalignement (#1284)

This commit is contained in:
Jason Cameron 2025-11-16 15:43:07 -05:00 committed by GitHub
parent da1890380e
commit 9dd4de6f1f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 90 additions and 94 deletions

View file

@ -8,9 +8,9 @@ import (
func TestASNsValid(t *testing.T) {
for _, tt := range []struct {
name string
input *ASNs
err error
input *ASNs
name string
}{
{
name: "basic valid",

View file

@ -62,13 +62,11 @@ type BotConfig struct {
Expression *ExpressionOrList `json:"expression,omitempty" yaml:"expression,omitempty"`
Challenge *ChallengeRules `json:"challenge,omitempty" yaml:"challenge,omitempty"`
Weight *Weight `json:"weight,omitempty" yaml:"weight,omitempty"`
GeoIP *GeoIP `json:"geoip,omitempty"`
ASNs *ASNs `json:"asns,omitempty"`
Name string `json:"name" yaml:"name"`
Action Rule `json:"action" yaml:"action"`
RemoteAddr []string `json:"remote_addresses,omitempty" yaml:"remote_addresses,omitempty"`
// Thoth features
GeoIP *GeoIP `json:"geoip,omitempty"`
ASNs *ASNs `json:"asns,omitempty"`
}
func (b BotConfig) Zero() bool {
@ -324,13 +322,13 @@ func (sc StatusCodes) Valid() error {
}
type fileConfig struct {
Bots []BotOrImport `json:"bots"`
DNSBL bool `json:"dnsbl"`
OpenGraph openGraphFileConfig `json:"openGraph,omitempty"`
Impressum *Impressum `json:"impressum,omitempty"`
StatusCodes StatusCodes `json:"status_codes"`
Store *Store `json:"store"`
Bots []BotOrImport `json:"bots"`
Thresholds []Threshold `json:"thresholds"`
StatusCodes StatusCodes `json:"status_codes"`
DNSBL bool `json:"dnsbl"`
}
func (c *fileConfig) Valid() error {
@ -462,13 +460,13 @@ func Load(fin io.Reader, fname string) (*Config, error) {
}
type Config struct {
Impressum *Impressum
Store *Store
OpenGraph OpenGraph
Bots []BotConfig
Thresholds []Threshold
DNSBL bool
Impressum *Impressum
OpenGraph OpenGraph
StatusCodes StatusCodes
Store *Store
DNSBL bool
}
func (c Config) Valid() error {

View file

@ -15,9 +15,9 @@ func p[V any](v V) *V { return &v }
func TestBotValid(t *testing.T) {
var tests = []struct {
bot BotConfig
err error
name string
bot BotConfig
}{
{
name: "simple user agent",

View file

@ -11,10 +11,10 @@ import (
func TestExpressionOrListMarshalJSON(t *testing.T) {
for _, tt := range []struct {
name string
input *ExpressionOrList
output []byte
err error
input *ExpressionOrList
name string
output []byte
}{
{
name: "single expression",
@ -74,10 +74,10 @@ func TestExpressionOrListMarshalJSON(t *testing.T) {
func TestExpressionOrListMarshalYAML(t *testing.T) {
for _, tt := range []struct {
name string
input *ExpressionOrList
output []byte
err error
input *ExpressionOrList
name string
output []byte
}{
{
name: "single expression",
@ -217,8 +217,8 @@ func TestExpressionOrListUnmarshalJSON(t *testing.T) {
func TestExpressionOrListString(t *testing.T) {
for _, tt := range []struct {
name string
in ExpressionOrList
out string
in ExpressionOrList
}{
{
name: "single expression",

View file

@ -7,9 +7,9 @@ import (
func TestGeoIPValid(t *testing.T) {
for _, tt := range []struct {
name string
input *GeoIP
err error
input *GeoIP
name string
}{
{
name: "basic valid",

View file

@ -8,9 +8,9 @@ import (
func TestImpressumValid(t *testing.T) {
for _, cs := range []struct {
name string
inp Impressum
err error
inp Impressum
name string
}{
{
name: "basic happy path",

View file

@ -13,17 +13,17 @@ var (
)
type openGraphFileConfig struct {
Override map[string]string `json:"override,omitempty" yaml:"override,omitempty"`
TimeToLive string `json:"ttl" yaml:"ttl"`
Enabled bool `json:"enabled" yaml:"enabled"`
ConsiderHost bool `json:"considerHost" yaml:"enabled"`
TimeToLive string `json:"ttl" yaml:"ttl"`
Override map[string]string `json:"override,omitempty" yaml:"override,omitempty"`
}
type OpenGraph struct {
Enabled bool `json:"enabled" yaml:"enabled"`
ConsiderHost bool `json:"considerHost" yaml:"enabled"`
Override map[string]string `json:"override,omitempty" yaml:"override,omitempty"`
TimeToLive time.Duration `json:"ttl" yaml:"ttl"`
Enabled bool `json:"enabled" yaml:"enabled"`
ConsiderHost bool `json:"considerHost" yaml:"enabled"`
}
func (og *openGraphFileConfig) Valid() error {

View file

@ -7,9 +7,9 @@ import (
func TestOpenGraphFileConfigValid(t *testing.T) {
for _, tt := range []struct {
name string
input *openGraphFileConfig
err error
input *openGraphFileConfig
name string
}{
{
name: "basic happy path",

View file

@ -12,9 +12,9 @@ import (
func TestStoreValid(t *testing.T) {
for _, tt := range []struct {
err error
name string
input config.Store
err error
}{
{
name: "no backend",

View file

@ -31,10 +31,10 @@ var (
)
type Threshold struct {
Name string `json:"name" yaml:"name"`
Expression *ExpressionOrList `json:"expression" yaml:"expression"`
Action Rule `json:"action" yaml:"action"`
Challenge *ChallengeRules `json:"challenge" yaml:"challenge"`
Name string `json:"name" yaml:"name"`
Action Rule `json:"action" yaml:"action"`
}
func (t Threshold) Valid() error {

View file

@ -10,9 +10,9 @@ import (
func TestThresholdValid(t *testing.T) {
for _, tt := range []struct {
name string
input *Threshold
err error
input *Threshold
name string
}{
{
name: "basic allow",