diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 804a5433..8e37815f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,9 +44,7 @@ jobs: steps: - uses: actions/checkout@v1 - name: Check Docs - run: make check - - name: Compile Docs - run: make docs + run: make docs-vale build: needs: - lints diff --git a/.gitignore b/.gitignore index e7a5ceed..84b31c43 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,3 @@ -## Ignore Antora output -_antora - ## Ignore commodore output catalog compiled diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c10e606..0d1606ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,12 +9,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added +* New `commodore cluster list` command ([#135]) * Validation of component slug ([#153]) * `component compile` now applies postprocessing filters ([#154]) * Option to disable postprocessing filters ([#155]) * `--interactive` option to prompt push confirmation ([#157]) * Extend component template with docs setup ([#158]) * Build Helm bindings for native Helm dependencies ([#161]) +* Replaced playbook.yml with custom command ([#165]) ### Changed diff --git a/Makefile b/Makefile index 189aef9e..92efb595 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,10 @@ MAKEFLAGS += -j4 -pages := $(shell find docs -type f -name '*.adoc') -web_dir := ./_antora - docker_cmd ?= docker docker_opts ?= --rm --tty --user "$$(id -u)" -antora_cmd ?= $(docker_cmd) run $(docker_opts) --volume "$${PWD}":/antora vshn/antora:2.3.0 -antora_opts ?= --cache-dir=.cache/antora - -vale_cmd ?= $(docker_cmd) run $(docker_opts) --volume "$${PWD}"/docs/modules/ROOT/pages:/pages vshn/vale:2.1.1 --minAlertLevel=error /pages +vale_cmd ?= $(docker_cmd) run $(docker_opts) --volume "$${PWD}"/docs/modules/ROOT/pages:/pages vshn/vale:2.1.1 --minAlertLevel=error /pages +antora_preview_cmd ?= $(docker_cmd) run --rm --publish 2020:2020 --volume "${PWD}":/antora vshn/antora-preview:2.3.3 --style=syn --antora=docs UNAME := $(shell uname) ifeq ($(UNAME), Linux) @@ -24,19 +19,12 @@ endif .PHONY: all all: docs -# This will clean the Antora Artifacts, not the npm artifacts -.PHONY: clean -clean: - rm -rf $(web_dir) - -.PHONY: docs -docs: $(web_dir)/index.html - -$(web_dir)/index.html: playbook.yml $(pages) - $(antora_cmd) $(antora_opts) $< +.PHONY: docs-serve +docs-serve: + $(antora_preview_cmd) -.PHONY: check -check: +.PHONY: docs-vale +docs-vale: $(vale_cmd) diff --git a/README.md b/README.md index 5a1edb40..6e33f1f3 100644 --- a/README.md +++ b/README.md @@ -158,9 +158,9 @@ Documentation for this component is written using [Asciidoc][asciidoc] and [Anto It is located in the [docs/](docs) folder. The [Divio documentation structure](https://documentation.divio.com/) is used to organize its content. -Run the `make docs` command in the `docs` subfolder to generate the Antora documentation website locally. The website will be available at the `_antora/index.html` file. +Run the `make docs-serve` command in the root of the project, and then browse to http://localhost:2020 to see a preview of the current state of the documentation. -After writing the documentation, please use the `make check` command and correct any warnings raised by the tool. +After writing the documentation, please use the `make docs-vale` command and correct any warnings raised by the tool. ## Contributing and license diff --git a/commodore/catalog.py b/commodore/catalog.py index 6bba406d..ed3c568f 100644 --- a/commodore/catalog.py +++ b/commodore/catalog.py @@ -3,7 +3,10 @@ import click from . import git -from .helpers import rm_tree_contents +from .helpers import ( + rm_tree_contents, + lieutenant_query +) def fetch_customer_catalog(config, repoinfo): @@ -101,3 +104,12 @@ def update_catalog(cfg, target_name, repo): click.echo(' > Skipping commit+push to catalog in local mode...') else: click.echo(' > Skipping commit+push to catalog...') + + +def catalog_list(cfg): + clusters = lieutenant_query(cfg.api_url, cfg.api_token, 'clusters', '') + for cluster in clusters: + display_name = cluster['displayName'] + catalog_id = cluster['id'] + click.secho(catalog_id, nl=False, bold=True) + click.echo(f' - {display_name}') diff --git a/commodore/cli.py b/commodore/cli.py index 879fd272..5cad8045 100644 --- a/commodore/cli.py +++ b/commodore/cli.py @@ -3,6 +3,7 @@ from dotenv import load_dotenv from importlib_metadata import version from commodore import __git_version__ +from .catalog import catalog_list from .config import Config from .helpers import clean_working_tree from .compile import compile as _compile @@ -84,6 +85,22 @@ def compile_catalog(config: Config, cluster, api_url, api_token, _compile(config, cluster) +@catalog.command(name='list', short_help='List available catalog cluster IDs') +@click.option('--api-url', + envvar='COMMODORE_API_URL', + help='Lieutenant API URL.', metavar='URL') +@click.option('--api-token', + envvar='COMMODORE_API_TOKEN', + help='Lieutenant API token.', metavar='TOKEN') +@verbosity +@pass_config +def clusters_list_command(config: Config, api_url, api_token, verbose): + config.update_verbosity(verbose) + config.api_url = api_url + config.api_token = api_token + catalog_list(config) + + @commodore.group(short_help='Interact with components.') @verbosity @pass_config diff --git a/commodore/component-template/{{ cookiecutter.slug }}/Makefile b/commodore/component-template/{{ cookiecutter.slug }}/Makefile index b4b29efa..b08bee2e 100644 --- a/commodore/component-template/{{ cookiecutter.slug }}/Makefile +++ b/commodore/component-template/{{ cookiecutter.slug }}/Makefile @@ -22,27 +22,13 @@ YAMLLINT_DOCKER ?= $(DOCKER_CMD) $(DOCKER_ARGS) $(YAMLLINT_IMAGE) VALE_CMD ?= $(DOCKER_CMD) $(DOCKER_ARGS) --volume "$${PWD}"/docs/modules:/pages vshn/vale:2.1.1 VALE_ARGS ?= --minAlertLevel=error --config=/pages/ROOT/pages/.vale.ini /pages -PAGES := $(shell find docs -type f -name '*.adoc') -WEB_DIR := ./_public -ANTORA_CMD ?= $(DOCKER_CMD) $(DOCKER_ARGS) --volume "$${PWD}":/antora vshn/antora:2.3.0 -ANTORA_ARGS ?= --cache-dir=.cache/antora - -UNAME := $(shell uname) -ifeq ($(UNAME), Linux) - OS = linux-x64 - OPEN = xdg-open -endif -ifeq ($(UNAME), Darwin) - OS = darwin-x64 - OPEN = open -endif - +ANTORA_PREVIEW_CMD ?= $(DOCKER_CMD) run --rm --publish 2020:2020 --volume "${PWD}":/antora vshn/antora-preview:2.3.3 --style=syn --antora=docs .PHONY: all -all: lint docs open +all: lint open .PHONY: lint -lint: lint_jsonnet lint_yaml lint_adoc +lint: lint_jsonnet lint_yaml docs-vale .PHONY: lint_jsonnet lint_jsonnet: $(JSONNET_FILES) @@ -52,10 +38,6 @@ lint_jsonnet: $(JSONNET_FILES) lint_yaml: $(YAML_FILES) $(YAMLLINT_DOCKER) -f parsable -c $(YAMLLINT_CONFIG) $(YAMLLINT_ARGS) -- $? -.PHONY: lint_adoc -lint_adoc: - $(VALE_CMD) $(VALE_ARGS) - .PHONY: format format: format_jsonnet @@ -63,12 +45,11 @@ format: format_jsonnet format_jsonnet: $(JSONNET_FILES) $(JSONNET_DOCKER) $(JSONNETFMT_ARGS) -- $? -.PHONY: open -open: $(WEB_DIR)/index.html - -$(OPEN) $< +.PHONY: docs-serve +docs-serve: + $(ANTORA_PREVIEW_CMD) -.PHONY: docs -docs: $(WEB_DIR)/index.html +.PHONY: docs-vale +docs-vale: + $(VALE_CMD) $(VALE_ARGS) -$(WEB_DIR)/index.html: playbook.yml $(PAGES) - $(ANTORA_CMD) $(ANTORA_ARGS) $< diff --git a/commodore/component-template/{{ cookiecutter.slug }}/README.md b/commodore/component-template/{{ cookiecutter.slug }}/README.md index 2b35cb38..a351fccd 100644 --- a/commodore/component-template/{{ cookiecutter.slug }}/README.md +++ b/commodore/component-template/{{ cookiecutter.slug }}/README.md @@ -11,6 +11,10 @@ Documentation for this component is written using [Asciidoc][asciidoc] and [Anto It is located in the [docs/](docs) folder. The [Divio documentation structure](https://documentation.divio.com/) is used to organize its content. +Run the `make docs-serve` command in the root of the project, and then browse to http://localhost:2020 to see a preview of the current state of the documentation. + +After writing the documentation, please use the `make docs-vale` command and correct any warnings raised by the tool. + ## Contributing and license This library is licensed under [BSD-3-Clause](LICENSE). diff --git a/commodore/component-template/{{ cookiecutter.slug }}/playbook.yml b/commodore/component-template/{{ cookiecutter.slug }}/playbook.yml deleted file mode 100644 index 2ba34f32..00000000 --- a/commodore/component-template/{{ cookiecutter.slug }}/playbook.yml +++ /dev/null @@ -1,36 +0,0 @@ -site: - title: "{{ cookiecutter.name }}" - url: https://syn.tools/ - start_page: {{ cookiecutter.slug }}::index.adoc - robots: disallow -content: - sources: - - url: . - branches: HEAD - start_path: docs - edit_url: '{{ cookiecutter.github_url }}/edit/master/{path}' -ui: - bundle: - url: https://github.com/vshn/antora-ui-default/releases/download/1.6/ui-bundle.zip - snapshot: false -asciidoc: - attributes: - toc: 'auto' - toc-title: '' - toclevels: 2 - hide-uri-scheme: '' - experimental: '' - stem: '' - icons: font - kroki-server-url: https://vshn-kroki.appuioapp.ch - kroki-fetch-diagram: '' - extensions: - - asciidoctor-kroki -output: - destinations: - - provider: fs - path: ./_public - clean: true - - provider: archive - path: ./_archive/site.zip - clean: true diff --git a/docs/modules/ROOT/pages/reference/cli.adoc b/docs/modules/ROOT/pages/reference/cli.adoc index 81127787..aa82b471 100644 --- a/docs/modules/ROOT/pages/reference/cli.adoc +++ b/docs/modules/ROOT/pages/reference/cli.adoc @@ -92,6 +92,10 @@ See also xref:local-mode.adoc[local mode documentation]. *--help*:: Show catalog clean usage and options then exit. +== Catalog Clean + +This command doesn't have any command line options. + == Component Compile *-f, --values* FILE:: diff --git a/playbook.yml b/playbook.yml deleted file mode 100644 index 1e59031d..00000000 --- a/playbook.yml +++ /dev/null @@ -1,31 +0,0 @@ -site: - title: "PREVIEW Commodore Documentation" - url: http://localhost/ - start_page: commodore::index.adoc -content: - sources: - - url: . # The current folder is a git repo - branches: HEAD # "HEAD" uses whichever branch is currently checked out - start_path: docs - edit_url: 'https://github.com/projectsyn/commodore/edit/master/{path}' -ui: - bundle: - url: https://github.com/projectsyn/antora-ui-default/releases/download/1.3/ui-bundle.zip - snapshot: false -asciidoc: - attributes: - toc: 'auto' - toc-title: '' - toclevels: 2 - hide-uri-scheme: '' - experimental: '' - stem: '' - icons: font - kroki-server-url: https://vshn-kroki.appuioapp.ch - extensions: - - asciidoctor-kroki -output: - destinations: - - provider: fs - path: ./_antora - clean: true