Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "catalog list" command #178

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
## Ignore Antora output
_antora

## Ignore commodore output
catalog
compiled
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
26 changes: 7 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)


Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 13 additions & 1 deletion commodore/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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}')
17 changes: 17 additions & 0 deletions commodore/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
37 changes: 9 additions & 28 deletions commodore/component-template/{{ cookiecutter.slug }}/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -52,23 +38,18 @@ 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

.PHONY: 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) $<
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down

This file was deleted.

4 changes: 4 additions & 0 deletions docs/modules/ROOT/pages/reference/cli.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand Down
31 changes: 0 additions & 31 deletions playbook.yml

This file was deleted.