Skip to content

Commit 4075428

Browse files
committed
Make running brodocs optional so tests don't need docker to run
1 parent ac35586 commit 4075428

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

cmd/kubebuilder/docs/docs.go

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,15 @@ var generateConfig bool
6161
var cleanup, verbose bool
6262
var outputDir string
6363
var copyright string
64+
var brodocs bool
6465

6566
func AddDocs(cmd *cobra.Command) {
6667
docsCmd.Flags().BoolVar(&cleanup, "cleanup", true, "If true, cleanup intermediary files")
6768
docsCmd.Flags().BoolVar(&verbose, "verbose", true, "If true, use verbose output")
6869
docsCmd.Flags().BoolVar(&generateConfig, "generate-config", true, "If true, generate the docs/reference/config.yaml.")
6970
docsCmd.Flags().StringVar(&outputDir, "output-dir", filepath.Join("docs", "reference"), "Build docs into this directory")
7071
docsCmd.Flags().StringVar(&copyright, "copyright", filepath.Join("hack", "boilerplate.go.txt"), "Location of copyright boilerplate file.")
72+
docsCmd.Flags().BoolVar(&brodocs, "brodocs", true, "Run brodocs to generate html.")
7173
docsCmd.Flags().StringVar(&generatecmd.Docscopyright, "docs-copyright", "<a href=\"https://github.com/kubernetes/kubernetes\">Copyright 2018 The Kubernetes Authors.</a>", "html for the copyright text on the docs")
7274
docsCmd.Flags().StringVar(&generatecmd.Docstitle, "title", "API Reference", "title of the docs page")
7375
cmd.AddCommand(docsCmd)
@@ -154,25 +156,26 @@ func RunDocs(cmd *cobra.Command, args []string) {
154156
generatecmd.Codegenerators = []string{"apidocs"}
155157
generatecmd.RunGenerate(cmd, args)
156158

157-
// Run the docker command to build the docs
158-
c = exec.Command("docker", "run",
159-
"-v", fmt.Sprintf("%s:%s", filepath.Join(wd, outputDir, "includes"), "/source"),
160-
"-v", fmt.Sprintf("%s:%s", filepath.Join(wd, outputDir, "build"), "/build"),
161-
"-v", fmt.Sprintf("%s:%s", filepath.Join(wd, outputDir, "build"), "/build"),
162-
"-v", fmt.Sprintf("%s:%s", filepath.Join(wd, outputDir), "/manifest"),
163-
"gcr.io/kubebuilder/brodocs",
164-
)
165-
if verbose {
166-
log.Println(strings.Join(c.Args, " "))
167-
c.Stderr = os.Stderr
168-
c.Stdout = os.Stdout
169-
}
170-
err = c.Run()
171-
if err != nil {
172-
log.Fatalf("error: %v\n", err)
159+
if brodocs {
160+
// Run the docker command to build the docs
161+
c = exec.Command("docker", "run",
162+
"-v", fmt.Sprintf("%s:%s", filepath.Join(wd, outputDir, "includes"), "/source"),
163+
"-v", fmt.Sprintf("%s:%s", filepath.Join(wd, outputDir, "build"), "/build"),
164+
"-v", fmt.Sprintf("%s:%s", filepath.Join(wd, outputDir, "build"), "/build"),
165+
"-v", fmt.Sprintf("%s:%s", filepath.Join(wd, outputDir), "/manifest"),
166+
"gcr.io/kubebuilder/brodocs",
167+
)
168+
if verbose {
169+
log.Println(strings.Join(c.Args, " "))
170+
c.Stderr = os.Stderr
171+
c.Stdout = os.Stdout
172+
}
173+
err = c.Run()
174+
if err != nil {
175+
log.Fatalf("error: %v\n", err)
176+
}
177+
fmt.Printf("Reference docs written to %s\n", filepath.Join(outputDir, "build", "index.html"))
173178
}
174-
175-
fmt.Printf("Reference docs written to %s\n", filepath.Join(outputDir, "build", "index.html"))
176179
}
177180

178181
// Scaffolding file for writing the openapi generated structs to a swagger.json file

0 commit comments

Comments
 (0)