atlas-init 0.2.0__py3-none-any.whl → 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- atlas_init/__init__.py +1 -1
- atlas_init/settings/env_vars.py +13 -0
- atlas_init/settings/path.py +7 -3
- atlas_init/settings/rich_utils.py +1 -1
- atlas_init/typer_app.py +4 -18
- {atlas_init-0.2.0.dist-info → atlas_init-0.3.0.dist-info}/METADATA +14 -30
- {atlas_init-0.2.0.dist-info → atlas_init-0.3.0.dist-info}/RECORD +9 -9
- atlas_init-0.3.0.dist-info/entry_points.txt +2 -0
- atlas_init-0.2.0.dist-info/entry_points.txt +0 -2
- {atlas_init-0.2.0.dist-info → atlas_init-0.3.0.dist-info}/WHEEL +0 -0
atlas_init/__init__.py
CHANGED
atlas_init/settings/env_vars.py
CHANGED
@@ -6,6 +6,7 @@ from functools import cached_property
|
|
6
6
|
from pathlib import Path
|
7
7
|
from typing import Any, NamedTuple
|
8
8
|
|
9
|
+
import typer
|
9
10
|
from model_lib import field_names, parse_payload
|
10
11
|
from pydantic import field_validator, model_validator
|
11
12
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
@@ -271,4 +272,16 @@ def active_suites(settings: AtlasInitSettings) -> list[TestSuite]:
|
|
271
272
|
|
272
273
|
|
273
274
|
def init_settings() -> AtlasInitSettings:
|
275
|
+
missing_env_vars, ambiguous_env_vars = AtlasInitSettings.check_env_vars(
|
276
|
+
os.getenv("ATLAS_INIT_PROFILE", DEFAULT_PROFILE),
|
277
|
+
required_extra_fields=["project_name"],
|
278
|
+
)
|
279
|
+
if missing_env_vars:
|
280
|
+
typer.echo(f"missing env_vars: {missing_env_vars}")
|
281
|
+
if ambiguous_env_vars:
|
282
|
+
typer.echo(
|
283
|
+
f"amiguous env_vars: {ambiguous_env_vars} (specified both in cli & in .env-manual file with different values)"
|
284
|
+
)
|
285
|
+
if missing_env_vars or ambiguous_env_vars:
|
286
|
+
raise typer.Exit(1)
|
274
287
|
return AtlasInitSettings.safe_settings()
|
atlas_init/settings/path.py
CHANGED
@@ -1,12 +1,15 @@
|
|
1
|
+
import logging
|
1
2
|
import os
|
2
3
|
from collections.abc import Callable
|
3
4
|
from pathlib import Path
|
4
5
|
|
5
6
|
import dotenv
|
7
|
+
from appdirs import user_data_dir
|
6
8
|
from zero_3rdparty.file_utils import ensure_parents_write_text
|
7
9
|
|
8
10
|
from atlas_init import running_in_repo
|
9
11
|
|
12
|
+
logger = logging.getLogger(__name__)
|
10
13
|
"""WARNING these variables should only be used through the AtlasInitSettings, not directly"""
|
11
14
|
if running_in_repo():
|
12
15
|
ROOT_PATH = Path(__file__).parent.parent.parent.parent # atlas_init REPO_PATH
|
@@ -14,9 +17,10 @@ if running_in_repo():
|
|
14
17
|
else:
|
15
18
|
ROOT_PATH = Path(__file__).parent.parent # site package install directory
|
16
19
|
_default_profiles_path = os.environ.get("ATLAS_INIT_PROFILES_PATH")
|
17
|
-
|
18
|
-
_default_profiles_path
|
19
|
-
|
20
|
+
if not _default_profiles_path:
|
21
|
+
_default_profiles_path = Path(user_data_dir("atlas_init")) / "profiles"
|
22
|
+
warning_msg = f"os.environ['ATLAS_INIT_PROFILES_PATH'] is not set using default: {_default_profiles_path}"
|
23
|
+
logger.warning(warning_msg)
|
20
24
|
DEFAULT_PROFILES_PATH = Path(_default_profiles_path)
|
21
25
|
DEFAULT_PROFILES_PATH.mkdir(exist_ok=True, parents=True)
|
22
26
|
DEFAULT_TF_PATH = ROOT_PATH / "tf"
|
@@ -35,7 +35,7 @@ def hide_secrets(handler: logging.Handler, secrets_dict: dict[str, str]) -> None
|
|
35
35
|
if not isinstance(value, str):
|
36
36
|
continue
|
37
37
|
key_lower = key.lower()
|
38
|
-
if key_lower in {"true", "false"}:
|
38
|
+
if key_lower in {"true", "false"} or value.lower() in {"true", "false"}:
|
39
39
|
continue
|
40
40
|
if any(safe in key_lower for safe in safe_keys):
|
41
41
|
continue
|
atlas_init/typer_app.py
CHANGED
@@ -10,7 +10,6 @@ from atlas_init.cli_cfn.app import app as app_cfn
|
|
10
10
|
from atlas_init.cli_tf.app import app as app_tf
|
11
11
|
from atlas_init.settings.env_vars import (
|
12
12
|
DEFAULT_PROFILE,
|
13
|
-
AtlasInitSettings,
|
14
13
|
as_env_var_name,
|
15
14
|
env_var_names,
|
16
15
|
)
|
@@ -52,25 +51,12 @@ def main(
|
|
52
51
|
),
|
53
52
|
show_secrets: bool = typer.Option(False, help="show secrets in the logs"),
|
54
53
|
):
|
55
|
-
|
54
|
+
if profile != DEFAULT_PROFILE:
|
55
|
+
os.environ[as_env_var_name("profile")] = profile
|
56
56
|
if project_name != "":
|
57
|
-
|
57
|
+
os.environ[as_env_var_name("project_name")] = project_name
|
58
58
|
log_handler = configure_logging(log_level)
|
59
59
|
logger.info(f"running in repo: {running_in_repo()} python location:{sys.executable}")
|
60
|
-
missing_env_vars, ambiguous_env_vars = AtlasInitSettings.check_env_vars(
|
61
|
-
profile,
|
62
|
-
required_extra_fields=["project_name"],
|
63
|
-
explicit_env_vars=explicit_env_vars,
|
64
|
-
)
|
65
|
-
if missing_env_vars:
|
66
|
-
typer.echo(f"missing env_vars: {missing_env_vars}")
|
67
|
-
if ambiguous_env_vars:
|
68
|
-
typer.echo(
|
69
|
-
f"amiguous env_vars: {missing_env_vars} (specified both in cli & in .env-manual file with different values)"
|
70
|
-
)
|
71
|
-
if missing_env_vars or ambiguous_env_vars:
|
72
|
-
raise typer.Exit(1)
|
73
60
|
if not show_secrets:
|
74
61
|
hide_secrets(log_handler, {**os.environ})
|
75
|
-
command
|
76
|
-
logger.info(f"in the app callback, log-level: {log_level}, command: {command}")
|
62
|
+
logger.info(f"in the app callback, log-level: {log_level}, command: {ctx.command}")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: atlas-init
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.3.0
|
4
4
|
Project-URL: Documentation, https://github.com/EspenAlbert/atlas-init#readme
|
5
5
|
Project-URL: Issues, https://github.com/EspenAlbert/atlas-init/issues
|
6
6
|
Project-URL: Source, https://github.com/EspenAlbert/atlas-init
|
@@ -10,6 +10,7 @@ Classifier: Development Status :: 4 - Beta
|
|
10
10
|
Classifier: Programming Language :: Python
|
11
11
|
Classifier: Programming Language :: Python :: 3.12
|
12
12
|
Requires-Python: >=3.12
|
13
|
+
Requires-Dist: appdirs==1.4.4
|
13
14
|
Requires-Dist: boto3==1.34.55
|
14
15
|
Requires-Dist: gitpython==3.1.42
|
15
16
|
Requires-Dist: humanize==4.9.0
|
@@ -46,7 +47,15 @@ Currently, used with
|
|
46
47
|
- <https://github.com/mongodb/mongodb/mongodbatlas-cloudformation-resources>
|
47
48
|
- see [atlas_init#repo_aliases](atlas_init.yaml) for an up-to-date list
|
48
49
|
|
49
|
-
##
|
50
|
+
## Quickstart
|
51
|
+
Recommended as a tool with [uvx](https://docs.astral.sh/uv/guides/tools/#running-tools)
|
52
|
+
```shell
|
53
|
+
uvx atlas-init # help info
|
54
|
+
uvx atlas-init tf # help for tf specific commands
|
55
|
+
uvx atlas-init cfn # help for cfn specific commands
|
56
|
+
```
|
57
|
+
|
58
|
+
## Profile Configuration
|
50
59
|
1. [Create an organization](https://cloud-dev.mongodb.com/v2#/preferences/organizations)
|
51
60
|
2. Go to `access_manager` and click `Create Api Key`: <https://cloud-dev.mongodb.com/v2#/org/{ORG_ID_IN_URL_FROM_1}/access/apiKeys>
|
52
61
|
- Tick all permissions
|
@@ -72,17 +81,7 @@ ATLAS_INIT_CFN_PROFILE=YOUR_NAME
|
|
72
81
|
ATLAS_INIT_CFN_REGION=eu-south-2 # find a region with few other profiles
|
73
82
|
```
|
74
83
|
|
75
|
-
##
|
76
|
-
|
77
|
-
### 1. `pip install` normal user
|
78
|
-
|
79
|
-
```shell
|
80
|
-
source .venv/bin/activate # ensure you are in your preferred python env
|
81
|
-
(uv) pip install atlas-init
|
82
|
-
# use export ATLAS_INIT_PROFILES_PATH=/somewhere/to/store/your/env-vars/and/tf/state
|
83
|
-
```
|
84
|
-
|
85
|
-
### 2. Local development, run from github repo
|
84
|
+
## Local development
|
86
85
|
|
87
86
|
```shell
|
88
87
|
git clone https://github.com/EspenAlbert/atlas-init
|
@@ -117,27 +116,11 @@ echo "alias atlas_init='export PYTHONPATH=$pypath && \"$VENV_PYTHON\" -m atlas_i
|
|
117
116
|
atlas_init # should show how to use the cli
|
118
117
|
```
|
119
118
|
|
120
|
-
###
|
121
|
-
- will be used by the CI in other repos
|
119
|
+
### CI Installation Tests (`pip install` local wheel)
|
122
120
|
- [atlasci_local_install](atlasci_local_install.sh)
|
123
121
|
- creates a local `.venv` builds the wheel from this repo and installs it
|
124
122
|
- use `export ATLAS_INIT_PROFILES_PATH=/somewhere/to/store/your/env-vars/and/tf/state`
|
125
123
|
|
126
|
-
## Commands
|
127
|
-
|
128
|
-
```shell
|
129
|
-
cd terraform/cfn/{YOUR_RESOURCE_PATH}
|
130
|
-
# if you used `pip install` replace `atlas_init` with `atlasci`
|
131
|
-
atlas_init # help info
|
132
|
-
atlas_init # initialize the terraform providers
|
133
|
-
atlas_init tf # help for tf specific commands
|
134
|
-
atlas_init cfn # help for cfn specific commands
|
135
|
-
atals_init apply # `terraform apply`
|
136
|
-
# use cmd+v if you plan on using other tools, e.g., cfn make commands
|
137
|
-
# see appendix on how to configure .vscode test env-vars
|
138
|
-
atals_init destroy # `terraform destroy`
|
139
|
-
```
|
140
|
-
|
141
124
|
|
142
125
|
## Appendix
|
143
126
|
|
@@ -177,3 +160,4 @@ terraform providers lock \
|
|
177
160
|
-platform=darwin_arm64 \
|
178
161
|
-platform=linux_arm64
|
179
162
|
# -platform=windows_amd64 \
|
163
|
+
```
|
@@ -1,11 +1,11 @@
|
|
1
|
-
atlas_init/__init__.py,sha256=
|
1
|
+
atlas_init/__init__.py,sha256=wefdLatWmYi2mgkWhGxe2aEGq2miR5yH7tbuwRX6TAc,372
|
2
2
|
atlas_init/__main__.py,sha256=dY1dWWvwxRZMmnOFla6RSfti-hMeLeKdoXP7SVYqMUc,52
|
3
3
|
atlas_init/atlas_init.yaml,sha256=GMyJVhKKRc7WzEu7fafmWgeTsDaExTLv7QvXOmE_Brg,1907
|
4
4
|
atlas_init/cli.py,sha256=IiOEC_Jry6vrSDH3_OvsU50F-_3iVIS4tV6-R7659fY,9642
|
5
5
|
atlas_init/cli_args.py,sha256=tiwUYAE0JBSl9lHV6VJ41vFCU90ChBZ4mKvi-YoF_HY,541
|
6
6
|
atlas_init/humps.py,sha256=l0ZXXuI34wwd9TskXhCjULfGbUyK-qNmiyC6_2ow6kU,7339
|
7
7
|
atlas_init/terraform.yaml,sha256=qPrnbzBEP-JAQVkYadHsggRnDmshrOJyiv0ckyZCxwY,2734
|
8
|
-
atlas_init/typer_app.py,sha256=
|
8
|
+
atlas_init/typer_app.py,sha256=nxwKwr2GNZ6Zd8uXfJV8mZucEHT0KvfRyF_qxJ3IpYQ,1962
|
9
9
|
atlas_init/cli_cfn/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
10
|
atlas_init/cli_cfn/app.py,sha256=iMukpUDgsAgZh_U_APGZB3gmewOo-3vtFK0byJuDz9w,6649
|
11
11
|
atlas_init/cli_cfn/aws.py,sha256=GbohR7uczSGwQjLEYozCmlxbeIHo1uwQIJMwsh7kF7M,17894
|
@@ -54,10 +54,10 @@ atlas_init/repos/go_sdk.py,sha256=nh3lw9iw4lDGdHnhC8KK0PZTDMUGKvCHTMTuEtIUKNg,10
|
|
54
54
|
atlas_init/repos/path.py,sha256=wrT8e01OBoAHj8iMrxqutgqWu-BHPe9-bEWtcZRu238,4187
|
55
55
|
atlas_init/settings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
56
56
|
atlas_init/settings/config.py,sha256=HIytZom8RRvpLGy6u8CpZ83tmFXI6v1tO3iSiuo08kc,6259
|
57
|
-
atlas_init/settings/env_vars.py,sha256=
|
57
|
+
atlas_init/settings/env_vars.py,sha256=q8Hj2LPJIg-PK0fCjrEigoPwTGIEbqjLEZckwgnkG8s,9688
|
58
58
|
atlas_init/settings/interactive.py,sha256=Xy1Z5WMAOSaJ-vQI_4xjAbSR92rWQgnffwVoDT27L68,340
|
59
|
-
atlas_init/settings/path.py,sha256=
|
60
|
-
atlas_init/settings/rich_utils.py,sha256=
|
59
|
+
atlas_init/settings/path.py,sha256=FQ6-SVgc_KyxUjU9GWqq5YjViLDEEpojnApk8EwlS6U,2570
|
60
|
+
atlas_init/settings/rich_utils.py,sha256=JyVD_RuZTBeZdbnXN7B3WsYGkROhmypgzAym-zD92B4,1703
|
61
61
|
atlas_init/tf/.terraform.lock.hcl,sha256=DIojR50rr4fyLShYiQ-UpRV8z6vuBjwGWdK60FODoyM,6876
|
62
62
|
atlas_init/tf/always.tf,sha256=ij6QKI8Lg0140bFZwOyiYK5c-2p5e7AGZ1qKbYyv6Os,1359
|
63
63
|
atlas_init/tf/main.tf,sha256=DH0C8y9RDEHnSAZvL-TjE5MQjxj5ALfgk5zVO88cpZw,3960
|
@@ -86,7 +86,7 @@ atlas_init/tf/modules/vpc_peering/vpc_peering.tf,sha256=hJ3KJdGbLpOQednUpVuiJ0Cq
|
|
86
86
|
atlas_init/tf/modules/vpc_privatelink/atlas-privatelink.tf,sha256=FloaaX1MNDvoMZxBnEopeLKyfIlq6kaX2dmx8WWlXNU,1298
|
87
87
|
atlas_init/tf/modules/vpc_privatelink/variables.tf,sha256=gktHCDYD4rz6CEpLg5aiXcFbugw4L5S2Fqc52QYdJyc,255
|
88
88
|
atlas_init/tf/modules/vpc_privatelink/versions.tf,sha256=G0u5V_Hvvrkux_tqfOY05pA-GzSp_qILpfx1dZaTGDc,237
|
89
|
-
atlas_init-0.
|
90
|
-
atlas_init-0.
|
91
|
-
atlas_init-0.
|
92
|
-
atlas_init-0.
|
89
|
+
atlas_init-0.3.0.dist-info/METADATA,sha256=Kgl-C8C71uv9NU9s6q1uOfhF2fcUIAmYfU5mdzR1vSE,5650
|
90
|
+
atlas_init-0.3.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
91
|
+
atlas_init-0.3.0.dist-info/entry_points.txt,sha256=oSNFIEAS9nUZyyZ8Fc-0F0U5j-NErygy01LpJVSHapQ,57
|
92
|
+
atlas_init-0.3.0.dist-info/RECORD,,
|
File without changes
|