Skip to content

Commit 464b889

Browse files
authored
chore: update docs with enhancement (#77)
* chore: remove misleading warning when yarn install is successful Signed-off-by: Frank Kong <frkong@redhat.com> * chore: add additional plugin examples Signed-off-by: Frank Kong <frkong@redhat.com> --------- Signed-off-by: Frank Kong <frkong@redhat.com>
1 parent 4d08eb4 commit 464b889

15 files changed

Lines changed: 468 additions & 23 deletions

File tree

CONTRIBUTING.md

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ rhdh-dynamic-plugin-factory/
180180
├── src/rhdh_dynamic_plugin_factory/
181181
│ ├── __init__.py # Package initialization and public API
182182
│ ├── __main__.py # Package entry point
183+
│ ├── __version__.py # Package version definition
183184
│ ├── cli.py # CLI implementation and argument parsing
184185
│ ├── config.py # Configuration classes and validation
185186
│ ├── constants.py # Shared constants and configuration values
@@ -193,32 +194,51 @@ rhdh-dynamic-plugin-factory/
193194
│ └── override-sources.sh # Patch/overlay application script
194195
├── tests/
195196
│ ├── __init__.py
196-
│ ├── conftest.py # Pytest fixtures and configuration
197-
│ ├── test_cli.py # CLI argument parsing tests
198-
│ ├── test_config_export_plugins.py # Plugin export tests
199-
│ ├── test_config_load_from_env.py # Environment loading tests
200-
│ ├── test_config_patches_and_overlays.py # Patch/overlay tests
201-
│ ├── test_config_registry.py # Registry configuration tests
202-
│ ├── test_multi_workspace.py # Multi-workspace mode tests
203-
│ ├── test_plugin_list_config.py # Plugin list and build-arg tests
204-
│ └── test_source_config.py # Source configuration tests
197+
│ ├── conftest.py # Pytest fixtures and configuration
198+
│ ├── test_cli.py # CLI argument parsing tests
199+
│ ├── test_config_discover_and_build_args.py # Plugin discovery and build-arg tests
200+
│ ├── test_config_export_plugins.py # Plugin export tests
201+
│ ├── test_config_load_from_env.py # Environment loading tests
202+
│ ├── test_config_patches_and_overlays.py # Patch/overlay tests
203+
│ ├── test_config_registry.py # Registry configuration tests
204+
│ ├── test_multi_workspace.py # Multi-workspace mode tests
205+
│ ├── test_plugin_list_config.py # Plugin list and build-arg tests
206+
│ ├── test_source_config.py # Source configuration tests
207+
│ └── test_utils.py # Utility function tests
205208
├── examples/ # Example configuration sets
206209
│ ├── example-config-todo/
207210
│ ├── example-config-gitlab/
208211
│ ├── example-config-aws-ecs/
212+
│ ├── example-config-backstage-devtools/
213+
│ ├── example-config-toolbox/
214+
│ ├── example-config-usage-statistics/
209215
│ └── example-config-multi-workspace/
216+
├── .github/ # GitHub Actions CI/CD
217+
├── resources/
218+
│ ├── rhdh/yarn.lock # RHDH yarn.lock used for dependency matching in `plugins-list.yaml` private dependency resolution
219+
│ └── metadata.json # Package metadata
210220
├── .cursor/rules/ # Development guidelines
211221
│ ├── commit-standards.mdc
222+
│ ├── development-workflow.mdc
212223
│ ├── documentation-standards.mdc
224+
│ ├── github-actions-workflow.mdc
225+
│ ├── integration-tests.mdc
213226
│ ├── planning-process.mdc
227+
│ ├── pytest-unit-tests.mdc
214228
│ ├── python-code-quality.mdc
215229
│ └── shell-code-quality.mdc
230+
├── .dockerignore
231+
├── .gitignore
232+
├── CONTRIBUTING.md # Contributor guidelines
216233
├── default.env # Default environment settings
217234
├── Dockerfile # Container image definition
218-
├── requirements.txt # Python runtime dependencies
219-
├── requirements.dev.txt # Python development dependencies
235+
├── LICENSE
236+
├── pyproject.toml # Python project configuration
220237
├── pytest.ini # Pytest configuration
221-
└── README.md # User documentation
238+
├── README.md # Main user documentation
239+
├── renovate.json # Renovate dependency update configuration
240+
├── requirements.dev.txt # Python development dependencies
241+
└── requirements.txt # Python runtime dependencies
222242
```
223243

224244
### Key Components

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -648,12 +648,15 @@ NOTE: If the repository name (ex: plugin-name-dynamic) in the namespace specifie
648648

649649
The `examples` directory contains ready-to-use configuration examples demonstrating different use cases and features.
650650

651-
| Example | Description | Details |
652-
| ------------------- | ------------------------------------------------------------- | ------------------------------------------------------------------ |
653-
| **TODO** | Basic single-workspace with custom scalprum-config | [View README](./examples/example-config-todo/README.md) |
654-
| **GitLab** | Overlays for non Backstage Community Plugins workspace format | [View README](./examples/example-config-gitlab/README.md) |
655-
| **AWS ECS** | Patches and embed packages in plugins-list.yaml | [View README](./examples/example-config-aws-ecs/README.md) |
656-
| **Multi-Workspace** | Multiple workspaces from different repos in a single run | [View README](./examples/example-config-multi-workspace/README.md) |
651+
| Example | Description | Details |
652+
| ---------------------- | ------------------------------------------------------------- | --------------------------------------------------------------------- |
653+
| **TODO** | Basic single-workspace with custom scalprum-config | [View README](./examples/example-config-todo/README.md) |
654+
| **GitLab** | Overlays for non Backstage Community Plugins workspace format | [View README](./examples/example-config-gitlab/README.md) |
655+
| **AWS ECS** | Patches and embed packages in plugins-list.yaml | [View README](./examples/example-config-aws-ecs/README.md) |
656+
| **Backstage DevTools** | DevTools plugins from the main Backstage repository | [View README](./examples/example-config-backstage-devtools/README.md) |
657+
| **Toolbox** | Toolbox plugins with patches and a backend module | [View README](./examples/example-config-toolbox/README.md) |
658+
| **Usage Statistics** | Usage Statistics plugins from a third-party repository | [View README](./examples/example-config-usage-statistics/README.md) |
659+
| **Multi-Workspace** | Multiple workspaces from different repos in a single run | [View README](./examples/example-config-multi-workspace/README.md) |
657660

658661
### Quick Example: TODO Workspace
659662

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Backstage DevTools Example Configuration
2+
3+
This example demonstrates building the DevTools plugins from the main Backstage repository.
4+
5+
## Table of Contents
6+
7+
- [Backstage DevTools Example Configuration](#backstage-devtools-example-configuration)
8+
- [Table of Contents](#table-of-contents)
9+
- [Overview](#overview)
10+
- [Example Config Directory Structure](#example-config-directory-structure)
11+
- [Configuration Files](#configuration-files)
12+
- [Quick Start](#quick-start)
13+
- [Container Execution (Recommended)](#container-execution-recommended)
14+
- [Local Development](#local-development)
15+
- [Expected Output](#expected-output)
16+
- [Publishing the package](#publishing-the-package)
17+
- [Next Steps](#next-steps)
18+
19+
## Overview
20+
21+
This example builds the frontend and backend DevTools plugins from the [backstage/backstage](https://github.com/backstage/backstage) repository. It is a minimal configuration with no patches or overlays required.
22+
23+
## Example Config Directory Structure
24+
25+
```bash
26+
example-config-backstage-devtools/
27+
├── plugins-list.yaml # List of plugins to build
28+
└── source.json # Source repository configuration
29+
```
30+
31+
### Configuration Files
32+
33+
- **`source.json`**: Specifies the Backstage repository and git reference to clone from. The `repo-ref` field is optional; when omitted, the repository's default branch is used. The `workspace-path` field can also be set here instead of using `--workspace-path`.
34+
- **`plugins-list.yaml`**: Lists the path to the DevTools frontend and backend plugins to build with respect to the workspace path
35+
36+
## Quick Start
37+
38+
### Container Execution (Recommended)
39+
40+
From the repository root, run:
41+
42+
```bash
43+
podman run --rm -it \
44+
--device /dev/fuse \
45+
-v ./examples/example-config-backstage-devtools:/config:z \
46+
-v ./outputs:/outputs:z \
47+
quay.io/rhdh-community/dynamic-plugins-factory:latest \
48+
```
49+
50+
Note: `workspace-path` is set to `.` in the `source.json` because the Backstage repository does not follow the backstage community plugins (BCP) repository structure where there are multiple yarn workspaces. Instead the plugins are stored in the main workspace, so root of the workspace is also the root of the repository in this example.
51+
52+
### Local Development
53+
54+
From the repository root, run:
55+
56+
```bash
57+
python -m src.rhdh_dynamic_plugin_factory \
58+
--config-dir ./examples/example-config-backstage-devtools \
59+
--repo-path ./source \
60+
--output-dir ./outputs
61+
```
62+
63+
Or using CLI args instead of `source.json`:
64+
65+
```bash
66+
python -m src.rhdh_dynamic_plugin_factory \
67+
--source-repo https://github.com/backstage/backstage \
68+
--source-ref 6b60bd75fd1d448a16c2c28dbb3e9a10c1e8a722 \
69+
--config-dir ./examples/example-config-backstage-devtools \
70+
--workspace-path . \
71+
--repo-path ./source \
72+
--output-dir ./outputs
73+
```
74+
75+
This will do the following:
76+
77+
1. The factory clones the Backstage repository to `./source`
78+
2. Dependencies are installed at the repository root
79+
3. Both frontend and backend DevTools plugins are compiled
80+
4. Plugins are exported as dynamic plugins using the RHDH CLI
81+
5. Plugin tarballs and integrity files are created in `./outputs`
82+
83+
## Expected Output
84+
85+
After successful execution, you'll find these files in `./outputs`:
86+
87+
```bash
88+
outputs/
89+
├── backstage-plugin-devtools-X.Y.Z.tgz
90+
├── backstage-plugin-devtools-X.Y.Z.tgz.integrity
91+
├── backstage-plugin-devtools-backend-X.Y.Z.tgz
92+
└── backstage-plugin-devtools-backend-X.Y.Z.tgz.integrity
93+
```
94+
95+
Note: Version numbers may vary depending on the plugin versions in the source repository.
96+
97+
## Publishing the package
98+
99+
If you want to publish the package, you will need to add a `--push-image` argument and provide the following environmental variables in the `/config/.env` file:
100+
101+
```bash
102+
REGISTRY_URL="quay.io"
103+
REGISTRY_USERNAME="your-username"
104+
REGISTRY_PASSWORD="your-password"
105+
REGISTRY_NAMESPACE="your-namespace"
106+
REGISTRY_INSECURE="false"
107+
```
108+
109+
## Next Steps
110+
111+
- Review the [TODO example](../example-config-todo/) for a simpler use case with custom scalprum-config
112+
- Try the [Toolbox example](../example-config-toolbox/) to learn about patches and backend modules
113+
- Try the [AWS ECS example](../example-config-aws-ecs/) to learn about patches and embed packages
114+
- Read the [main README](../../README.md) for more configuration options
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
plugins/devtools:
2+
plugins/devtools-backend:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"repo":"https://github.com/backstage/backstage","repo-ref":"6b60bd75fd1d448a16c2c28dbb3e9a10c1e8a722","workspace-path":"."}
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# Toolbox Example Configuration
2+
3+
This example demonstrates building the Toolbox plugins from a third-party repository with patches and a backend module.
4+
5+
## Table of Contents
6+
7+
- [Toolbox Example Configuration](#toolbox-example-configuration)
8+
- [Table of Contents](#table-of-contents)
9+
- [Overview](#overview)
10+
- [Example Config Directory Structure](#example-config-directory-structure)
11+
- [Configuration Files](#configuration-files)
12+
- [Understanding the Patch](#understanding-the-patch)
13+
- [How Patches Work](#how-patches-work)
14+
- [Quick Start](#quick-start)
15+
- [Container Execution (Recommended)](#container-execution-recommended)
16+
- [Local Development](#local-development)
17+
- [Expected Output](#expected-output)
18+
- [Publishing the package](#publishing-the-package)
19+
- [Next Steps](#next-steps)
20+
21+
## Overview
22+
23+
This example builds frontend, backend, and backend module plugins from the [drodil/backstage-plugin-toolbox](https://github.com/drodil/backstage-plugin-toolbox) repository. It includes the following configurations:
24+
25+
1. **Patches**: A patch to fix workspace configuration that prevents packaging generated export artifacts since the frontend plugin in this example also contains an alpha package with support for the new frontend system.
26+
2. **Backend Module**: Demonstrates building a backend module plugin (`toolbox-backend-module-whois`) in addition to the main frontend and backend plugins
27+
28+
## Example Config Directory Structure
29+
30+
```bash
31+
example-config-toolbox/
32+
├── patches/
33+
│ └── 1-avoid-double-wildcards.patch # Patch file
34+
├── plugins-list.yaml # List of plugins to build
35+
└── source.json # Source repository configuration
36+
```
37+
38+
### Configuration Files
39+
40+
- **`source.json`**: Specifies the Toolbox plugin repository and git reference to clone from. The `repo-ref` field is optional; when omitted, the repository's default branch is used. The `workspace-path` field can also be set here instead of using `--workspace-path`.
41+
- **`plugins-list.yaml`**: Lists the path to the Toolbox frontend, backend, and backend module plugins to build
42+
- **`patches/`**: Contains patch files applied before building
43+
44+
## Understanding the Patch
45+
46+
The `1-avoid-double-wildcards.patch` modifies the workspace `packages` glob in `package.json` from `plugins/**` to `plugins/*`. This prevents Yarn from treating the `dist-dynamic` directories (generated by the RHDH CLI export command) as additional workspaces, which would cause build failures.
47+
48+
```diff
49+
--- a/package.json
50+
+++ b/package.json
51+
@@ -30,7 +30,7 @@
52+
},
53+
"workspaces": {
54+
"packages": [
55+
- "plugins/**"
56+
+ "plugins/*"
57+
]
58+
},
59+
```
60+
61+
### How Patches Work
62+
63+
1. The factory clones the source repository
64+
2. Before building, it applies all `.patch` files from `config/patches/` in alphabetical order
65+
3. Each patch modifies specific lines in the source files
66+
4. The patched source is then built and exported
67+
68+
**Warning**: Patches are destructive - they permanently modify files in the workspace directory. Please make sure to have source control if using a local repository.
69+
70+
## Quick Start
71+
72+
### Container Execution (Recommended)
73+
74+
From the repository root, run:
75+
76+
```bash
77+
podman run --rm -it \
78+
--device /dev/fuse \
79+
-v ./examples/example-config-toolbox:/config:z \
80+
-v ./outputs:/outputs:z \
81+
quay.io/rhdh-community/dynamic-plugins-factory:latest \
82+
```
83+
84+
Note: `workspace-path` is set to `.` in `source.json` because this repository does not follow the backstage community plugins (BCP) repository structure where there are multiple yarn workspaces. Instead the plugins are stored in the main workspace, so root of the workspace is also the root of the repository in this example.
85+
86+
### Local Development
87+
88+
From the repository root, run:
89+
90+
```bash
91+
python -m src.rhdh_dynamic_plugin_factory \
92+
--config-dir ./examples/example-config-toolbox \
93+
--repo-path ./source \
94+
--output-dir ./outputs
95+
```
96+
97+
Or using CLI args instead of `source.json`:
98+
99+
```bash
100+
python -m src.rhdh_dynamic_plugin_factory \
101+
--source-repo https://github.com/drodil/backstage-plugin-toolbox \
102+
--source-ref 32ff2046741478f0964cf63a97fae5cc2f1a93d8 \
103+
--config-dir ./examples/example-config-toolbox \
104+
--workspace-path . \
105+
--repo-path ./source \
106+
--output-dir ./outputs
107+
```
108+
109+
This will do the following:
110+
111+
1. The factory clones the Toolbox plugin repository to `./source`
112+
2. The `1-avoid-double-wildcards.patch` is applied to fix workspace configuration
113+
3. Dependencies are installed at the repository root
114+
4. Frontend, backend, and backend module plugins are compiled
115+
5. Plugins are exported as dynamic plugins using the RHDH CLI
116+
6. Plugin tarballs and integrity files are created in `./outputs`
117+
118+
## Expected Output
119+
120+
After successful execution, you'll find these files in `./outputs`:
121+
122+
```bash
123+
outputs/
124+
├── backstage-plugin-toolbox-X.Y.Z.tgz
125+
├── backstage-plugin-toolbox-X.Y.Z.tgz.integrity
126+
├── backstage-plugin-toolbox-backend-X.Y.Z.tgz
127+
├── backstage-plugin-toolbox-backend-X.Y.Z.tgz.integrity
128+
├── backstage-plugin-toolbox-backend-module-whois-X.Y.Z.tgz
129+
└── backstage-plugin-toolbox-backend-module-whois-X.Y.Z.tgz.integrity
130+
```
131+
132+
Note: Version numbers may vary depending on the plugin versions in the source repository.
133+
134+
## Publishing the package
135+
136+
If you want to publish the package, you will need to add a `--push-image` argument and provide the following environmental variables in the `/config/.env` file:
137+
138+
```bash
139+
REGISTRY_URL="quay.io"
140+
REGISTRY_USERNAME="your-username"
141+
REGISTRY_PASSWORD="your-password"
142+
REGISTRY_NAMESPACE="your-namespace"
143+
REGISTRY_INSECURE="false"
144+
```
145+
146+
## Next Steps
147+
148+
- Try the [AWS ECS example](../example-config-aws-ecs/) to learn about embed packages
149+
- Try the [GitLab example](../example-config-gitlab/) to learn about overlays
150+
- Review the [TODO example](../example-config-todo/) for a simpler use case
151+
- Read the [main README](../../README.md) for more configuration options
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- a/package.json
2+
+++ b/package.json
3+
@@ -30,7 +30,7 @@
4+
},
5+
"workspaces": {
6+
"packages": [
7+
- "plugins/**"
8+
+ "plugins/*"
9+
]
10+
},
11+
"devDependencies": {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
plugins/toolbox:
2+
plugins/toolbox-backend:
3+
plugins/toolbox-backend-module-whois:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"repo": "https://github.com/drodil/backstage-plugin-toolbox",
3+
"repo-ref": "32ff2046741478f0964cf63a97fae5cc2f1a93d8",
4+
"workspace-path": "."
5+
}

0 commit comments

Comments
 (0)