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 21, 2024
1 parent 2ab7c3b commit c4a4d20
Show file tree
Hide file tree
Showing 12 changed files with 325 additions and 8 deletions.
80 changes: 78 additions & 2 deletions configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ func (s *SectionParser) monitorFail() interface{} {
return nil
}

func (s *SectionParser) compression() interface{} {
func (s *SectionParser) compression() interface{} { //nolint:gocognit
compressionFound := false
compression := &models.Compression{}

Expand All @@ -1172,6 +1172,24 @@ func (s *SectionParser) compression() interface{} {
}
}

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

data, err = s.get("compression algo-res", false)
if err == nil {
d, ok := data.(*types.StringSliceC)
if ok && d != nil && len(d.Value) > 0 {
compressionFound = true
compression.AlgosRes = d.Value
}
}

data, err = s.get("compression type", false)
if err == nil {
d, ok := data.(*types.StringSliceC)
Expand All @@ -1181,6 +1199,24 @@ func (s *SectionParser) compression() interface{} {
}
}

data, err = s.get("compression type-req", false)
if err == nil {
d, ok := data.(*types.StringSliceC)
if ok && d != nil && len(d.Value) > 0 {
compressionFound = true
compression.TypesReq = d.Value
}
}

data, err = s.get("compression type-res", false)
if err == nil {
d, ok := data.(*types.StringSliceC)
if ok && d != nil && len(d.Value) > 0 {
compressionFound = true
compression.TypesRes = d.Value
}
}

data, err = s.get("compression offload", false)
if err == nil {
d, ok := data.(*types.Enabled)
Expand Down Expand Up @@ -2618,17 +2654,33 @@ func (s *SectionObject) statsOptions(field reflect.Value) error {
return s.set("stats", ss)
}

func (s *SectionObject) compression(field reflect.Value) error {
func (s *SectionObject) compression(field reflect.Value) error { //nolint:gocognit
var err error
if valueIsNil(field) {
err = s.set("compression algo", nil)
if err != nil {
return err
}
err = s.set("compression algo-req", nil)
if err != nil {
return err
}
err = s.set("compression algo-res", nil)
if err != nil {
return err
}
err = s.set("compression type", nil)
if err != nil {
return err
}
err = s.set("compression type-req", nil)
if err != nil {
return err
}
err = s.set("compression type-res", nil)
if err != nil {
return err
}
err = s.set("compression offload", nil)
if err != nil {
return err
Expand Down Expand Up @@ -2656,12 +2708,36 @@ func (s *SectionObject) compression(field reflect.Value) error {
return err
}
}
if len(compression.AlgoReq) > 0 {
err = s.set("compression algo-req", &types.StringC{Value: compression.AlgoReq})
if err != nil {
return err
}
}
if len(compression.AlgosRes) > 0 {
err = s.set("compression algo-res", &types.StringSliceC{Value: compression.AlgosRes})
if err != nil {
return err
}
}
if len(compression.Types) > 0 {
err = s.set("compression type", &types.StringSliceC{Value: compression.Types})
if err != nil {
return err
}
}
if len(compression.TypesReq) > 0 {
err = s.set("compression type-req", &types.StringSliceC{Value: compression.TypesReq})
if err != nil {
return err
}
}
if len(compression.TypesRes) > 0 {
err = s.set("compression type-res", &types.StringSliceC{Value: compression.TypesRes})
if err != nil {
return err
}
}
if compression.Offload {
err = s.set("compression offload", &types.Enabled{})
if err != nil {
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.1-0.20240220100901-1145ec548975
github.com/haproxytech/config-parser/v5 v5.1.1-0.20240221073837-5b782186def2
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.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/config-parser/v5 v5.1.1-0.20240221073837-5b782186def2 h1:YXI/15X8xJPrnyO8brmiNaFhOD17Ib9nszHRrlEtuIw=
github.com/haproxytech/config-parser/v5 v5.1.1-0.20240221073837-5b782186def2/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
105 changes: 105 additions & 0 deletions models/compression.go

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

32 changes: 32 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.

Loading

0 comments on commit c4a4d20

Please sign in to comment.