Skip to content

Commit 447b85c

Browse files
florentianayuwonoerineconweiiwang01
authored
docs: populate charm documentation (#6)
* feat: set up charm skeleton * feat: add more charm hooks * test: add unit test cases * docs: update readme and tox lint * fix tox problems * fix lint error * test: add integration test * fix charmcraft.yaml * docs: update charm docs * docs: update contributing and index * docs: add actions, config, integrate * add documentation workflows * fix capitalisation Co-authored-by: Erin Conley <erin.conley@canonical.com> * Apply suggestions from code review Co-authored-by: Erin Conley <erin.conley@canonical.com> * apply suggestions * fix vale complaints * Apply suggestions from code review Co-authored-by: Erin Conley <erin.conley@canonical.com> * apply suggestion * Update README.md Co-authored-by: Erin Conley <erin.conley@canonical.com> * Apply suggestions from code review Co-authored-by: Erin Conley <erin.conley@canonical.com> * update docs * fix vale * Apply suggestions from code review Co-authored-by: Erin Conley <erin.conley@canonical.com> * remove section * update badges * Update docs/how-to/configure.md Co-authored-by: Weii Wang <weii.wang@canonical.com> * fix description --------- Co-authored-by: erinecon <erin.conley@canonical.com> Co-authored-by: Weii Wang <weii.wang@canonical.com>
1 parent c6bafe2 commit 447b85c

20 files changed

Lines changed: 608 additions & 218 deletions

File tree

.github/workflows/comment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ jobs:
1010
comment-on-pr:
1111
uses: canonical/operator-workflows/.github/workflows/comment.yaml@main
1212
secrets: inherit
13+

.github/workflows/docs.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Documentation
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
8+
jobs:
9+
docs-checks:
10+
uses: canonical/operator-workflows/.github/workflows/docs.yaml@main
11+
secrets: inherit

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,16 @@ __pycache__/
1111
*.egg-info/
1212
*/*.rock
1313
terraform/tests/.terraform
14+
15+
# BEGIN VALE WORKFLOW IGNORE
16+
.vale/styles/*
17+
!.vale/styles/local
18+
!.vale/styles/config/
19+
20+
.vale/styles/config/*
21+
!.vale/styles/config/vocabularies/
22+
23+
.vale/styles/config/vocabularies/*
24+
!.vale/styles/config/vocabularies/local
25+
# END VALE WORKFLOW IGNORE
26+

.vale.ini

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
; Copyright 2025 Canonical Ltd.
2+
; See LICENSE file for licensing details.
3+
4+
StylesPath = .vale/styles
5+
6+
Packages = https://github.com/canonical/platform-engineering-vale-package/releases/download/latest/pfe-vale.zip
7+
8+
Vocab = PFE, local
9+
10+
[*]
11+
BasedOnStyles = PFE
12+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
nftables
2+
aproxy
3+
allowlists

CONTRIBUTING.md

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
<!-- Remember to update this file for your charm -- replace <charm-name> with the appropriate name. -->
2-
31
# Contributing
42

5-
This document explains the processes and practices recommended for contributing enhancements to the <charm-name> charm.
3+
This document explains the processes and practices recommended for contributing enhancements to the aproxy charm.
64

75
## Overview
86

97
- Generally, before developing enhancements to this charm, you should consider [opening an issue
10-
](link to issues page) explaining your use case.
8+
](https://github.com/canonical/aproxy-operator/issues) explaining your use case.
119
- If you would like to chat with us about your use-cases or proposed implementation, you can reach
1210
us at [Canonical Matrix public channel](https://matrix.to/#/#charmhub-charmdev:ubuntu.com)
1311
or [Discourse](https://discourse.charmhub.io/).
@@ -29,10 +27,8 @@ When contributing, you must abide by the
2927

3028
## Releases and versions
3129

32-
This project uses [semantic versioning](https://semver.org/).
33-
3430
Please ensure that any new feature, fix, or significant change is documented by
35-
adding an entry to the [CHANGELOG.md](link-to-changelog) file.
31+
adding an entry to the [CHANGELOG.md](https://github.com/canonical/aproxy-operator/blob/main/docs/changelog.md) file.
3632

3733
To learn more about changelog best practices, visit [Keep a Changelog](https://keepachangelog.com/).
3834

@@ -43,7 +39,7 @@ notify in advance the people involved to avoid confusion;
4339
also, reference the issue or bug number when you submit the changes.
4440

4541
- [Fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/about-forks)
46-
our [GitHub repository](link-to-github-repo)
42+
our [GitHub repository](https://github.com/canonical/aproxy-operator)
4743
and add the changes to your fork, properly structuring your commits,
4844
providing detailed commit messages and signing your commits.
4945
- Make sure the updated project builds and runs without warnings or errors;
@@ -80,7 +76,7 @@ your pull request must provide the following details:
8076
- The [contributing guide](https://github.com/canonical/is-charms-contributing-guide) was applied
8177
- The changes are compliant with [ISD054 - Managing Charm Complexity](https://discourse.charmhub.io/t/specification-isd014-managing-charm-complexity/11619)
8278
- The documentation is updated
83-
- The PR is tagged with appropriate label (trivial, senior-review-required)
79+
- The PR is tagged with appropriate label (trivial, senior-review-required, documentation, etc.)
8480
- The changelog has been updated
8581

8682
### Signing commits
@@ -91,7 +87,7 @@ we use the [Canonical contributor license agreement](https://assets.ubuntu.com/v
9187

9288
#### Canonical contributor agreement
9389

94-
Canonical welcomes contributions to the <charm-name> charm. Please check out our
90+
Canonical welcomes contributions to the aproxy charm. Please check out our
9591
[contributor agreement](https://ubuntu.com/legal/contributors) if you're interested in contributing to the solution.
9692

9793
The CLA sign-off is simple line at the
@@ -111,8 +107,8 @@ To make contributions to this charm, you'll need a working
111107

112108
The code for this charm can be downloaded as follows:
113109

114-
```
115-
git clone https://github.com/canonical/<charm-name>
110+
```bash
111+
git clone https://github.com/canonical/aproxy-operator
116112
```
117113

118114
You can create an environment for development with `python3-venv`.
@@ -135,28 +131,9 @@ that can be used for linting and formatting code when you're preparing contribut
135131
* ``tox -e lint``: Runs a range of static code analysis to check the code.
136132
* ``tox -e static``: Runs other checks such as ``bandit`` for security issues.
137133

138-
### Build the rock and charm
139-
140-
Use [Rockcraft](https://documentation.ubuntu.com/rockcraft/en/latest/) to create an
141-
OCI image for the <charm-name> app, and then upload the image to a MicroK8s registry,
142-
which stores OCI archives so they can be downloaded and deployed.
143-
144-
Enable the MicroK8s registry:
145-
146-
```bash
147-
microk8s enable registry
148-
```
149-
150-
The following commands pack the OCI image and push it into
151-
the MicroK8s registry:
152-
153-
```bash
154-
cd <project_dir>
155-
rockcraft pack
156-
skopeo --insecure-policy copy --dest-tls-verify=false oci-archive:<rock-name>.rock docker://localhost:32000/<app-name>:latest
157-
```
134+
### Build the charm
158135

159-
Build the charm in this git repository using:
136+
Aproxy is a subordinate machine charm that installs a snap and configures nftables. Build the charm in this git repository using:
160137

161138
```shell
162139
charmcraft pack
@@ -169,8 +146,10 @@ charmcraft pack
169146
juju add-model charm-dev
170147
# Enable DEBUG logging
171148
juju model-config logging-config="<root>=INFO;unit=DEBUG"
172-
# Deploy the charm
173-
juju deploy ./<charm-name>.charm
149+
# Deploy the charm with a required config
150+
juju deploy ./aproxy.charm --config proxy-address=<target.proxy>
151+
# Integrate with a principal charm
152+
juju integrate aproxy <principal-charm>
174153
```
175154

176155

Makefile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2025 Canonical Ltd.
2+
# See LICENSE file for licensing details.
3+
4+
# Top-level Makefile
5+
# Delegates targets to Makefile.docs
6+
7+
# ==============================================================================
8+
# Macros
9+
# ==============================================================================
10+
11+
# Colors
12+
NO_COLOR=\033[0m
13+
CYAN_COLOR=\033[0;36m
14+
YELLOW_COLOR=\033[0;93m
15+
RED_COLOR=\033[0;91m
16+
17+
msg = @printf '$(CYAN_COLOR)$(1)$(NO_COLOR)\n'
18+
errmsg = @printf '$(RED_COLOR)Error: $(1)$(NO_COLOR)\n' && exit 1
19+
20+
# ==============================================================================
21+
# Core
22+
# ==============================================================================
23+
24+
include Makefile.docs
25+
26+
.PHONY: help
27+
help: _list-targets ## Prints all available targets
28+
29+
.PHONY: _list-targets
30+
_list-targets: ## This collects and prints all targets, ignore internal commands
31+
$(call msg,Available targets:)
32+
@awk -F'[:#]' ' \
33+
/^[a-zA-Z0-9._-]+:([^=]|$$)/ { \
34+
target = $$1; \
35+
comment = ""; \
36+
if (match($$0, /## .*/)) \
37+
comment = substr($$0, RSTART + 3); \
38+
if (target != ".PHONY" && target !~ /^_/ && !seen[target]++) \
39+
printf " make %-20s $(YELLOW_COLOR)# %s$(NO_COLOR)\n", target, comment; \
40+
}' $(MAKEFILE_LIST) | sort
41+

Makefile.docs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Copyright 2025 Canonical Ltd.
2+
# See LICENSE file for licensing details.
3+
4+
# Minimal makefile for documentation
5+
#
6+
7+
# Vale settings
8+
VALE_DIR ?= .vale
9+
PRAECEPTA_CONFIG ?= .vale.ini
10+
DOCS_FILES ?= docs/ README.md CONTRIBUTING.md
11+
12+
HAS_VALE := $(shell command -v vale;)
13+
HAS_LYCHEE := $(shell command -v lychee;)
14+
15+
# ==============================================================================
16+
# Docs Targets
17+
# ==============================================================================
18+
19+
.PHONY: docs-check
20+
docs-check: vale lychee ## Run all Docs checks
21+
22+
.PHONY: docs-clean
23+
docs-clean: vale-clean
24+
25+
# ==============================================================================
26+
# Dependency Check Targets
27+
# ==============================================================================
28+
29+
.PHONY: .check-vale
30+
.check-vale:
31+
ifndef HAS_VALE
32+
$(call errmsg,'vale' is not installed. Please install it first) \
33+
exit 1;
34+
endif
35+
36+
.PHONY: .check-lychee
37+
.check-lychee:
38+
ifndef HAS_LYCHEE
39+
$(call errmsg,'lychee' is not installed. Please install it first) \
40+
exit 1;
41+
endif
42+
43+
44+
# ==============================================================================
45+
# Main Vale Targets
46+
# ==============================================================================
47+
48+
.PHONY: vale-sync
49+
vale-sync: ## Download and install external Vale configuration sources
50+
$(call msg,--- Syncing Vale styles... ---)
51+
@vale sync
52+
53+
.PHONY: vale
54+
vale: .check-vale vale-sync ## Run Vale checks on docs
55+
$(call msg,--- Running Vale checks on "$(DOCS_FILES)"... ---)
56+
@vale --config=$(PRAECEPTA_CONFIG) $(DOCS_FILES)
57+
58+
# ==============================================================================
59+
# Main Lychee Targets
60+
# ==============================================================================
61+
62+
.PHONY: lychee
63+
lychee: .check-lychee ## Run Lychee checks on docs
64+
$(call msg,--- Running lychee checks on "$(LYCHEE_DOCS_FILES)"... ---)
65+
@lychee $(DOCS_FILES)
66+
67+
# ==============================================================================
68+
# Helper Targets
69+
# ==============================================================================
70+
71+
.PHONY: vale-clean
72+
vale-clean:
73+
$(call msg,--- Cleaning downloaded packages and ignored files from "$(VALE_DIR)"... ---)
74+
@git clean -dfX $(VALE_DIR)
75+

0 commit comments

Comments
 (0)