Experimental web UI
This commit is contained in:
parent
4c5eb22cb2
commit
6d8420898c
2 changed files with 233 additions and 0 deletions
|
@ -19,6 +19,7 @@ import (
|
|||
"bytes"
|
||||
"text/tabwriter"
|
||||
"sort"
|
||||
"os"
|
||||
)
|
||||
|
||||
func (docker *Docker) CmdHelp(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
||||
|
@ -36,6 +37,7 @@ func (docker *Docker) CmdHelp(stdin io.ReadCloser, stdout io.Writer, args ...str
|
|||
{"export", "Extract changes to a container's filesystem into a new layer"},
|
||||
{"attach", "Attach to the standard inputs and outputs of a running container"},
|
||||
{"info", "Display system-wide information"},
|
||||
{"web", "Generate a web UI"},
|
||||
} {
|
||||
fmt.Fprintf(stdout, " %-10.10s%s\n", cmd...)
|
||||
}
|
||||
|
@ -350,6 +352,8 @@ func (docker *Docker) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
log.Printf("%s\n", strings.Join(append(append([]string{"docker"}, cmd), args...), " "))
|
||||
if cmd == "" {
|
||||
cmd = "help"
|
||||
} else if cmd == "web" {
|
||||
w.Header().Set("content-type", "text/html")
|
||||
}
|
||||
method := docker.getMethod(cmd)
|
||||
if method == nil {
|
||||
|
@ -362,6 +366,15 @@ func (docker *Docker) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
}
|
||||
|
||||
func (docker *Docker) CmdWeb(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
||||
if file, err := os.Open("dockerweb.html"); err != nil {
|
||||
return err
|
||||
} else if _, err := io.Copy(stdout, file); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (docker *Docker) getMethod(name string) Cmd {
|
||||
methodName := "Cmd"+strings.ToUpper(name[:1])+strings.ToLower(name[1:])
|
||||
method, exists := reflect.TypeOf(docker).MethodByName(methodName)
|
||||
|
|
220
dockerd/dockerweb.html
Normal file
220
dockerd/dockerweb.html
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue