...
1
16
17 package main
18
19 import (
20 "bytes"
21 "fmt"
22 "io"
23 "os"
24
25 "github.com/spf13/cobra/doc"
26 "k8s.io/cli-runtime/pkg/genericiooptions"
27 "k8s.io/kubectl/pkg/cmd"
28 "k8s.io/kubernetes/cmd/genutils"
29 )
30
31 func main() {
32
33 path := "docs/"
34 if len(os.Args) == 2 {
35 path = os.Args[1]
36 } else if len(os.Args) > 2 {
37 fmt.Fprintf(os.Stderr, "usage: %s [output directory]\n", os.Args[0])
38 os.Exit(1)
39 }
40
41 outDir, err := genutils.OutDir(path)
42 if err != nil {
43 fmt.Fprintf(os.Stderr, "failed to get output directory: %v\n", err)
44 os.Exit(1)
45 }
46
47
48
49 os.Setenv("HOME", "/home/username")
50 kubectl := cmd.NewKubectlCommand(cmd.KubectlOptions{IOStreams: genericiooptions.IOStreams{In: bytes.NewReader(nil), Out: io.Discard, ErrOut: io.Discard}})
51 doc.GenMarkdownTree(kubectl, outDir)
52 }
53
View as plain text