Skip to content

Commit

Permalink
BUG/MINOR: add compression algo-req algo-res type-req type-res
Browse files Browse the repository at this point in the history
  • Loading branch information
hdurand0710 committed Feb 21, 2024
1 parent 1145ec5 commit 5b78218
Show file tree
Hide file tree
Showing 14 changed files with 999 additions and 3 deletions.
53 changes: 53 additions & 0 deletions parsers/compression-algo-req.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
Copyright 2022 HAProxy Technologies
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package parsers

import (
"fmt"

"github.com/haproxytech/config-parser/v5/common"
"github.com/haproxytech/config-parser/v5/errors"
"github.com/haproxytech/config-parser/v5/types"
)

type CompressionAlgoReq struct {
data *types.StringC
preComments []string // comments that appear before the actual line
}

func (c *CompressionAlgoReq) Parse(line string, parts []string, comment string) (string, error) {
if len(parts) < 3 {
return "", &errors.ParseError{Parser: "CompressionAlgoReq", Line: line, Message: "Parse error"}
}
c.data = &types.StringC{
Value: parts[2],
Comment: comment,
}
return "", nil
}

func (c *CompressionAlgoReq) Result() ([]common.ReturnResultLine, error) {
if c.data == nil {
return nil, errors.ErrFetch
}
return []common.ReturnResultLine{
{
Data: fmt.Sprintf("compression algo-req %s", c.data.Value),
Comment: c.data.Comment,
},
}, nil
}
99 changes: 99 additions & 0 deletions parsers/compression-algo-req_generated.go

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

61 changes: 61 additions & 0 deletions parsers/compression-algo-res.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
Copyright 2022 HAProxy Technologies
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package parsers

import (
"strings"

"github.com/haproxytech/config-parser/v5/common"
"github.com/haproxytech/config-parser/v5/errors"
"github.com/haproxytech/config-parser/v5/types"
)

type CompressionAlgoRes struct {
data *types.StringSliceC
preComments []string // comments that appear before the actual line
}

func (c *CompressionAlgoRes) Parse(line string, parts []string, comment string) (string, error) {
if len(parts) < 3 {
return "", &errors.ParseError{Parser: "CompressionAlgoRes", Line: line, Message: "Parse error"}
}
c.data = &types.StringSliceC{
Value: parts[2:],
Comment: comment,
}
return "", nil
}

func (c *CompressionAlgoRes) Result() ([]common.ReturnResultLine, error) {
if c.data == nil || len(c.data.Value) == 0 {
return nil, errors.ErrFetch
}
var result strings.Builder
result.WriteString("compression algo-res")

for _, typereq := range c.data.Value {
result.WriteString(" ")
result.WriteString(typereq)
}

return []common.ReturnResultLine{
{
Data: result.String(),
Comment: c.data.Comment,
},
}, nil
}
99 changes: 99 additions & 0 deletions parsers/compression-algo-res_generated.go

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

61 changes: 61 additions & 0 deletions parsers/compression-type-req.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
Copyright 2022 HAProxy Technologies
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package parsers

import (
"strings"

"github.com/haproxytech/config-parser/v5/common"
"github.com/haproxytech/config-parser/v5/errors"
"github.com/haproxytech/config-parser/v5/types"
)

type CompressionTypeReq struct {
data *types.StringSliceC
preComments []string // comments that appear before the actual line
}

func (c *CompressionTypeReq) Parse(line string, parts []string, comment string) (string, error) {
if len(parts) < 3 {
return "", &errors.ParseError{Parser: "CompressionTypeReq", Line: line, Message: "Parse error"}
}
c.data = &types.StringSliceC{
Value: parts[2:],
Comment: comment,
}
return "", nil
}

func (c *CompressionTypeReq) Result() ([]common.ReturnResultLine, error) {
if c.data == nil || len(c.data.Value) == 0 {
return nil, errors.ErrFetch
}
var result strings.Builder
result.WriteString("compression type-req")

for _, typereq := range c.data.Value {
result.WriteString(" ")
result.WriteString(typereq)
}

return []common.ReturnResultLine{
{
Data: result.String(),
Comment: c.data.Comment,
},
}, nil
}
Loading

0 comments on commit 5b78218

Please sign in to comment.