Skip to content

Commit 363c16e

Browse files
authored
Merge pull request #50 from SEKOIA-IO/feat/sync_library_env_variable
feat: Allows to use env variables for secrets in sync library script
2 parents 754e0ba + 6224c4c commit 363c16e

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Changed
1111

1212
- In `synchronize-lib` script add support for slug based docker names
13+
- In `synchronize-lib` script allow to use environment variable for secrets
1314

1415
## [1.3.0] - 2023-06-06
1516

sekoia_automation/cli.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,23 @@ def openapi_to_module(
139139

140140
@app.command(name="synchronize-library")
141141
def sync_library(
142-
playbook_url=typer.Argument(..., help="URL of the Playbook API"),
143-
api_key=typer.Argument(..., help="Secret key to connect to the Playbook API"),
144-
modules_path: Path = typer.Argument(".", help="Path to the playbook modules"),
142+
playbook_url=typer.Argument(
143+
..., envvar="PLAYBOOK_URL", help="URL of the Playbook API"
144+
),
145+
api_key=typer.Argument(
146+
..., envvar="PLAYBOOK_API_KEY", help="Secret key to connect to the Playbook API"
147+
),
148+
modules_path: Path = typer.Option(".", help="Path to the playbook modules"),
145149
module: str = typer.Option("", help="Module to deploy. Default to all modules"),
146150
check_image_on_registry: bool = typer.Option(
147151
False, help="Whether to check registry for existing image"
148152
),
149-
registry_pat: str = typer.Option("", help="Docker registry personal access token"),
150-
registry_user: str = typer.Option("", help="Docker registry username"),
153+
registry_pat: str = typer.Option(
154+
"", envvar="REGISTRY_PAT", help="Docker registry personal access token"
155+
),
156+
registry_user: str = typer.Option(
157+
"", envvar="REGISTRY_USER", help="Docker registry username"
158+
),
151159
):
152160
"""
153161
Synchronize the module library to Sekoia.io

tests/test_cli.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,11 @@ def test_openapi_url_to_module(tmp_path, requests_mock, swagger_path):
199199
assert module.joinpath("main.py").exists()
200200
assert len(list(module.glob("action_*"))) > 0
201201
assert module.joinpath("dashboard_api", "__init__.py").exists()
202+
203+
204+
def test_synchronize_library():
205+
res: Result = runner.invoke(
206+
app,
207+
["synchronize-library", "foo", "bar"],
208+
)
209+
assert res.exit_code == 0

0 commit comments

Comments
 (0)