Skip to content

Commit

Permalink
Add the yaml env load
Browse files Browse the repository at this point in the history
  • Loading branch information
athiruma committed Sep 23, 2024
1 parent 1134aac commit 7525c93
Show file tree
Hide file tree
Showing 5 changed files with 328 additions and 55 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,4 @@ empty_test_environment_variables.py
/cloud_governance/policy/send_mail.py
cloudsensei/.env.txt
.vscode
env.yaml
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,28 @@ podman run --rm --name cloud-governance -e policy="tag_vm" -e account="$account"

```

#### Run with yaml config

```shell
cp example.yaml env.yaml
```

Added the supported environment variables.
example:

```yaml
policy: instance_idle
AWS_ACCESS_KEY_ID: ""
AWS_SECRET_ACCESS_KEY: ""
```
```shell
podman run --rm --name cloud-governance \
-v "env.yaml":"/env.yaml" \
-v DEFAULT_CONF_PATH="/env.yaml" \
"quay.io/cloud-governance/cloud-governance:latest"
```

## Run Policy Using Pod

#### Run as a pod job via OpenShift
Expand Down
10 changes: 4 additions & 6 deletions cloud_governance/common/logger/init_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@
import sys
import logging

from cloud_governance.main.environment_variables import environment_variables

logger_category_name = 'cloud_governance'
logger = logging.getLogger(logger_category_name) # instantiating a logger
handler = logging.StreamHandler(sys.stdout)
# log for output only
#log_path = os.getcwd()
#fileHandler = logging.FileHandler(filename=f'{log_path}/cloud_governance.log', mode='w+')
account_name = environment_variables.environment_variables_dict.get('account')
# log_path = os.getcwd()
# fileHandler = logging.FileHandler(filename=f'{log_path}/cloud_governance.log', mode='w+')
account_name = os.environ.get('account')
log_format = f'[%(levelname)s] %(asctime)s {account_name} - %(message)s'
formatter = logging.Formatter(log_format)
handler.setFormatter(formatter)
logger.addHandler(handler)
#logger.addHandler(fileHandler)
# logger.addHandler(fileHandler)


# def get_pyperf_log_path():
Expand Down
Loading

0 comments on commit 7525c93

Please sign in to comment.