Skip to content

Commit

Permalink
BUG/MINOR: compression direction both not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
hdurand0710 committed Feb 20, 2024
1 parent da63d45 commit 9d32b8b
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 6 deletions.
6 changes: 5 additions & 1 deletion configuration/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,9 @@ func TestGetBackend(t *testing.T) {
t.Errorf("%v: Compression.Types[1] wrong: %v", b.Name, b.Compression.Types[1])
}
}
if b.Compression.Direction != "both" {
t.Errorf("%v: Compression.Direction not both: %v", b.Name, b.Compression.Direction)
}
}
if b.Checkcache != "enabled" {
t.Errorf("%v: Checkcache not enabled: %v", b.Name, b.Checkcache)
Expand Down Expand Up @@ -726,7 +729,8 @@ func TestCreateEditDeleteBackend(t *testing.T) {
},
AcceptInvalidHTTPResponse: "enabled",
Compression: &models.Compression{
Offload: true,
Offload: true,
Direction: "both",
},
LogHealthChecks: "enabled",
Checkcache: "enabled",
Expand Down
25 changes: 25 additions & 0 deletions configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,15 @@ func (s *SectionParser) compression() interface{} {
}
}

data, err = s.get("compression direction", false)
if err == nil {
d, ok := data.(*types.StringC)
if ok && d != nil {
compressionFound = true
compression.Direction = d.Value
}
}

if compressionFound {
return compression
}
Expand Down Expand Up @@ -2612,6 +2621,16 @@ func (s *SectionObject) compression(field reflect.Value) error {
if err != nil {
return err
}

err = s.set("compression direction", nil)
if err != nil {
// compression direction does not exist on Frontends
var setErr error
if errors.As(parser_errors.ErrAttributeNotFound, &setErr) {
return nil
}
return err
}
return nil
}
compression, ok := field.Elem().Interface().(models.Compression)
Expand All @@ -2637,6 +2656,12 @@ func (s *SectionObject) compression(field reflect.Value) error {
return err
}
}
if len(compression.Direction) > 0 {
err = s.set("compression direction", &types.StringC{Value: compression.Direction})
if err != nil {
return err
}
}
return nil
}

Expand Down
1 change: 1 addition & 0 deletions configuration/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@ backend test
no option accept-invalid-http-response
no option h1-case-adjust-bogus-server
compression type application/json text/plain
compression direction both
srvtcpka-cnt 10
srvtcpka-idle 10s
srvtcpka-intvl 10
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/google/go-cmp v0.6.0
github.com/google/renameio v1.0.1
github.com/google/uuid v1.6.0
github.com/haproxytech/config-parser/v5 v5.1.0
github.com/haproxytech/config-parser/v5 v5.1.1-0.20240220100901-1145ec548975
github.com/json-iterator/go v1.1.12
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/mitchellh/mapstructure v1.5.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ github.com/google/renameio v1.0.1 h1:Lh/jXZmvZxb0BBeSY5VKEfidcbcbenKjZFzM/q0fSeU
github.com/google/renameio v1.0.1/go.mod h1:t/HQoYBZSsWSNK35C6CO/TpPLDVWvxOHboWUAweKUpk=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/haproxytech/config-parser/v5 v5.1.0 h1:gdifNXscsx4x++GQWw9Oj3JDpJMgSLtCiXgdQqxsYQU=
github.com/haproxytech/config-parser/v5 v5.1.0/go.mod h1:iy8nBB1eopwYbyeh3FQpjxZUxfcIDyTV9bW0F1t+cVA=
github.com/haproxytech/config-parser/v5 v5.1.1-0.20240220100901-1145ec548975 h1:CL/3SEvayajAyRHHOmKLsqiwZ8SVwAstCbKEvuxNknI=
github.com/haproxytech/config-parser/v5 v5.1.1-0.20240220100901-1145ec548975/go.mod h1:iy8nBB1eopwYbyeh3FQpjxZUxfcIDyTV9bW0F1t+cVA=
github.com/haproxytech/go-logger v1.1.0 h1:HgGtYaI1ApkvbQdsm7f9AzQQoxTB7w37criTflh7IQE=
github.com/haproxytech/go-logger v1.1.0/go.mod h1:OekUd8HCb7ubxMplzHUPBTHNxZmddOWfOjWclZsqIeM=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
Expand Down
54 changes: 54 additions & 0 deletions models/compression.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions models/compression_compare.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions models/compression_compare_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions specification/build/haproxy_spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9852,6 +9852,13 @@ definitions:
type: string
type: array
x-omitempty: true
direction:
enum:
- request
- response
- both
type: string
x-omitempty: true
offload:
type: boolean
types:
Expand Down
4 changes: 4 additions & 0 deletions specification/models/configuration/misc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ compression:
type: string
offload:
type: boolean
direction:
type: string
enum: [request, response, both]
x-omitempty: true
stats_http_request:
type: object
required:
Expand Down

0 comments on commit 9d32b8b

Please sign in to comment.