Skip to content

Commit 4bd34b5

Browse files
Autogenerate basic helm readme's for app umbrella charts (#452)
* Autogenerate basic helm readme's for app umbrella charts This will help at least provide some usable documentation for how to reconfigure helm charts * bump helm-docs
1 parent b4a908a commit 4bd34b5

5 files changed

Lines changed: 260 additions & 1 deletion

File tree

cmd/plural/deploy.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ func (p *Plural) doBuild(installation *api.Installation, force bool) error {
152152

153153
workspace.PrintLinks()
154154

155+
appReadme(repoName, false) // nolint:errcheck
155156
return err
156157
}
157158

cmd/plural/workspace.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import (
88

99
"github.com/pluralsh/plural/pkg/helm"
1010
"github.com/pluralsh/plural/pkg/provider"
11+
"github.com/pluralsh/plural/pkg/scaffold"
1112
"github.com/pluralsh/plural/pkg/utils"
13+
"github.com/pluralsh/plural/pkg/utils/git"
1214
"github.com/pluralsh/plural/pkg/wkspace"
1315
"github.com/urfave/cli"
1416
)
@@ -20,6 +22,18 @@ func (p *Plural) workspaceCommands() []cli.Command {
2022
Usage: "generates kubernetes credentials for this subworkspace",
2123
Action: latestVersion(kubeInit),
2224
},
25+
{
26+
Name: "readme",
27+
Usage: "generate chart readme for an app",
28+
ArgsUsage: "NAME",
29+
Flags: []cli.Flag{
30+
cli.BoolFlag{
31+
Name: "dry-run",
32+
Usage: "output to stdout instead of to a file",
33+
},
34+
},
35+
Action: latestVersion(func(c *cli.Context) error { return appReadme(c.Args().Get(0), c.Bool("dry-run")) }),
36+
},
2337
{
2438
Name: "helm",
2539
Usage: "upgrade/installs the helm chart for this subworkspace",
@@ -186,3 +200,13 @@ func (p *Plural) mapkubeapis(c *cli.Context) error {
186200

187201
return minimal.MapKubeApis()
188202
}
203+
204+
func appReadme(name string, dryRun bool) error {
205+
repoRoot, err := git.Root()
206+
if err != nil {
207+
return err
208+
}
209+
210+
dir := filepath.Join(repoRoot, name, "helm", name)
211+
return scaffold.Readme(dir, dryRun)
212+
}

go.mod

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ require (
4343
github.com/mikesmitty/edkey v0.0.0-20170222072505-3356ea4e686a
4444
github.com/mitchellh/go-homedir v1.1.0
4545
github.com/mitchellh/mapstructure v1.5.0
46+
github.com/norwoodj/helm-docs v1.11.2
4647
github.com/olekukonko/tablewriter v0.0.5
4748
github.com/packethost/packngo v0.29.0
4849
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
@@ -51,6 +52,7 @@ require (
5152
github.com/pluralsh/polly v0.1.1
5253
github.com/rodaine/hclencoder v0.0.1
5354
github.com/samber/lo v1.33.0
55+
github.com/spf13/viper v1.8.1
5456
github.com/thoas/go-funk v0.9.2
5557
github.com/urfave/cli v1.22.10
5658
github.com/wailsapp/wails/v2 v2.4.1
@@ -97,6 +99,7 @@ require (
9799
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
98100
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
99101
github.com/fatih/camelcase v1.0.0 // indirect
102+
github.com/fsnotify/fsnotify v1.6.0 // indirect
100103
github.com/go-gorp/gorp/v3 v3.1.0 // indirect
101104
github.com/go-ole/go-ole v1.2.6 // indirect
102105
github.com/goccy/go-json v0.9.7 // indirect
@@ -112,17 +115,23 @@ require (
112115
github.com/leaanthony/go-ansi-parser v1.0.1 // indirect
113116
github.com/leaanthony/gosod v1.0.3 // indirect
114117
github.com/leaanthony/slicer v1.5.0 // indirect
118+
github.com/magiconair/properties v1.8.5 // indirect
115119
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
120+
github.com/pelletier/go-toml v1.9.5 // indirect
116121
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
117122
github.com/pluralsh/controller-reconcile-helper v0.0.4 // indirect
123+
github.com/spf13/afero v1.8.0 // indirect
124+
github.com/spf13/jwalterweatherman v1.1.0 // indirect
118125
github.com/stretchr/objx v0.5.0 // indirect
126+
github.com/subosito/gotenv v1.2.0 // indirect
119127
github.com/tkrajina/go-reflector v0.5.5 // indirect
120128
github.com/valyala/bytebufferpool v1.0.0 // indirect
121129
github.com/valyala/fasttemplate v1.2.1 // indirect
122130
github.com/vektah/gqlparser/v2 v2.5.1 // indirect
123131
github.com/wailsapp/mimetype v1.4.1 // indirect
124132
github.com/zclconf/go-cty v1.10.0 // indirect
125133
google.golang.org/genproto v0.0.0-20230216225411-c8e22ba71e44 // indirect
134+
gopkg.in/ini.v1 v1.62.0 // indirect
126135
gopkg.in/yaml.v3 v3.0.1 // indirect
127136
)
128137

@@ -251,7 +260,7 @@ require (
251260
github.com/schollz/progressbar/v3 v3.8.6 // indirect
252261
github.com/sergi/go-diff v1.2.0 // indirect
253262
github.com/shopspring/decimal v1.2.0 // indirect
254-
github.com/sirupsen/logrus v1.9.0 // indirect
263+
github.com/sirupsen/logrus v1.9.0
255264
github.com/spf13/cast v1.4.1 // indirect
256265
github.com/spf13/cobra v1.6.1 // indirect
257266
github.com/spf13/pflag v1.0.5 // indirect
@@ -293,3 +302,5 @@ require (
293302
sigs.k8s.io/kustomize/kyaml v0.13.9 // indirect
294303
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
295304
)
305+
306+
replace github.com/norwoodj/helm-docs v1.11.2 => github.com/pluralsh/helm-docs v1.11.3-0.20230914190909-3fe18acd95d7

0 commit comments

Comments
 (0)