-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUG/MINOR: add compression algo-req algo-res type-req type-res
- Loading branch information
1 parent
1145ec5
commit 5b78218
Showing
14 changed files
with
999 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Oops, something went wrong.