コード例 #1
0
ファイル: gen_kube_docs.go プロジェクト: Clarifai/kubernetes
func main() {
	// use os.Args instead of "flags" because "flags" will mess up the man pages!
	path := ""
	module := ""
	if len(os.Args) == 3 {
		path = os.Args[1]
		module = os.Args[2]
	} else {
		fmt.Fprintf(os.Stderr, "usage: %s [output directory] [module] \n", os.Args[0])
		os.Exit(1)
	}

	outDir, err := genutils.OutDir(path)
	if err != nil {
		fmt.Fprintf(os.Stderr, "failed to get output directory: %v\n", err)
		os.Exit(1)
	}

	switch module {
	case "kube-apiserver":
		// generate docs for kube-apiserver
		apiserver := apiservapp.NewAPIServerCommand()
		doc.GenMarkdownTree(apiserver, outDir)
	case "kube-controller-manager":
		// generate docs for kube-controller-manager
		controllermanager := cmapp.NewControllerManagerCommand()
		doc.GenMarkdownTree(controllermanager, outDir)
	case "kube-proxy":
		// generate docs for kube-proxy
		proxy := proxyapp.NewProxyCommand()
		doc.GenMarkdownTree(proxy, outDir)
	case "kube-scheduler":
		// generate docs for kube-scheduler
		scheduler := schapp.NewSchedulerCommand()
		doc.GenMarkdownTree(scheduler, outDir)
	case "kubelet":
		// generate docs for kubelet
		kubelet := kubeletapp.NewKubeletCommand()
		doc.GenMarkdownTree(kubelet, outDir)
	default:
		fmt.Fprintf(os.Stderr, "Module %s is not supported", module)
		os.Exit(1)
	}
}
コード例 #2
0
func main() {
	// use os.Args instead of "flags" because "flags" will mess up the man pages!
	path := "docs/man/man1"
	module := ""
	if len(os.Args) == 3 {
		path = os.Args[1]
		module = os.Args[2]
	} else {
		fmt.Fprintf(os.Stderr, "usage: %s [output directory] [module] \n", os.Args[0])
		os.Exit(1)
	}

	outDir, err := genutils.OutDir(path)
	if err != nil {
		fmt.Fprintf(os.Stderr, "failed to get output directory: %v\n", err)
		os.Exit(1)
	}

	// Set environment variables used by command so the output is consistent,
	// regardless of where we run.
	os.Setenv("HOME", "/home/username")

	switch module {
	case "kube-apiserver":
		// generate manpage for kube-apiserver
		apiserver := apiservapp.NewAPIServerCommand()
		genMarkdown(apiserver, "", outDir)
		for _, c := range apiserver.Commands() {
			genMarkdown(c, "kube-apiserver", outDir)
		}
	case "kube-controller-manager":
		// generate manpage for kube-controller-manager
		controllermanager := cmapp.NewControllerManagerCommand()
		genMarkdown(controllermanager, "", outDir)
		for _, c := range controllermanager.Commands() {
			genMarkdown(c, "kube-controller-manager", outDir)
		}
	case "kube-proxy":
		// generate manpage for kube-proxy
		proxy := proxyapp.NewProxyCommand()
		genMarkdown(proxy, "", outDir)
		for _, c := range proxy.Commands() {
			genMarkdown(c, "kube-proxy", outDir)
		}
	case "kube-scheduler":
		// generate manpage for kube-scheduler
		scheduler := schapp.NewSchedulerCommand()
		genMarkdown(scheduler, "", outDir)
		for _, c := range scheduler.Commands() {
			genMarkdown(c, "kube-scheduler", outDir)
		}
	case "kubelet":
		// generate manpage for kubelet
		kubelet := kubeletapp.NewKubeletCommand()
		genMarkdown(kubelet, "", outDir)
		for _, c := range kubelet.Commands() {
			genMarkdown(c, "kubelet", outDir)
		}
	case "kubectl":
		// generate manpage for kubectl
		// TODO os.Stdin should really be something like ioutil.Discard, but a Reader
		kubectl := kubectlcmd.NewKubectlCommand(kubectlcmdutil.NewFactory(nil), os.Stdin, ioutil.Discard, ioutil.Discard)
		genMarkdown(kubectl, "", outDir)
		for _, c := range kubectl.Commands() {
			genMarkdown(c, "kubectl", outDir)
		}
	default:
		fmt.Fprintf(os.Stderr, "Module %s is not supported", module)
		os.Exit(1)
	}
}