Skip to content

Commit 16af8a8

Browse files
add more patterns
1 parent b25f345 commit 16af8a8

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,22 @@ See 'docker run --help'.
3636
Once the method is checked, a list of regular expressions are checked. In version 0.1.0 the list reads:
3737
3838
```bash
39-
# List and inspect containers
40-
^/(v\d\.\d+/)?containers(/\w+)?/json$
39+
# List, inspect, metrics and processes of containers
40+
^/(v\d\.\d+/)?containers(/\w+)?/(json|stats|top)$
4141
# List and inspect services
4242
^/(v\d\.\d+/)?services(/[0-9a-f]+)?$
4343
# List and inspect tasks
4444
^/(v\d\.\d+/)?tasks(/\w+)?$
4545
# List and inspect networks
4646
^/(v\d\.\d+/)?networks(/\w+)?$
47+
# List and inspect volumes
48+
^/(v\d\.\d+/)?volumes(/\w+)?$
4749
# List and inspect nodes
4850
^/(v\d\.\d+/)?nodes(/\w+)?$
4951
# Show engine info
5052
^/(v\d\.\d+/)?info$
53+
# Show engine version
54+
^/(v\d\.\d+/)?version$
5155
# Healthcheck
5256
^/_ping$
5357
```

doxy.pattern

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
# List and inspect containers
2-
^/(v\d\.\d+/)?containers(/\w+)?/json$
1+
# List, inspect, metrics and processes of containers
2+
^/(v\d\.\d+/)?containers(/\w+)?/(json|stats|top)$
33
# List and inspect services
44
^/(v\d\.\d+/)?services(/[0-9a-f]+)?$
55
# List and inspect tasks
66
^/(v\d\.\d+/)?tasks(/\w+)?$
77
# List and inspect networks
88
^/(v\d\.\d+/)?networks(/\w+)?$
9+
# List and inspect volumes
10+
^/(v\d\.\d+/)?volumes(/\w+)?$
911
# List and inspect nodes
1012
^/(v\d\.\d+/)?nodes(/\w+)?$
1113
# Show engine info
1214
^/(v\d\.\d+/)?info$
15+
# Show engine version
16+
^/(v\d\.\d+/)?version$
1317
# Healthcheck
1418
^/_ping$

main.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import (
66
"github.com/zpatrick/go-config"
77
"github.com/codegangsta/cli"
88
"github.com/qnib/doxy/proxy"
9-
"bufio"
10-
"strings"
119
)
1210

1311

@@ -19,20 +17,19 @@ func RunApp(ctx *cli.Context) {
1917
debug, _ := cfg.Bool("debug")
2018
patternsFile, _ := cfg.String("pattern-file")
2119
reader, err := os.Open(patternsFile)
22-
if err != nil {
23-
return
24-
}
2520
defer reader.Close()
26-
patterns, err := proxy.ReadPatterns(reader)
21+
patterns := []string{}
2722
if err != nil {
2823
log.Printf("Error reading patterns file (%s), using default patterns\n", err.Error())
2924
patterns = []string{
30-
`^/(v\d\.\d+/)?containers(/\w+)?/json$`,
25+
`^/(v\d\.\d+/)?containers(/\w+)?/(json|stats|top)$`,
3126
`^/(v\d\.\d+/)?services(/[0-9a-f]+)?$`,
3227
`^/(v\d\.\d+/)?tasks(/\w+)?$`,
3328
`^/(v\d\.\d+/)?networks(/\w+)?$`,
29+
`^/(v\d\.\d+/)?volumes(/\w+)?$`,
3430
`^/(v\d\.\d+/)?nodes(/\w+)?$`,
3531
`^/(v\d\.\d+/)?info$`,
32+
`^/(v\d\.\d+/)?version$`,
3633
"^/_ping$",
3734
}
3835
if debug {
@@ -41,6 +38,8 @@ func RunApp(ctx *cli.Context) {
4138
}
4239

4340
}
41+
} else {
42+
patterns, err = proxy.ReadPatterns(reader)
4443
}
4544
p := proxy.NewProxy(newSock, dockerSock, debug)
4645
p.AddPatterns(patterns)

proxy/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package proxy
22

33
import (
4+
"log"
45
"net/http"
56
"os"
67
"syscall"
@@ -45,6 +46,7 @@ func (p *Proxy) Run() {
4546
n.Use(negroni.NewLogger())
4647
}
4748
n.UseHandler(upstream)
49+
log.Printf("Serving proxy on '%s'", p.newSocket)
4850
if err = http.Serve(l, n); err != nil {
4951
panic(err)
5052
}

0 commit comments

Comments
 (0)