Skip to content

Commit c16eae9

Browse files
authored
Added AsciiDoc k3kcli automation (#597)
* adding scripts for asciidoc cli generation * fix small typos to align to existing docs * added pandoc * pandoc check
1 parent fc6bced commit c16eae9

27 files changed

+411
-44
lines changed

.github/workflows/test-e2e.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ jobs:
2020
with:
2121
go-version-file: go.mod
2222

23+
- name: Install Pandoc
24+
run: sudo apt-get install pandoc
25+
2326
- name: Validate
2427
run: make validate
28+
2529
tests-e2e:
2630
runs-on: ubuntu-latest
2731
needs: validate

.github/workflows/test.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ jobs:
3737
with:
3838
go-version-file: go.mod
3939

40+
- name: Install Pandoc
41+
run: sudo apt-get install pandoc
42+
4043
- name: Validate
4144
run: make validate
4245

Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ CRD_REF_DOCS_VER ?= v0.1.0
1515
GOLANGCI_LINT ?= go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
1616
GINKGO ?= go run github.com/onsi/ginkgo/v2/ginkgo@$(GINKGO_VERSION)
1717
CRD_REF_DOCS := go run github.com/elastic/crd-ref-docs@$(CRD_REF_DOCS_VER)
18+
PANDOC := $(shell which pandoc 2> /dev/null)
1819

1920
ENVTEST ?= go run sigs.k8s.io/controller-runtime/tools/setup-envtest@$(ENVTEST_VERSION)
2021
ENVTEST_DIR ?= $(shell pwd)/.envtest
@@ -83,12 +84,21 @@ generate: ## Generate the CRDs specs
8384
go generate ./...
8485

8586
.PHONY: docs
86-
docs: ## Build the CRDs and CLI docs
87+
docs: docs-crds docs-cli ## Build the CRDs and CLI docs
88+
89+
.PHONY: docs-crds
90+
docs-crds: ## Build the CRDs docs
8791
$(CRD_REF_DOCS) --config=./docs/crds/config.yaml \
8892
--renderer=markdown \
8993
--source-path=./pkg/apis/k3k.io/v1beta1 \
9094
--output-path=./docs/crds/crd-docs.md
91-
@go run ./docs/cli/genclidoc.go
95+
96+
.PHONY: docs-cli
97+
docs-cli: ## Build the CLI docs
98+
ifeq (, $(PANDOC))
99+
$(error "pandoc not found in PATH.")
100+
endif
101+
@./scripts/generate-cli-docs
92102

93103
.PHONY: lint
94104
lint: ## Find any linting issues in the project

cli/cmds/cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
func NewClusterCmd(appCtx *AppContext) *cobra.Command {
88
cmd := &cobra.Command{
99
Use: "cluster",
10-
Short: "cluster command",
10+
Short: "K3k cluster command.",
1111
}
1212

1313
cmd.AddCommand(

cli/cmds/cluster_create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func NewClusterCreateCmd(appCtx *AppContext) *cobra.Command {
5858

5959
cmd := &cobra.Command{
6060
Use: "create",
61-
Short: "Create new cluster",
61+
Short: "Create a new cluster.",
6262
Example: "k3kcli cluster create [command options] NAME",
6363
PreRunE: func(cmd *cobra.Command, args []string) error {
6464
return validateCreateConfig(createConfig)

cli/cmds/cluster_delete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var keepData bool
2424
func NewClusterDeleteCmd(appCtx *AppContext) *cobra.Command {
2525
cmd := &cobra.Command{
2626
Use: "delete",
27-
Short: "Delete an existing cluster",
27+
Short: "Delete an existing cluster.",
2828
Example: "k3kcli cluster delete [command options] NAME",
2929
RunE: delete(appCtx),
3030
Args: cobra.ExactArgs(1),

cli/cmds/cluster_list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
func NewClusterListCmd(appCtx *AppContext) *cobra.Command {
1717
cmd := &cobra.Command{
1818
Use: "list",
19-
Short: "List all the existing cluster",
19+
Short: "List all existing clusters.",
2020
Example: "k3kcli cluster list [command options]",
2121
RunE: list(appCtx),
2222
Args: cobra.NoArgs,

cli/cmds/kubeconfig.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type GenerateKubeconfigConfig struct {
3737
func NewKubeconfigCmd(appCtx *AppContext) *cobra.Command {
3838
cmd := &cobra.Command{
3939
Use: "kubeconfig",
40-
Short: "Manage kubeconfig for clusters",
40+
Short: "Manage kubeconfig for clusters.",
4141
}
4242

4343
cmd.AddCommand(
@@ -52,7 +52,7 @@ func NewKubeconfigGenerateCmd(appCtx *AppContext) *cobra.Command {
5252

5353
cmd := &cobra.Command{
5454
Use: "generate",
55-
Short: "Generate kubeconfig for clusters",
55+
Short: "Generate kubeconfig for clusters.",
5656
RunE: generate(appCtx, cfg),
5757
Args: cobra.NoArgs,
5858
}

cli/cmds/policy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
func NewPolicyCmd(appCtx *AppContext) *cobra.Command {
88
cmd := &cobra.Command{
99
Use: "policy",
10-
Short: "policy command",
10+
Short: "K3k policy command.",
1111
}
1212

1313
cmd.AddCommand(

cli/cmds/policy_create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func NewPolicyCreateCmd(appCtx *AppContext) *cobra.Command {
3030

3131
cmd := &cobra.Command{
3232
Use: "create",
33-
Short: "Create new policy",
33+
Short: "Create a new policy.",
3434
Example: "k3kcli policy create [command options] NAME",
3535
PreRunE: func(cmd *cobra.Command, args []string) error {
3636
switch config.mode {

0 commit comments

Comments
 (0)