Skip to content

Commit 34cdb06

Browse files
authored
Merge pull request #777 from MetaCell/release/2.4.0
Release/2.4.0
2 parents ac1f272 + af3703e commit 34cdb06

747 files changed

Lines changed: 34933 additions & 57334 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ __pycache__
1919
/application-templates
2020
/deployment-configuration
2121
/cloud-harness
22-
.openapi-generator
22+
.openapi-generator
23+
docker-compose.yaml

.github/workflows/lint-check.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Lint Check
2+
3+
on:
4+
push
5+
6+
jobs:
7+
lint:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v2
13+
14+
- name: Set up Python
15+
uses: actions/setup-python@v2
16+
with:
17+
python-version: '3.x'
18+
19+
- name: Install autopep8
20+
run: pip install autopep8
21+
22+
- name: Run lint-check.sh
23+
run: bash lint-check.sh

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ node_modules
77
.coverage
88
*.DS_Store
99
deployment/helm
10+
deployment/compose
11+
docker-compose.yaml
1012
*.egg-info
1113
*.idea
1214
/build
@@ -17,4 +19,5 @@ skaffold.yaml
1719
/deployment.yaml
1820
.hypothesis
1921
__pycache__
20-
.env
22+
.env
23+
/.venv

README.md

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<img src="https://github.com/MetaCell/cloud-harness/blob/develop/cloudharness.png?raw=true" alt="drawing" width="200"/>
33
</p>
44

5-
CloudHarness is a base infrastructure facilitator for microservice based applications deployed on Kubernetes.
5+
CloudHarness is a base infrastructure facilitator for microservice based applications deployed primarily on Kubernetes.
66
Can scaffold and maintain your cloud solution on top of Cloudharness without writing
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-
- Common framework and utilities to develop and deploy micro-service application
10+
- Common framework and utilities to develop and deploy micro-service application
1111
- Helm chart automatic generation
1212
- deployments
1313
- services
@@ -17,6 +17,12 @@ What building your cloud solution with CloudHarness gives to you:
1717
- access gatekeepers configuration
1818
- secrets
1919
- templated config maps from files
20+
- Docker compose configuration generation
21+
- services
22+
- traefik configuration
23+
- databases (postgreql)
24+
- access gatekeepers configuration
25+
- secrets and configmaps
2026
* Automatic build and push of images
2127
* REST-API scaffolding building based on OpenApi
2228
* Continuous deployment script generation
@@ -46,17 +52,18 @@ In particular, these questions may rise:
4652
- How to manage databases without being locked to a specific vendor solution?
4753
- How to perform database backups?
4854
- How to manage secret data?
49-
- What about having a precounfigured account management application?
50-
- Sooner rather than later I'll need an orchestration queue. Why not have that just ready to use?
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?
5157

5258
# Command line tools
5359

5460
CloudHarness provides the following command line tools to help application scaffolding and deployment.
5561

56-
* `harness-deployment` - generate the helm chart to deploy on Kubernetes.
62+
* `harness-deployment` - generate the helm chart to deploy on Kubernetes.
5763
* `harness-application` - create a new CloudHarness REST application.
5864
* `harness-generate` - generates server and client code for all CloudHarness REST applications.
5965
* `harness-test` - run end to end tests
66+
6067
# Get started
6168

6269
## Prerequisites
@@ -67,15 +74,15 @@ Cloudharness can be used on all major operative systems.
6774
- Linux: supported and tested
6875
- MacOS: supported and tested
6976
- Windows/WSL2: supported and tested
70-
- Windows native: mostly working, unsupported
77+
- Windows native: mostly working, unsupported
7178

7279
### Python
7380
Python 3.9 must be installed.
7481

7582
It is recommended to setup a virtual environment.
76-
With conda:
83+
With conda:
7784
```bash
78-
conda create --name ch python=3.9
85+
conda create --name ch python=3.12
7986
conda activate ch
8087
```
8188

@@ -94,6 +101,10 @@ conda activate ch
94101

95102
[Skaffold](https://skaffold.dev/docs/install/) is the way to go to build and debug your application in your local development environment.
96103

104+
### Docker compose
105+
106+
[Docker Compose](https://docs.docker.com/compose/) is required if the docker compose system is the target (instead of Kubernetes).
107+
97108
### Node environment
98109

99110
A node environment with npm is required for developing web applications and to run end to end tests.
@@ -108,7 +119,6 @@ A JRE is needed to run the code generators based on openapi-generator.
108119

109120
For more info, see [here](https://openapi-generator.tech/docs/installation).
110121

111-
112122
## CloudHarness command line tools
113123
To use the cli tools, install requirements first:
114124

@@ -127,24 +137,25 @@ To (re)generate the code for your applications, run `harness-generate` from the
127137
The script will look for all openapi applications, and regenerate the Flask server code and documentation.
128138
Note: the script will eventually override any manually modified file. To avoid that, define a file openapi-generator-ignore.
129139

130-
# Extend CloudHarness to build your solution
131-
CloudHarness is born to be extended. In order to extend CloudHarness you just need to mirror the folder structure:
132-
* **applications**: place here your custom applications, or override default ones
133-
* **deployment-configuration**: override the helm chart default values and templates
134-
* **infrastructure**: define base images to use in your application
140+
# Extend CloudHarness to build your project
141+
142+
CloudHarness is born to be extended.
143+
144+
The quickest way to start is to install Cloud Harness, copy the *blueprint* folder and build from that with the cli tools, such as
145+
`harness-application`, `harness-generate`, `harness-deployment`.
135146

136-
or simply copy the *blueprint* folder.
147+
See the [developers documentation](docs/dev.md#start-your-project) for more information.
137148

138149
# Build and deploy
139150

140151
The script `harness-deployment` scans your applications and configurations to create the build and deploy artifacts.
141152
Created artifacts include:
142-
- Helm chart
153+
- Helm chart (or docker compose configuration file)
143154
- Skaffold build and run configuration
144155
- Visual Studio Code debug and run configuration
145156
- Codefresh pipeline yaml specification (optional)
146157

147-
With your solution folder structure looking like
158+
With your project folder structure looking like
148159

149160
```
150161
applications
@@ -153,7 +164,7 @@ infrastructure
153164
cloud-harness
154165
```
155166

156-
run
167+
run
157168

158169
```
159170
harness-deployment cloud-harness . [PARAMS]

application-templates/base/test/api/test_st.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import schemathesis as st
44
from schemathesis.checks import response_schema_conformance, not_a_server_error
55

6-
from cloudharness_test import apitest_init # include to perform default authorization
6+
from cloudharness_test import apitest_init # include to perform default authorization
77

88
app_url = os.environ.get("APP_URL", "http://samples.ch.local/api")
99

@@ -15,4 +15,3 @@ def test_ping(case):
1515
response = case.call()
1616
pprint(response.__dict__)
1717
assert response.status_code == 200, "this api errors on purpose"
18-

application-templates/base/test/e2e/landing.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe("End to end test", () => {
2929
return el.textContent;
3030
});
3131

32-
expect(await page.title()).toEqual("Samples");
33-
expect(title).toEqual("Sample React application is working!");
32+
expect(await page.title()).not.toBeNull();
33+
expect(title).not.toBeNull();
3434
});
3535
});

application-templates/django-app/api/templates/main.jinja2

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ from fastapi.staticfiles import StaticFiles
1414

1515
{{imports | replace(".","openapi.")}}
1616

17-
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "__APP_NAME__.settings")
17+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_baseapp.settings")
1818
apps.populate(settings.INSTALLED_APPS)
1919

2020
# migrate the Django models
2121
os.system("python manage.py migrate")
2222

23-
from api.controllers import *
23+
from __APP_NAME__.controllers import *
2424

2525
app = FastAPI(
2626
{% if info %}
@@ -49,34 +49,41 @@ app.add_middleware(
4949
allow_headers=["*"],
5050
)
5151

52-
from cloudharness.middleware import set_authentication_token
52+
from cloudharness.middleware import set_authentication_token, get_authentication_token
5353
@app.middleware("http")
5454
async def add_process_time_header(request: Request, call_next):
5555
# retrieve the bearer token from the header
5656
# and save it for use in the AuthClient
57-
authorization = request.headers.get('Authorization')
57+
authorization = request.headers.get('Authorization') or request.cookies.get('kc-access')
58+
5859
if authorization:
60+
if 'Bearer ' in authorization:
61+
authorization = authorization.split('Bearer ')[1]
62+
5963
set_authentication_token(authorization)
6064

6165
return await call_next(request)
6266

6367
if os.environ.get('KUBERNETES_SERVICE_HOST', None):
6468
# init the auth service when running in/for k8s
65-
from cloudharness_django.services import init_services, get_auth_service
66-
init_services()
67-
# start the kafka event listener when running in/for k8s
68-
import cloudharness_django.services.events
69+
from cloudharness_django.services import init_services_in_background, get_auth_service
70+
init_services_in_background()
6971

70-
# enable the Bearer Authentication
71-
security = HTTPBearer()
72+
# start the kafka event listener when running in/for k8s
73+
from cloudharness_django.services.events import init_listener_in_background
74+
init_listener_in_background()
7275

73-
async def has_access(credentials: HTTPBasicCredentials = Depends(security)):
76+
async def has_access():
7477
"""
7578
Function that is used to validate the token in the case that it requires it
7679
"""
7780
if not os.environ.get('KUBERNETES_SERVICE_HOST', None):
7881
return {}
79-
token = credentials.credentials
82+
83+
token = get_authentication_token()
84+
85+
if not token:
86+
raise HTTPException(status_code=401)
8087

8188
try:
8289
payload = get_auth_service().get_auth_client().decode_token(token)

application-templates/django-app/api/test_st.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import schemathesis as st
44
from schemathesis.checks import response_schema_conformance, not_a_server_error
55

6-
from cloudharness_test import apitest_init # include to perform default authorization
6+
from cloudharness_test import apitest_init # include to perform default authorization
77

88
app_url = os.environ.get("APP_URL", "http://samples.ch.local/api")
99

@@ -20,8 +20,9 @@ def test_ping(case):
2020
pprint(response.__dict__)
2121
assert response.status_code == 200, "this api errors on purpose"
2222

23+
2324
def test_state_machine():
2425
schema.as_state_machine().run()
2526
# APIWorkflow = schema.as_state_machine()
2627
# APIWorkflow.run()
27-
# TestAPI = APIWorkflow.TestCase
28+
# TestAPI = APIWorkflow.TestCase

application-templates/django-app/backend/api/admin.py renamed to application-templates/django-app/backend/__APP_NAME__/admin.py

File renamed without changes.

application-templates/django-app/backend/api/apps.py renamed to application-templates/django-app/backend/__APP_NAME__/apps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
class ApiConfig(AppConfig):
55
default_auto_field = 'django.db.models.BigAutoField'
6-
name = 'api'
6+
name = '__APP_NAME__'

0 commit comments

Comments
 (0)