Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:MetaCell/cloud-harness into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
filippomc committed Jul 30, 2024
2 parents 7692d9b + f81447b commit 25098cc
Show file tree
Hide file tree
Showing 94 changed files with 1,800 additions and 1,812 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ skaffold.yaml
/deployment.yaml
.hypothesis
__pycache__
.env
.env
/.venv
11 changes: 11 additions & 0 deletions application-templates/webapp/frontend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "__APP_NAME__",
"scripts": {
"dev": "vite",
"start": "DOMAIN=http://localhost:5000 vite",
"start:dev": "DOMAIN=https://test.ch.metacell.us vite",
"start:local": "DOMAIN=http://samples.ch vite",
"prebuild": "eslint .",
"build": "vite build"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ def ping(): # noqa: E501
:rtype: str
"""

import os

expected_environment_variables = {
'WORKERS': '3',
'ENVIRONMENT_TEST_A': 'value',
'ENVIRONMENT_TEST_B': '123',
}

for key, expected_value in expected_environment_variables.items():
try:
environment_value = os.environ[key]
if environment_value != expected_value:
raise Exception(f'Expected environment variable {key} to be {expected_value}, but got {environment_value}')
except KeyError:
raise Exception(f'Expected to have an environment variable {key} defined')

import time
return time.time()

Expand Down
3 changes: 2 additions & 1 deletion applications/samples/deploy/values-minimal.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
harness:
secured: true
secured: false
dependencies:
soft: []
hard: []
use_services: []

3 changes: 3 additions & 0 deletions applications/samples/deploy/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ harness:
env:
- name: WORKERS
value: "3"
envmap:
ENVIRONMENT_TEST_A: "value"
ENVIRONMENT_TEST_B: 123
dependencies:
soft:
- workflows
Expand Down
4 changes: 4 additions & 0 deletions deployment-configuration/helm/templates/auto-deployments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ spec:
{{- if .app.harness.env }}
{{- .app.harness.env | toYaml | nindent 8 }}
{{- end }}
{{- range $name, $value := .app.harness.envmap }}
- name: {{ $name | quote }}
value: {{ $value | quote }}
{{- end }}
{{ if .app.harness.livenessProbe }}
livenessProbe:
httpGet:
Expand Down
5 changes: 4 additions & 1 deletion docs/applications/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ The most important configuration entries are the following:
- `postgres`: postgres specific configurations
- `mongo`: mongo specific configurations
- `neo4j`: neo4j specific configurations
- `env` (`{name, value}[]`): add custom environment variables
- `envmap`: add custom environment variables
- `<environment_variable_name>`: `<environment_variable_value>`
- ...
- `env` (`{name, value}[]`): add custom environment variables (deprecated, please use `envmap`)
- `resources`: mount files from
- `use_services` (`{name, src, dst}[]`): create reverse proxy endpoints in the ingress for the listed applications on [subdomain].[Values.domain]/proxy/[name]. Useful to avoid CORS requests from frontend clients
- `readinessProbe`: defines a a url to use as a readiness probe
Expand Down
46 changes: 46 additions & 0 deletions docs/applications/environment-variables.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# CloudHarness Environment Variables

CloudHarness has support for adding environment variables for an application which will be available to all containers within the application pod.

## Automatically included environment variables

The following environment variables are included in each container by default:
- `CH_CURRENT_APP_NAME`: the name of the application
- Any environment variables defined in the root `.Values.env`
- If `accounts` is an included application:
- `CH_ACCOUNTS_CLIENT_SECRET`: the client secret for the accounts
- `CH_ACCOUNTS_REALM`: the accounts realm
- `CH_ACCOUNTS_AUTH_DOMAIN`: the auth domain for the accounts
- `CH_ACCOUNTS_CLIENT_ID`: the client id for the accounts
- `DOMAIN`: the domain for the accounts

## Environment variables definition in CloudHarness

Environment variables are defined in the application values.yaml file in the `envmap` section under the `harness` section.
Example

```yaml
harness:
envmap:
ENV_VARIABLE_A: <value>
...
```

Each key in the `envmap` will add an environment variable with a name matching the key and a value equal to the value provided. The value can be any primitive type, but will be quoted as a string within the deployment template.

### (Deprecated) Setting with `env`

Environment variables can be defined by using the `env` section under the `harness` section. This functionality is deprecated but not yet obsoleted, and use of `envmap` should be preferred over this approach.
Example

```yaml
harness:
env:
- name: ENV_VARIABLE_A
value: <value>
...
```

Each element of the `env` sequence will add an environment variable named `name` with value set from `value`.

This functionality was deprecated as cloud harness cannot merge arrays, so if an environment variable needed changing in a specific environment the entire array must be reproduced to change the single variable.
65 changes: 26 additions & 39 deletions docs/model/ApiTestsConfig.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,33 @@
# cloudharness_model.model.api_tests_config.ApiTestsConfig
# ApiTestsConfig

## Model Type Info
Input Type | Accessed Type | Description | Notes
------------ | ------------- | ------------- | -------------
dict, frozendict.frozendict, | frozendict.frozendict, | |

### Dictionary Keys
Key | Input Type | Accessed Type | Description | Notes
------------ | ------------- | ------------- | ------------- | -------------
**[checks](#checks)** | list, tuple, | tuple, | One of the Schemathesis checks: - not_a_server_error. The response has 5xx HTTP status; - status_code_conformance. The response status is not defined in the API schema; - content_type_conformance. The response content type is not defined in the API schema; - response_schema_conformance. The response content does not conform to the schema defined for this specific response; - response_headers_conformance. The response headers does not contain all defined headers. |
**autotest** | bool, | BoolClass, | Specify whether to run the common smoke tests |
**enabled** | bool, | BoolClass, | Enables api tests for this application (default: false) |
**[runParams](#runParams)** | list, tuple, | tuple, | Additional schemathesis parameters | [optional]
**any_string_name** | dict, frozendict.frozendict, str, date, datetime, int, float, bool, decimal.Decimal, None, list, tuple, bytes, io.FileIO, io.BufferedReader | frozendict.frozendict, str, BoolClass, decimal.Decimal, NoneClass, tuple, bytes, FileIO | any string name can be used but the value must be the correct type | [optional]

# checks

One of the Schemathesis checks: - not_a_server_error. The response has 5xx HTTP status; - status_code_conformance. The response status is not defined in the API schema; - content_type_conformance. The response content type is not defined in the API schema; - response_schema_conformance. The response content does not conform to the schema defined for this specific response; - response_headers_conformance. The response headers does not contain all defined headers.

## Model Type Info
Input Type | Accessed Type | Description | Notes
------------ | ------------- | ------------- | -------------
list, tuple, | tuple, | One of the Schemathesis checks: - not_a_server_error. The response has 5xx HTTP status; - status_code_conformance. The response status is not defined in the API schema; - content_type_conformance. The response content type is not defined in the API schema; - response_schema_conformance. The response content does not conform to the schema defined for this specific response; - response_headers_conformance. The response headers does not contain all defined headers. |

### Tuple Items
Class Name | Input Type | Accessed Type | Description | Notes
------------- | ------------- | ------------- | ------------- | -------------
items | str, | str, | |

# runParams
## Properties

Additional schemathesis parameters

## Model Type Info
Input Type | Accessed Type | Description | Notes
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
list, tuple, | tuple, | Additional schemathesis parameters |

### Tuple Items
Class Name | Input Type | Accessed Type | Description | Notes
------------- | ------------- | ------------- | ------------- | -------------
items | str, | str, | |
**enabled** | **bool** | Enables api tests for this application (default: false) |
**autotest** | **bool** | Specify whether to run the common smoke tests |
**run_params** | **List[str]** | Additional schemathesis parameters | [optional]
**checks** | **List[str]** | One of the Schemathesis checks: - not_a_server_error. The response has 5xx HTTP status; - status_code_conformance. The response status is not defined in the API schema; - content_type_conformance. The response content type is not defined in the API schema; - response_schema_conformance. The response content does not conform to the schema defined for this specific response; - response_headers_conformance. The response headers does not contain all defined headers. |

## Example

```python
from cloudharness_model.models.api_tests_config import ApiTestsConfig

# TODO update the JSON string below
json = "{}"
# create an instance of ApiTestsConfig from a JSON string
api_tests_config_instance = ApiTestsConfig.from_json(json)
# print the JSON string representation of the object
print ApiTestsConfig.to_json()

# convert the object into a dict
api_tests_config_dict = api_tests_config_instance.to_dict()
# create an instance of ApiTestsConfig from a dict
api_tests_config_form_dict = api_tests_config.from_dict(api_tests_config_dict)
```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md)

53 changes: 20 additions & 33 deletions docs/model/ApplicationAccountsConfig.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,31 @@
# cloudharness_model.model.application_accounts_config.ApplicationAccountsConfig
# ApplicationAccountsConfig

## Model Type Info
Input Type | Accessed Type | Description | Notes
------------ | ------------- | ------------- | -------------
dict, frozendict.frozendict, | frozendict.frozendict, | |

### Dictionary Keys
Key | Input Type | Accessed Type | Description | Notes
------------ | ------------- | ------------- | ------------- | -------------
**[roles](#roles)** | list, tuple, | tuple, | Specify roles to be created in this deployment specific for this application | [optional]
**[users](#users)** | list, tuple, | tuple, | Defines test users to be added to the deployment, specific for this application | [optional]
**any_string_name** | dict, frozendict.frozendict, str, date, datetime, int, float, bool, decimal.Decimal, None, list, tuple, bytes, io.FileIO, io.BufferedReader | frozendict.frozendict, str, BoolClass, decimal.Decimal, NoneClass, tuple, bytes, FileIO | any string name can be used but the value must be the correct type | [optional]

# roles

Specify roles to be created in this deployment specific for this application
## Properties

## Model Type Info
Input Type | Accessed Type | Description | Notes
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
list, tuple, | tuple, | Specify roles to be created in this deployment specific for this application |
**roles** | **List[str]** | Specify roles to be created in this deployment specific for this application | [optional]
**users** | [**List[ApplicationUser]**](ApplicationUser.md) | Defines test users to be added to the deployment, specific for this application | [optional]

### Tuple Items
Class Name | Input Type | Accessed Type | Description | Notes
------------- | ------------- | ------------- | ------------- | -------------
items | str, | str, | |
## Example

# users
```python
from cloudharness_model.models.application_accounts_config import ApplicationAccountsConfig

Defines test users to be added to the deployment, specific for this application

## Model Type Info
Input Type | Accessed Type | Description | Notes
------------ | ------------- | ------------- | -------------
list, tuple, | tuple, | Defines test users to be added to the deployment, specific for this application |
# TODO update the JSON string below
json = "{}"
# create an instance of ApplicationAccountsConfig from a JSON string
application_accounts_config_instance = ApplicationAccountsConfig.from_json(json)
# print the JSON string representation of the object
print ApplicationAccountsConfig.to_json()

### Tuple Items
Class Name | Input Type | Accessed Type | Description | Notes
------------- | ------------- | ------------- | ------------- | -------------
[**ApplicationUser**](ApplicationUser.md) | [**ApplicationUser**](ApplicationUser.md) | [**ApplicationUser**](ApplicationUser.md) | |
# convert the object into a dict
application_accounts_config_dict = application_accounts_config_instance.to_dict()
# create an instance of ApplicationAccountsConfig from a dict
application_accounts_config_form_dict = application_accounts_config.from_dict(application_accounts_config_dict)
```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md)

33 changes: 23 additions & 10 deletions docs/model/ApplicationConfig.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
# cloudharness_model.model.application_config.ApplicationConfig
# ApplicationConfig

Place here the values to configure your application helm templates.

## Model Type Info
Input Type | Accessed Type | Description | Notes
## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
dict, frozendict.frozendict, | frozendict.frozendict, | Place here the values to configure your application helm templates. |
**harness** | [**ApplicationHarnessConfig**](ApplicationHarnessConfig.md) | |

## Example

```python
from cloudharness_model.models.application_config import ApplicationConfig

# TODO update the JSON string below
json = "{}"
# create an instance of ApplicationConfig from a JSON string
application_config_instance = ApplicationConfig.from_json(json)
# print the JSON string representation of the object
print ApplicationConfig.to_json()

### Dictionary Keys
Key | Input Type | Accessed Type | Description | Notes
------------ | ------------- | ------------- | ------------- | -------------
**harness** | [**ApplicationHarnessConfig**](ApplicationHarnessConfig.md) | [**ApplicationHarnessConfig**](ApplicationHarnessConfig.md) | |
**any_string_name** | dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, | frozendict.frozendict, str, decimal.Decimal, BoolClass, NoneClass, tuple, bytes, FileIO | any string name can be used but the value must be the correct type | [optional]
# convert the object into a dict
application_config_dict = application_config_instance.to_dict()
# create an instance of ApplicationConfig from a dict
application_config_form_dict = application_config.from_dict(application_config_dict)
```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md)

Loading

0 comments on commit 25098cc

Please sign in to comment.