Skip to content

Commit 21b19bd

Browse files
authored
Merge pull request #795 from MetaCell/feature/CH-174
harness-generate refactoring, documentation review
2 parents 60cded6 + 6eeaf32 commit 21b19bd

File tree

8 files changed

+286
-112
lines changed

8 files changed

+286
-112
lines changed

README.md

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ Can scaffold and maintain your cloud solution on top of Cloudharness without wri
77
Kubernetes templates, with in place common utilities and applications already configured for you.
88

99
What building your cloud solution with CloudHarness gives to you:
10+
1011
- Common framework and utilities to develop and deploy micro-service application
12+
1113
- Helm chart automatic generation
1214
- deployments
1315
- services
@@ -23,11 +25,13 @@ What building your cloud solution with CloudHarness gives to you:
2325
- databases (postgreql)
2426
- access gatekeepers configuration
2527
- secrets and configmaps
28+
2629
* Automatic build and push of images
2730
* REST-API scaffolding building based on OpenApi
2831
* Continuous deployment script generation
2932
* Debug backend applications running on Kubernetes
3033
* Python cluster access utilities
34+
3135
* Prebuilt support applications and shared library to:
3236
* Log in and user management - based on Keycloak
3337
* Submit batch and asynchronous workflows - based on Argo
@@ -43,17 +47,18 @@ What building your cloud solution with CloudHarness gives to you:
4347

4448
The microservice architecture is a great to get code separation and flexible development, but may not be of easy implementation, especially for small development teams/projects.
4549
In particular, these questions may rise:
46-
- How do I create a deployment for my microservices?
47-
- How do I orchestrate my microservices?
48-
- How to create consistent api documentation?
49-
- Do I need to be an experienced devops to create a micro-service based application?
50-
- Wouldn't it be nice to develop a plain database/backend/frontend application without infrastructure boilerplate but still be able to configure everything I want when needed?
51-
- How to run batch operations like ETL processes easily and efficiently in a cloud environment?
52-
- How to manage databases without being locked to a specific vendor solution?
53-
- How to perform database backups?
54-
- How to manage secret data?
55-
- What about having a precounfigured account management application?
56-
- Sooner rather than later I'll need an orchestration queue. Why not have that just ready to use?
50+
51+
- How do I create a deployment for my microservices?
52+
- How do I orchestrate my microservices?
53+
- How to create consistent api documentation?
54+
- Do I need to be an experienced devops to create a micro-service based application?
55+
- Wouldn't it be nice to develop a plain database/backend/frontend application without infrastructure boilerplate but still be able to configure everything I want when needed?
56+
- How to run batch operations like ETL processes easily and efficiently in a cloud environment?
57+
- How to manage databases without being locked to a specific vendor solution?
58+
- How to perform database backups?
59+
- How to manage secret data?
60+
- What about having a precounfigured account management application?
61+
- Sooner rather than later I'll need an orchestration queue. Why not have that just ready to use?
5762

5863
# Command line tools
5964

@@ -63,30 +68,34 @@ CloudHarness provides the following command line tools to help application scaff
6368
* `harness-application` - create a new CloudHarness REST application.
6469
* `harness-generate` - generates server and client code for all CloudHarness REST applications.
6570
* `harness-test` - run end to end tests
66-
71+
6772
# Get started
6873

6974
## Prerequisites
7075

7176
### Operative system
7277

7378
Cloudharness can be used on all major operative systems.
79+
7480
- Linux: supported and tested
7581
- MacOS: supported and tested
7682
- Windows/WSL2: supported and tested
7783
- Windows native: mostly working, unsupported
7884

7985
### Python
80-
Python 3.9 must be installed.
86+
87+
Python 3.10+ must be installed.
8188

8289
It is recommended to setup a virtual environment.
8390
With conda:
91+
8492
```bash
8593
conda create --name ch python=3.12
8694
conda activate ch
8795
```
8896

8997
### Docker
98+
9099
[Docker](https://www.docker.com) is required to build locally.
91100

92101
### Kubernetes command line client
@@ -110,6 +119,7 @@ conda activate ch
110119
A node environment with npm is required for developing web applications and to run end to end tests.
111120

112121
Recommended:
122+
113123
- node >= v14.0.0
114124
- npm >= 8.0.0
115125

@@ -120,26 +130,31 @@ A JRE is needed to run the code generators based on openapi-generator.
120130
For more info, see [here](https://openapi-generator.tech/docs/installation).
121131

122132
## CloudHarness command line tools
133+
123134
To use the cli tools, install requirements first:
124135

125136
```bash
126137
bash install.sh
127138
```
128-
### Generate deployment
129139

130-
To generate a deployment, run `harness-deployment`. See [below](#Deployment) for more.
140+
### Create a new REST application
131141

132-
### Create new REST application
133-
To create a new REST application, run `harness-application` from the root of your solution.
142+
`harness-application` is a command-line tool used to create new applications based on predefined code templates. It allows users to quickly scaffold applications with backend, frontend, and database configurations.
143+
More information can be found [here](./docs/applications/harness-application.md).
134144

135145
### Generate server and client code from openapi
136-
To (re)generate the code for your applications, run `harness-generate` from the root.
137-
The script will look for all openapi applications, and regenerate the Flask server code and documentation.
138-
Note: the script will eventually override any manually modified file. To avoid that, define a file openapi-generator-ignore.
146+
147+
To (re)generate the code for your applications, run `harness-generate`.
148+
`harness-generate` is a command-line tool used to generate client code, server stubs, and model libraries for applications.
149+
More information can be found [here](./docs/applications/harness-generate.md)
150+
151+
### Generate deployment
152+
153+
To generate a deployment, run `harness-deployment`. See [below](#build-and-deploy) for more information.
139154

140155
# Extend CloudHarness to build your project
141156

142-
CloudHarness is born to be extended.
157+
CloudHarness is born to be extended.
143158

144159
The quickest way to start is to install Cloud Harness, copy the *blueprint* folder and build from that with the cli tools, such as
145160
`harness-application`, `harness-generate`, `harness-deployment`.
@@ -150,10 +165,11 @@ See the [developers documentation](docs/dev.md#start-your-project) for more info
150165

151166
The script `harness-deployment` scans your applications and configurations to create the build and deploy artifacts.
152167
Created artifacts include:
153-
- Helm chart (or docker compose configuration file)
154-
- Skaffold build and run configuration
155-
- Visual Studio Code debug and run configuration
156-
- Codefresh pipeline yaml specification (optional)
168+
169+
- Helm chart (or docker compose configuration file)
170+
- Skaffold build and run configuration
171+
- Visual Studio Code debug and run configuration
172+
- Codefresh pipeline yaml specification (optional)
157173

158174
With your project folder structure looking like
159175

@@ -193,5 +209,4 @@ Then, you can selectively add files related to configuration that you want to pe
193209

194210
For more information about how to configure a deployment, see [here](./build-deploy/helm-configuration.md)
195211

196-
197-
[![Codefresh build status]( https://g.codefresh.io/api/badges/pipeline/tarelli/Cloudharness%2Funittests?type=cf-1&key=eyJhbGciOiJIUzI1NiJ9.NWFkNzMyNDIzNjQ1YWMwMDAxMTJkN2Rl.-gUEkJxH6NCCIRgSIgEikVDte-Q0BsGZKEs4uahgpzs)]( https://g.codefresh.io/pipelines/edit/new/builds?id=6034cfce1036693697cd602b&pipeline=unittests&projects=Cloudharness&projectId=6034cfb83bb11c399e85c71b)
212+
[![Codefresh build status](https://g.codefresh.io/api/badges/pipeline/tarelli/Cloudharness%2Funittests?type=cf-1&key=eyJhbGciOiJIUzI1NiJ9.NWFkNzMyNDIzNjQ1YWMwMDAxMTJkN2Rl.-gUEkJxH6NCCIRgSIgEikVDte-Q0BsGZKEs4uahgpzs)](https://g.codefresh.io/pipelines/edit/new/builds?id=6034cfce1036693697cd602b&pipeline=unittests&projects=Cloudharness&projectId=6034cfb83bb11c399e85c71b)
Lines changed: 81 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,103 @@
1-
# Use harness-application to create a new application from templates
1+
# Use harness-application to create a new application
22

3-
## Choosing Templates
3+
## Overview
44

5-
If you create a new application, you can choose templates that are used to generate the application scaffold.
5+
`harness-application` is a command-line tool used to create new applications from predefined code templates. It allows users to quickly scaffold applications with backend, frontend, and database configurations.
66

7-
Running `harness-application --help` will list the currently available templates:
7+
## Usage
88

9+
```sh
10+
harness-application [name] [-t TEMPLATE]
911
```
10-
usage: harness-application [-h] [-t TEMPLATES] name
1112

12-
Creates a new Application.
13+
## Arguments
14+
15+
- `name` *(required)* – The name of the application to be created.
16+
17+
## Options
18+
19+
- `-h, --help` – Displays the help message and exits.
20+
- `-t TEMPLATES, --template TEMPLATES` – Specifies one or more templates to use when creating the application.
21+
22+
## Choosing Templates
1323

14-
positional arguments:
15-
name Application name
24+
When creating a new application, you can choose templates that define its structure and components. Running `harness-application --help` will list the currently available templates:
1625

17-
optional arguments:
18-
-h, --help show this help message and exit
19-
-t TEMPLATES, --template TEMPLATES
20-
Add a template name. Available templates: - base (always included) - flask-server (backend flask app based on openapi) - webapp (webapp including backend and frontend) - db-postgres - db-neo4j - db-mongo - django-app (fastapi django backend based on openapi)
26+
```sh
27+
usage: harness-application [-h] [-t TEMPLATES] name
2128
```
2229

2330
## Available Templates
2431

2532
### Base
2633

27-
* The `base` template is always included and used as foundation for any other template.
34+
- The `base` template is always included and serves as the foundation for any other template.
35+
36+
### Backend Templates
37+
38+
#### Flask Server
39+
40+
- The `flask-server` template consists of a backend built using [Flask](https://flask.palletsprojects.com/en/1.1.x/).
41+
- Uses [Connexion](https://github.com/zalando/connexion) to map OpenAPI definitions to Flask routes.
42+
- Served by [Gunicorn](https://gunicorn.org/) with 2 synchronous workers by default.
43+
- Supports customization of the worker count and type.
44+
45+
#### Django
46+
47+
- The `django-fastapi` consists of a backend based on [FastAPI](https://fastapi.tiangolo.com/) and [Django](https://www.djangoproject.com/).
48+
- Uses the [FastAPI code generator](https://github.com/koxudaxi/fastapi-code-generator) to map OpenAPI definitions.
49+
- Served by [Uvicorn](https://www.uvicorn.org/) with 2 workers by default.
50+
- The `django-ninja` consists of a backend based on [Django Ninja](https://django-ninja.dev/)
51+
- Provides automatic OpenAPI schema generation.
52+
- Supports Django's built-in ORM for seamless database integration.
53+
- High performance due to Pydantic-based data validation.
54+
- Simplifies request parsing and authentication.
2855

29-
### Flask Server
30-
* It consists of a single backend, a Python [Flask](https://flask.palletsprojects.com/en/1.1.x/) application.
31-
* The [Connexion](https://github.com/zalando/connexion) library maps the OpenAPI definition to Flask routing.
32-
* Per default, [Gunicorn](https://gunicorn.org/) serves the Flask app with 2 synchronous workers. Depending on the application requirements, you can update the number of workers or choose a different [worker type](https://docs.gunicorn.org/en/stable/design.html).
56+
### Full-Stack Templates
3357

58+
#### Webapp
3459

35-
### Webapp
60+
- The `webapp` template extends the `base` template by adding a [React](https://reactjs.org/) frontend.
61+
- The frontend bundle is served by the Python backend.
62+
- React is used by default, but other frontend technologies can be integrated.
3663

37-
* The `webapp` template consists builds upon the `base` template extends it by a [React](https://reactjs.org/) frontend application.
38-
* The generated frontend bundle is served by the Python backend.
39-
* Per default, React is used as a frontend application, but you are free to choose a different frontend technology.
64+
### Database Templates
4065

66+
- `db-postgres`[PostgreSQL](https://www.postgresql.org/), a relational database.
67+
- `db-neo4j`[Neo4J](https://neo4j.com/), a graph database.
68+
- `db-mongo`[MongoDB](https://www.mongodb.com/), a NoSQL document-based database.
4169

42-
### Databases
70+
## Examples
71+
72+
### Create a New Flask-Based Microservice Application
73+
74+
```sh
75+
harness-application myapp
76+
```
77+
78+
### Create a Full-Stack Web Application
79+
80+
```sh
81+
harness-application myapp -t webapp
82+
```
83+
84+
### Create a Web Application with a Mongo Database
85+
86+
```sh
87+
harness-application myapp -t webapp -t db-mongo
88+
```
89+
90+
### Display Help Information
91+
92+
```sh
93+
harness-application --help
94+
```
4395

44-
Additionally, you can choose one of the following database templates:
45-
* `db-postgres` - [PostgreSQL](https://www.postgresql.org/), a relational database
46-
* `db-neo4j`- [Neo4J](https://neo4j.com/), a graph database
47-
* `db-mongo` - [MongoDB](https://www.mongodb.com/), a NoSQL document-based database
96+
## Notes
4897

49-
### Django
50-
* It consists of a single backend, a Python [FastAPI](https://fastapi.tiangolo.com/) application.
51-
* The [FastAPI code generator](https://github.com/koxudaxi/fastapi-code-generator) maps the OpenAPI definition to FastAPI routing.
52-
* The [Django framework](https://www.djangoproject.com/) encourages rapid development and clean, pragmatic design.
53-
* Per default, [Uvicorn](https://www.uvicorn.org/) serves the FastAPI app with 2 workers. Depending on the application requirements, you can update the number of workers.
98+
- Multiple templates can be specified by concatenating the `-t` parameter.
99+
- The tool generates the necessary scaffolding for the chosen templates.
100+
- Ensure you have the required dependencies installed before running the generated application.
101+
- For more information, run `harness-application --help` or check out the additional documentation:
102+
- [Applications README](./docs/applications/README.md)
103+
- [Developer Guide](./docs/dev.md)
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Use harness-generate to generate server and client stubs
2+
3+
To (re)generate the code for your applications, run `harness-generate`.
4+
`harness-generate` is a command-line tool used to generate client code, server stubs, and model libraries for applications. It walks through the filesystem inside the `./applications` folder to create and update application scaffolding. The tool supports different generation modes and allows for both interactive and non-interactive usage.
5+
6+
## Usage
7+
8+
```sh
9+
harness-generate [mode] [-h] [-i] [-a APP_NAME] [-cn CLIENT_NAME] [-t | -p] [path]
10+
```
11+
12+
## harness-generate Arguments
13+
14+
- `path` *(optional)* – The base path of the application. If provided, the `-a/--app-name` flag is ignored.
15+
16+
## harness-generate Options
17+
18+
- `-h, --help` – Displays the help message and exits.
19+
- `-i, --interactive` – Asks for confirmation before generating code.
20+
- `-a APP_NAME, --app-name APP_NAME` – Specifies the application name to generate clients for.
21+
- `-cn CLIENT_NAME, --client-name CLIENT_NAME` – Specifies a prefix for the client name.
22+
- `-t, --ts-only` – Generates only TypeScript clients.
23+
- `-p, --python-only` – Generates only Python clients.
24+
25+
## Generation Modes
26+
27+
`harness-generate` supports the following modes:
28+
29+
- **all** – Generates both server stubs and client libraries.
30+
- **clients** – Generates only client libraries.
31+
- **servers** – Generates only server stubs.
32+
- **models** – Regenerates only model libraries.
33+
34+
## harness-generate Examples
35+
36+
### Generate Client and Server stubs for all applications
37+
38+
```sh
39+
harness-generate all
40+
```
41+
42+
### Generate Client and Server stubs for a Specific Application
43+
44+
```sh
45+
harness-generate all -a myApp
46+
```
47+
48+
### Generate Only Client Libraries
49+
50+
```sh
51+
harness-generate clients
52+
```
53+
54+
### Generate Only Server Stubs
55+
56+
```sh
57+
harness-generate servers
58+
```
59+
60+
### Regenerate Only Model Libraries (deprecated)
61+
62+
```sh
63+
harness-generate models
64+
```
65+
66+
### Generate TypeScript Clients Only and Server stubs
67+
68+
```sh
69+
harness-generate all -t
70+
```
71+
72+
### Generate Python Clients Only and Server stubs
73+
74+
```sh
75+
harness-generate all -p
76+
```
77+
78+
### Interactive Mode
79+
80+
```sh
81+
harness-generate all -i
82+
```
83+
84+
## harness-generate Notes
85+
86+
- The tool scans the `./applications` directory for available applications.
87+
- If `path` is provided, `-a/--app-name` is ignored.
88+
- The `models` mode is a special flag used when regenerating only model libraries (deprecated).
89+
- The tool supports interactive mode to confirm before generating clients.
90+
- Use either `-t` or `-p`, but not both simultaneously.
91+
92+
For further details, run:
93+
94+
```sh
95+
harness-generate --help
96+
```

0 commit comments

Comments
 (0)