Skip to content

Commit ad64005

Browse files
committed
MAJOR: move config-parser into client-native
there are lots off reasons why we need to do that, but main reason is to move from custom types that config parser uses to client native models. this will also simplify further development since we almost 99% percent of the time need to add similar code to both projects and with this change, only one PR is needed
1 parent 32e9bca commit ad64005

File tree

1 file changed

+11
-112
lines changed

1 file changed

+11
-112
lines changed

README.md

Lines changed: 11 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,25 @@
11
# ![HAProxy](assets/images/haproxy-weblogo-210x49.png "HAProxy")
22

3-
## HAProxy configuration parser
3+
<br/>
44

5-
[![Contributors](https://img.shields.io/github/contributors/haproxytech/config-parser?color=purple)](https://github.com/haproxy/haproxy/blob/master/CONTRIBUTING)
6-
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
5+
:warning: This project has been merged with [client-native](https://github.com/haproxytech/client-native) project.
76

8-
### autogenerated code
9-
if you change types/types.go you need to run
10-
```bash
11-
make generate
7+
use
8+
```go
9+
import "github.com/haproxytech/client-native/v6/config-parser"
1210
```
13-
### Contributing
14-
15-
For commit messages and general style please follow the haproxy project's [CONTRIBUTING guide](https://github.com/haproxy/haproxy/blob/master/CONTRIBUTING) and use that where applicable.
1611

17-
Please use `golangci-lint run` from [github.com/golangci/golangci-lint](https://github.com/golangci/golangci-lint) for linting code.
18-
19-
### Example
12+
instead of
2013

2114
```go
22-
package main
23-
24-
import (
25-
"github.com/haproxytech/config-parser/v5"
26-
"github.com/haproxytech/config-parser/v5/options"
27-
"github.com/haproxytech/config-parser/v5/parsers/http/actions"
28-
// ...
29-
)
30-
// ...
31-
32-
func main() {
33-
p, err := parser.New(options.Path("config.cfg"))
34-
/* p, err := parser.New(
35-
options.UseMd5Hash,
36-
options.Path("config.cfg")
37-
)*/
38-
if err != nil {
39-
log.Panic(err)
40-
}
41-
42-
{
43-
data, _ := p.Get(parser.Comments, parser.CommentsSectionName, "# _version", true)
44-
if err == errors.ErrFetch {
45-
log.Panicln("we have an fetch error !!")
46-
}
47-
ver, _ := data.(*types.Int64C)
48-
ver.Value = ver.Value + 1
49-
}
50-
51-
{
52-
p.Set(parser.Frontends, "http", "option forwardfor", types.OptionForwardFor{})
53-
}
54-
55-
{
56-
// for options that can exists multiple times in config Insert is preffered
57-
//
58-
// setting http-request & http-response is a bit different
59-
// since they accept multiple structs
60-
httpRequestActionDeny := &actions.Deny{
61-
DenyStatus: "0",
62-
Cond: "unless",
63-
CondTest: "{ src 127.0.0.1 }",
64-
}
65-
err = p.Insert(parser.Backends, "web_servers", "http-request", httpRequestActionDeny)
66-
// you can also choose index where action should be inserted
67-
err = p.Insert(parser.Backends, "web_servers", "http-request", httpRequestActionDeny, 2)
68-
}
69-
70-
{
71-
data, err := p.Get(parser.Global, parser.GlobalSectionName, "stats socket")
72-
if err != nil {
73-
log.Panicln(err)
74-
}
75-
val, _ := data.([]types.Socket)
76-
log.Println(val[0])
77-
val[0].Path = "$PWD/haproxy-runtime-api.1.sock"
78-
log.Println(val[0])
79-
}
80-
81-
{
82-
data, err := p.Get(parser.Global, parser.GlobalSectionName, "daemon")
83-
log.Println(data, err)
84-
if err == errors.ErrFetch {
85-
log.Panicln("we have an fetch error !!")
86-
}
87-
//remove it
88-
p.Set(parser.Global, parser.GlobalSectionName, "daemon", nil)
89-
}
90-
91-
{
92-
datar, err := p.Get(parser.Resolvers, "ns1", "nameserver")
93-
if err == nil {
94-
ns := datar.([]types.Nameserver)
95-
log.Println(ns[0].Name, ns[0].Address)
96-
log.Println(ns[1].Name, ns[1].Address)
97-
ns[1].Name = "hahaha"
98-
ns[0].Address = "0.0.0.0:8080"
99-
}
100-
datar, err = p.Get(parser.Resolvers, "ns1", "nameserver")
101-
if err == nil {
102-
ns := datar.([]types.Nameserver)
103-
log.Println(ns[0].Name, ns[0].Address)
104-
log.Println(ns[1].Name, ns[1].Address)
105-
}
106-
}
15+
import "github.com/haproxytech/config-parser/v5"
16+
```
10717

108-
{
109-
log.Println("nbproc ==================================================")
110-
data, err := p.Get(parser.Global, parser.GlobalSectionName, "nbproc")
111-
if err != nil {
112-
log.Println(err)
113-
} else {
114-
d := data.(*types.Int64C)
115-
log.Println(d.Value)
116-
d.Value = 5
117-
}
118-
}
18+
## Maintenance mode
11919

120-
p.Save(configFilename)
121-
}
20+
This library remains supported until September 2025 (bug fixes only).
12221

123-
```
22+
All new development must be done on the [client-native](https://github.com/haproxytech/client-native) repository.
12423

12524
## License
12625

0 commit comments

Comments
 (0)