Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

Commit 0a99d03

Browse files
author
David Chung
authored
Support README in playbooks (#471)
Signed-off-by: David Chung <[email protected]>
1 parent 4e670c2 commit 0a99d03

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

pkg/cli/remote/remote.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package remote
33
import (
44
"fmt"
55
"io"
6+
"path"
67
"strings"
78

89
"github.com/docker/infrakit/pkg/cli"
@@ -16,6 +17,13 @@ import (
1617

1718
var log = logutil.New("module", "cli/remote")
1819

20+
// helpTemplate is for embedding content from README.md in the same directory.
21+
const helpTemplate = `{{with or .Long .Short }}{{. | trim}}
22+
23+
%s
24+
{{end}}{{if or .Runnable .HasSubCommands}}{{.UsageString}}{{end}}
25+
`
26+
1927
type remote struct {
2028
modules Modules
2129
input io.Reader
@@ -104,6 +112,15 @@ loop:
104112
// if we can parse it as a map, then we have a 'directory'
105113
mods, err := dir(url)
106114
if err == nil {
115+
116+
// Documentation -- look for a README.md at the given dir
117+
readme := path.Join(path.Dir(string(url)), "README.md")
118+
if t, err := template.NewTemplate(readme, template.Options{}); err == nil {
119+
if view, err := t.Render(nil); err == nil {
120+
cmd.SetHelpTemplate(fmt.Sprintf(helpTemplate, view))
121+
}
122+
}
123+
107124
copy := url
108125
subs, err := list(plugins, mods, input, cmd, &copy)
109126
if err != nil {

pkg/rpc/mux/reverse_proxy_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ func TestMuxPlugins(t *testing.T) {
143143
})
144144
require.NotNil(t, rp)
145145

146-
proxy, err := startProxy(t, ":8080", rp)
146+
proxy, err := startProxy(t, ":24864", rp)
147147
require.NoError(t, err)
148148
defer proxy.Stop(10 * time.Second)
149149

150-
get := "http://localhost:8080/" + pluginName + rpc.URLAPI
150+
get := "http://localhost:24864/" + pluginName + rpc.URLAPI
151151

152152
T(100).Infoln("Basic info client:", get)
153153
resp, err := http.Get(get)

0 commit comments

Comments
 (0)