From 34f4eb82149ee1080bc7bf9d6ad86698e42861bb Mon Sep 17 00:00:00 2001
From: Adrian Kosmaczewski <adrian@vshn.ch>
Date: Wed, 2 Sep 2020 13:30:04 +0200
Subject: [PATCH 1/9] Replaced playbook.yml with a custom command

---
 .github/workflows/test.yml |  2 --
 .gitignore                 |  3 ---
 Makefile                   | 12 ++++--------
 playbook.yml               | 31 -------------------------------
 4 files changed, 4 insertions(+), 44 deletions(-)
 delete mode 100644 playbook.yml

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 804a5433..362bfaa9 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -45,8 +45,6 @@ jobs:
     - uses: actions/checkout@v1
     - name: Check Docs
       run: make check
-    - name: Compile Docs
-      run: make docs
   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/Makefile b/Makefile
index 189aef9e..abe7af4c 100644
--- a/Makefile
+++ b/Makefile
@@ -6,10 +6,8 @@ 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)
@@ -30,10 +28,8 @@ clean:
 	rm -rf $(web_dir)
 
 .PHONY: docs
-docs:    $(web_dir)/index.html
-
-$(web_dir)/index.html: playbook.yml $(pages)
-	$(antora_cmd) $(antora_opts) $<
+docs:
+	$(antora_preview_cmd)
 
 .PHONY: check
 check:
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

From e1183a15a485243a3aaf85f256af2bafb68a9e23 Mon Sep 17 00:00:00 2001
From: Adrian Kosmaczewski <adrian@vshn.ch>
Date: Wed, 2 Sep 2020 13:34:37 +0200
Subject: [PATCH 2/9] Updated changelog and readme

---
 CHANGELOG.md | 1 +
 README.md    | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4c10e606..c5e76acc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
 * `--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/README.md b/README.md
index 5a1edb40..9a06c2c9 100644
--- a/README.md
+++ b/README.md
@@ -158,7 +158,7 @@ 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` 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.
 

From 7a442b953f4174a9e55a2ad8193bd56ea45989a4 Mon Sep 17 00:00:00 2001
From: Adrian Kosmaczewski <adrian@vshn.ch>
Date: Wed, 2 Sep 2020 13:37:17 +0200
Subject: [PATCH 3/9] Updated command template

---
 .../{{ cookiecutter.slug }}/Makefile          | 23 ++++---------------
 1 file changed, 4 insertions(+), 19 deletions(-)

diff --git a/commodore/component-template/{{ cookiecutter.slug }}/Makefile b/commodore/component-template/{{ cookiecutter.slug }}/Makefile
index b4b29efa..0ea5cb79 100644
--- a/commodore/component-template/{{ cookiecutter.slug }}/Makefile	
+++ b/commodore/component-template/{{ cookiecutter.slug }}/Makefile	
@@ -22,24 +22,10 @@ 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
@@ -68,7 +54,6 @@ open: $(WEB_DIR)/index.html
 	-$(OPEN) $<
 
 .PHONY: docs
-docs:    $(WEB_DIR)/index.html
+docs:
+	$(ANTORA_PREVIEW_CMD)
 
-$(WEB_DIR)/index.html: playbook.yml $(PAGES)
-	$(ANTORA_CMD) $(ANTORA_ARGS) $<

From 7905519d0b6ecccff79ed7d3c99a528d40ccfc6f Mon Sep 17 00:00:00 2001
From: Adrian Kosmaczewski <adrian@vshn.ch>
Date: Wed, 2 Sep 2020 15:15:59 +0200
Subject: [PATCH 4/9] Renamed Makefile targets for uniformity with other
 projects

---
 Makefile | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/Makefile b/Makefile
index abe7af4c..92efb595 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,5 @@
 MAKEFLAGS += -j4
 
-pages   := $(shell find docs -type f -name '*.adoc')
-web_dir := ./_antora
-
 docker_cmd  ?= docker
 docker_opts ?= --rm --tty --user "$$(id -u)"
 
@@ -22,17 +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:
+.PHONY: docs-serve
+docs-serve:
 	$(antora_preview_cmd)
 
-.PHONY: check
-check:
+.PHONY: docs-vale
+docs-vale:
 	$(vale_cmd)
 
 

From e175f66b60bf1963f1d8cb25f71d7ef72b9e66b4 Mon Sep 17 00:00:00 2001
From: Adrian Kosmaczewski <adrian@vshn.ch>
Date: Wed, 2 Sep 2020 15:18:43 +0200
Subject: [PATCH 5/9] Renamed Makefile targets for uniformity with other
 projects

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 9a06c2c9..6c974a62 100644
--- a/README.md
+++ b/README.md
@@ -160,7 +160,7 @@ The [Divio documentation structure](https://documentation.divio.com/) is used to
 
 Run the `make docs` 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
 

From 86ccf8fc7bedfb0ce0074c9a0286c8a0cb1f4198 Mon Sep 17 00:00:00 2001
From: Adrian Kosmaczewski <adrian@vshn.ch>
Date: Wed, 2 Sep 2020 15:19:04 +0200
Subject: [PATCH 6/9] Renamed Makefile targets for uniformity with other
 projects

---
 .github/workflows/test.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 362bfaa9..8e37815f 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -44,7 +44,7 @@ jobs:
     steps:
     - uses: actions/checkout@v1
     - name: Check Docs
-      run: make check
+      run: make docs-vale
   build:
     needs:
     - lints

From 93570ac71da6d900b69d64d601058d798caaf661 Mon Sep 17 00:00:00 2001
From: Adrian Kosmaczewski <adrian@vshn.ch>
Date: Wed, 2 Sep 2020 15:21:45 +0200
Subject: [PATCH 7/9] Renamed Makefile targets for uniformity with other
 projects

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 6c974a62..6e33f1f3 100644
--- a/README.md
+++ b/README.md
@@ -158,7 +158,7 @@ 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 root of the project, and then browse to http://localhost:2020 to see a preview of the current state of the documentation.
+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.
 

From aece5a9dc3023c9d93bd1d424481c75be6ce8b04 Mon Sep 17 00:00:00 2001
From: Adrian Kosmaczewski <adrian@vshn.ch>
Date: Wed, 2 Sep 2020 15:29:39 +0200
Subject: [PATCH 8/9] Renamed Makefile targets for uniformity with other
 projects

---
 .../{{ cookiecutter.slug }}/Makefile          | 18 ++++------
 .../{{ cookiecutter.slug }}/README.md         |  4 +++
 .../{{ cookiecutter.slug }}/playbook.yml      | 36 -------------------
 3 files changed, 11 insertions(+), 47 deletions(-)
 delete mode 100644 commodore/component-template/{{ cookiecutter.slug }}/playbook.yml

diff --git a/commodore/component-template/{{ cookiecutter.slug }}/Makefile b/commodore/component-template/{{ cookiecutter.slug }}/Makefile
index 0ea5cb79..b08bee2e 100644
--- a/commodore/component-template/{{ cookiecutter.slug }}/Makefile	
+++ b/commodore/component-template/{{ cookiecutter.slug }}/Makefile	
@@ -28,7 +28,7 @@ ANTORA_PREVIEW_CMD ?= $(DOCKER_CMD) run --rm --publish 2020:2020 --volume "${PWD
 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)
@@ -38,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
 
@@ -49,11 +45,11 @@ format: format_jsonnet
 format_jsonnet: $(JSONNET_FILES)
 	$(JSONNET_DOCKER) $(JSONNETFMT_ARGS) -- $?
 
-.PHONY: open
-open: $(WEB_DIR)/index.html
-	-$(OPEN) $<
-
-.PHONY: docs
-docs:
+.PHONY: docs-serve
+docs-serve:
 	$(ANTORA_PREVIEW_CMD)
 
+.PHONY: docs-vale
+docs-vale:
+	$(VALE_CMD) $(VALE_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

From 807fd825786a61b2179921fee7c963d1f0676df3 Mon Sep 17 00:00:00 2001
From: Chris Glass <christopher.glass@vshn.net>
Date: Mon, 14 Sep 2020 10:10:30 +0200
Subject: [PATCH 9/9] Add "catalog list" command

This commit adds the "commodore catalog list" command that will query
lieutenant for a list of available cluster IDs (and descriptions), and
display the information on stdout.
---
 CHANGELOG.md                               |  1 +
 commodore/catalog.py                       | 14 +++++++++++++-
 commodore/cli.py                           | 17 +++++++++++++++++
 docs/modules/ROOT/pages/reference/cli.adoc |  4 ++++
 4 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index c5e76acc..0d1606ad 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@ 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])
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/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::