atlas-init 0.4.4__py3-none-any.whl → 0.4.5__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/cli_cfn/app.py +3 -4
- atlas_init/cli_cfn/cfn_parameter_finder.py +2 -2
- atlas_init/cli_cfn/contract.py +4 -7
- atlas_init/cli_cfn/example.py +0 -2
- atlas_init/cli_helper/go.py +1 -1
- atlas_init/cli_root/trigger.py +6 -6
- atlas_init/settings/env_vars.py +18 -31
- {atlas_init-0.4.4.dist-info → atlas_init-0.4.5.dist-info}/METADATA +1 -1
- {atlas_init-0.4.4.dist-info → atlas_init-0.4.5.dist-info}/RECORD +13 -13
- {atlas_init-0.4.4.dist-info → atlas_init-0.4.5.dist-info}/WHEEL +0 -0
- {atlas_init-0.4.4.dist-info → atlas_init-0.4.5.dist-info}/entry_points.txt +0 -0
- {atlas_init-0.4.4.dist-info → atlas_init-0.4.5.dist-info}/licenses/LICENSE +0 -0
atlas_init/__init__.py
CHANGED
atlas_init/cli_cfn/app.py
CHANGED
@@ -53,8 +53,8 @@ def reg(
|
|
53
53
|
if local:
|
54
54
|
deregister_cfn_resource_type(type_name, deregister=not dry_run, region_filter=region)
|
55
55
|
logger.info(f"ready to activate {type_name}")
|
56
|
-
|
57
|
-
cfn_execution_role =
|
56
|
+
init_settings(TFModuleCfn)
|
57
|
+
cfn_execution_role = TFModuleCfn.from_env().CFN_EXAMPLE_EXECUTION_ROLE
|
58
58
|
last_third_party = get_last_cfn_type(type_name, region, is_third_party=True)
|
59
59
|
assert last_third_party, f"no 3rd party extension found for {type_name} in {region}"
|
60
60
|
if dry_run:
|
@@ -100,7 +100,6 @@ def inputs(
|
|
100
100
|
cwd = current_dir()
|
101
101
|
suite = suites[0]
|
102
102
|
assert suite.cwd_is_repo_go_pkg(cwd, repo_alias="cfn")
|
103
|
-
env_extra = settings.load_env_vars_full()
|
104
103
|
CREATE_FILENAME = "cfn-test-create-inputs.sh" # noqa: N806
|
105
104
|
create_dirs = ["test/contract-testing", "test"]
|
106
105
|
parent_dir = None
|
@@ -113,7 +112,7 @@ def inputs(
|
|
113
112
|
if not run_command_is_ok(
|
114
113
|
cwd=cwd,
|
115
114
|
cmd=f"./{parent_dir}/{CREATE_FILENAME}" + " ".join(context.args),
|
116
|
-
env={**os.environ}
|
115
|
+
env={**os.environ},
|
117
116
|
logger=logger,
|
118
117
|
):
|
119
118
|
logger.critical("failed to create cfn contract input files")
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import logging
|
2
|
+
import os
|
2
3
|
from pathlib import Path
|
3
4
|
from typing import Any
|
4
5
|
|
@@ -158,7 +159,6 @@ def updated_template_path(path: Path) -> Path:
|
|
158
159
|
|
159
160
|
|
160
161
|
def decode_parameters(
|
161
|
-
exported_env_vars: dict[str, str],
|
162
162
|
template_path: Path,
|
163
163
|
type_name: str,
|
164
164
|
stack_name: str,
|
@@ -186,7 +186,7 @@ def decode_parameters(
|
|
186
186
|
parameters_dict[param_name] = type_default
|
187
187
|
continue
|
188
188
|
if env_key := parameters_exported_env_vars.get(param_name): # noqa: SIM102
|
189
|
-
if env_value :=
|
189
|
+
if env_value := os.environ.get(env_key):
|
190
190
|
logger.info(f"using {env_key} to fill parameter: {param_name}")
|
191
191
|
parameters_dict[param_name] = env_value
|
192
192
|
continue
|
atlas_init/cli_cfn/contract.py
CHANGED
@@ -53,7 +53,6 @@ class RunContractTestOutput(Entity):
|
|
53
53
|
|
54
54
|
class CreateContractTestInputs(Entity):
|
55
55
|
resource_path: Path
|
56
|
-
env_vars_generated: dict[str, str]
|
57
56
|
log_group_name: str
|
58
57
|
|
59
58
|
|
@@ -115,10 +114,8 @@ def contract_test(
|
|
115
114
|
settings = settings or init_settings(AWSSettings)
|
116
115
|
resource_paths = resource_paths or find_paths(Repo.CFN)
|
117
116
|
resource_name = resource_paths.resource_name
|
118
|
-
generated_env_vars = settings.load_env_vars_full()
|
119
117
|
create_inputs = CreateContractTestInputs(
|
120
118
|
resource_path=resource_paths.resource_path,
|
121
|
-
env_vars_generated=generated_env_vars,
|
122
119
|
log_group_name=f"mongodb-atlas-{resource_name}-logs",
|
123
120
|
)
|
124
121
|
create_response = create_contract_test_inputs(create_inputs)
|
@@ -164,7 +161,7 @@ def create_contract_test_inputs(
|
|
164
161
|
input_files = []
|
165
162
|
for template in sorted(test_dir.glob("*.template.json")):
|
166
163
|
template_file = template.read_text()
|
167
|
-
template_file = file_replacements(template_file,
|
164
|
+
template_file = file_replacements(template_file, template.name)
|
168
165
|
inputs_file = inputs_dir / template.name.replace(".template", "")
|
169
166
|
ensure_parents_write_text(inputs_file, template_file)
|
170
167
|
input_files.append(inputs_file)
|
@@ -173,11 +170,11 @@ def create_contract_test_inputs(
|
|
173
170
|
return CreateContractTestInputsResponse(input_files=input_files, sample_files=sample_files)
|
174
171
|
|
175
172
|
|
176
|
-
def file_replacements(text: str,
|
173
|
+
def file_replacements(text: str, file_name: str) -> str:
|
177
174
|
for match in re.finditer(r"\${(\w+)}", text):
|
178
175
|
var_name = match.group(1)
|
179
|
-
if
|
180
|
-
text = text.replace(match.group(0),
|
176
|
+
if env_value := os.environ.get(var_name):
|
177
|
+
text = text.replace(match.group(0), env_value)
|
181
178
|
else:
|
182
179
|
logger.warning(f"found placeholder {match.group(0)} in {file_name} but no replacement")
|
183
180
|
return text
|
atlas_init/cli_cfn/example.py
CHANGED
@@ -136,7 +136,6 @@ def example_handler(
|
|
136
136
|
)
|
137
137
|
type_name = inputs.type_name
|
138
138
|
stack_name = inputs.stack_name
|
139
|
-
env_vars_generated = settings.load_env_vars_full()
|
140
139
|
region = inputs.region
|
141
140
|
operation = inputs.operation
|
142
141
|
stack_timeout_s = inputs.stack_timeout_s
|
@@ -160,7 +159,6 @@ def example_handler(
|
|
160
159
|
return
|
161
160
|
template_path = infer_template_path(repo_path, type_name, stack_name, inputs.example_name)
|
162
161
|
template_path, parameters, not_found = decode_parameters(
|
163
|
-
exported_env_vars=env_vars_generated,
|
164
162
|
template_path=template_path,
|
165
163
|
stack_name=stack_name,
|
166
164
|
force_params=inputs.resource_params,
|
atlas_init/cli_helper/go.py
CHANGED
@@ -171,7 +171,7 @@ def resolve_env_vars(
|
|
171
171
|
skip_os: bool = False,
|
172
172
|
) -> dict[str, str]:
|
173
173
|
if env_vars == GoEnvVars.manual:
|
174
|
-
test_env_vars = settings.
|
174
|
+
test_env_vars = settings.manual_env_vars
|
175
175
|
elif env_vars == GoEnvVars.vscode:
|
176
176
|
test_env_vars = load_dotenv(settings.env_vars_vs_code)
|
177
177
|
else:
|
atlas_init/cli_root/trigger.py
CHANGED
@@ -4,7 +4,7 @@ import requests
|
|
4
4
|
from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_fixed
|
5
5
|
from zero_3rdparty.id_creator import simple_id
|
6
6
|
|
7
|
-
from atlas_init.settings.env_vars import init_settings
|
7
|
+
from atlas_init.settings.env_vars import env_vars_cls_or_none, init_settings
|
8
8
|
from atlas_init.settings.env_vars_generated import (
|
9
9
|
AtlasSettingsWithProject,
|
10
10
|
AWSSettings,
|
@@ -23,15 +23,15 @@ def trigger_app():
|
|
23
23
|
|
24
24
|
|
25
25
|
def create_realm_app():
|
26
|
-
settings = init_settings()
|
27
|
-
atlas_settings =
|
28
|
-
cluster_settings =
|
26
|
+
settings = init_settings(AtlasSettingsWithProject, TFModuleCluster, AWSSettings)
|
27
|
+
atlas_settings = AtlasSettingsWithProject.from_env()
|
28
|
+
cluster_settings = TFModuleCluster.from_env()
|
29
|
+
aws_settings = AWSSettings.from_env()
|
29
30
|
project_id = atlas_settings.MONGODB_ATLAS_PROJECT_ID
|
30
31
|
base_url = atlas_settings.realm_url
|
31
32
|
cluster_name = cluster_settings.MONGODB_ATLAS_CLUSTER_NAME
|
32
33
|
auth_headers = login_to_realm(settings, base_url)
|
33
|
-
realm_settings =
|
34
|
-
aws_settings = settings.env_vars_cls(AWSSettings)
|
34
|
+
realm_settings = env_vars_cls_or_none(RealmSettings, dotenv_path=settings.env_vars_trigger)
|
35
35
|
if realm_settings and function_exists(
|
36
36
|
base_url,
|
37
37
|
auth_headers,
|
atlas_init/settings/env_vars.py
CHANGED
@@ -144,31 +144,6 @@ class AtlasInitSettings(StaticSettings):
|
|
144
144
|
def cfn_region(self, default: str) -> str:
|
145
145
|
return self.atlas_init_cfn_region or default
|
146
146
|
|
147
|
-
def load_env_vars_full(self) -> dict[str, str]:
|
148
|
-
env_path = self.env_vars_vs_code
|
149
|
-
assert env_path.exists(), f"no env-vars exist {env_path} have you forgotten apply?"
|
150
|
-
return load_dotenv(env_path)
|
151
|
-
|
152
|
-
def env_vars_cls_or_none(self, t: type[T], *, path: Path | None = None) -> T | None:
|
153
|
-
with suppress(ValidationError):
|
154
|
-
return self.env_vars_cls(t, path=path)
|
155
|
-
|
156
|
-
def env_vars_cls(self, t: type[T], *, path: Path | None = None) -> T:
|
157
|
-
path = path or self.env_vars_vs_code
|
158
|
-
env_vars = load_dotenv(path) if path.exists() else {}
|
159
|
-
return t(**env_vars)
|
160
|
-
|
161
|
-
def load_profile_manual_env_vars(self, *, skip_os_update: bool = False) -> dict[str, str]:
|
162
|
-
# sourcery skip: dict-assign-update-to-union
|
163
|
-
manual_env_vars = self.manual_env_vars
|
164
|
-
if manual_env_vars:
|
165
|
-
if skip_os_update:
|
166
|
-
return manual_env_vars
|
167
|
-
if new_updates := {k: v for k, v in manual_env_vars.items() if k not in os.environ}:
|
168
|
-
logger.info(f"loading manual env-vars {','.join(new_updates)}")
|
169
|
-
os.environ.update(new_updates)
|
170
|
-
return manual_env_vars
|
171
|
-
|
172
147
|
def include_extra_env_vars_in_vscode(self, extra_env_vars: dict[str, str]) -> None:
|
173
148
|
extra_name = ", ".join(extra_env_vars.keys())
|
174
149
|
original_env_vars = load_dotenv(self.env_vars_vs_code)
|
@@ -261,20 +236,32 @@ def init_settings(
|
|
261
236
|
*settings_classes: type[BaseModel],
|
262
237
|
) -> AtlasInitSettings:
|
263
238
|
settings = AtlasInitSettings.from_env()
|
264
|
-
|
265
|
-
|
239
|
+
profile_env_vars = settings.manual_env_vars
|
240
|
+
vscode_env_vars = settings.env_vars_vs_code
|
241
|
+
if vscode_env_vars.exists():
|
242
|
+
profile_env_vars |= load_dotenv(vscode_env_vars)
|
266
243
|
required_env_vars = collect_required_env_vars(list(settings_classes))
|
267
|
-
ambiguous = detect_ambiguous_env_vars(
|
268
|
-
missing_env_vars = find_missing_env_vars(required_env_vars,
|
244
|
+
ambiguous = detect_ambiguous_env_vars(profile_env_vars)
|
245
|
+
missing_env_vars = find_missing_env_vars(required_env_vars, profile_env_vars)
|
269
246
|
|
270
247
|
if ambiguous:
|
271
248
|
logger.warning(
|
272
|
-
f"ambiguous env_vars: {ambiguous} (specified both in cli/env & in .env-manual file with different values)"
|
249
|
+
f"ambiguous env_vars: {ambiguous} (specified both in cli/env & in .env-(manual|vscode) file with different values)"
|
273
250
|
)
|
274
251
|
if missing_env_vars or ambiguous:
|
275
252
|
raise EnvVarsError(missing_env_vars, ambiguous)
|
276
253
|
|
277
|
-
|
254
|
+
if new_updates := {k: v for k, v in profile_env_vars.items() if k not in os.environ}:
|
255
|
+
logger.info(f"loading env-vars {','.join(sorted(new_updates))}")
|
256
|
+
os.environ |= new_updates
|
278
257
|
for cls in settings_classes:
|
279
258
|
cls() # ensure any errors are raised
|
280
259
|
return AtlasInitSettings.from_env()
|
260
|
+
|
261
|
+
|
262
|
+
def env_vars_cls_or_none(t: type[T], *, dotenv_path: Path | None = None) -> T | None:
|
263
|
+
explicit_vars: dict[str, str] = {}
|
264
|
+
if dotenv_path and dotenv_path.exists():
|
265
|
+
explicit_vars = load_dotenv(dotenv_path)
|
266
|
+
with suppress(ValidationError):
|
267
|
+
return t(**explicit_vars)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: atlas-init
|
3
|
-
Version: 0.4.
|
3
|
+
Version: 0.4.5
|
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
|
@@ -1,4 +1,4 @@
|
|
1
|
-
atlas_init/__init__.py,sha256=
|
1
|
+
atlas_init/__init__.py,sha256=0T7e5_mcm1rEvHTaZjzLUBsldG8S1Wg6ilQOz8p_5a4,213
|
2
2
|
atlas_init/__main__.py,sha256=dY1dWWvwxRZMmnOFla6RSfti-hMeLeKdoXP7SVYqMUc,52
|
3
3
|
atlas_init/atlas_init.yaml,sha256=Q_gFMbTa8OKxS8GbjszyrMA05nap8HI_Oe-cgQZNEPk,2351
|
4
4
|
atlas_init/cli.py,sha256=f7Y_i5_g8LrIE6GJRCQrpF4gN9HMSL3I_y1TYDfqwgw,9366
|
@@ -7,14 +7,14 @@ atlas_init/humps.py,sha256=l0ZXXuI34wwd9TskXhCjULfGbUyK-qNmiyC6_2ow6kU,7339
|
|
7
7
|
atlas_init/terraform.yaml,sha256=qPrnbzBEP-JAQVkYadHsggRnDmshrOJyiv0ckyZCxwY,2734
|
8
8
|
atlas_init/typer_app.py,sha256=icuru2-TzP7FtSIfXZRe4WbANVvYBexD5awKzpWTszo,4200
|
9
9
|
atlas_init/cli_cfn/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
|
-
atlas_init/cli_cfn/app.py,sha256=
|
10
|
+
atlas_init/cli_cfn/app.py,sha256=N0z4LtAyfnKAZHlrWNQ0m5TbmarECrwXBH1qp-0xkrA,6025
|
11
11
|
atlas_init/cli_cfn/aws.py,sha256=KtJWJmYDknPFtd4j6evMFRwmnFGcLYUFHArV6J49TjI,17911
|
12
|
-
atlas_init/cli_cfn/cfn_parameter_finder.py,sha256=
|
13
|
-
atlas_init/cli_cfn/contract.py,sha256=
|
14
|
-
atlas_init/cli_cfn/example.py,sha256=
|
12
|
+
atlas_init/cli_cfn/cfn_parameter_finder.py,sha256=HWm8I2IPPZlvwyXCjTxoqZhh-eUk9fHUKdiBVlhM2GQ,9411
|
13
|
+
atlas_init/cli_cfn/contract.py,sha256=u3kL_g_pIixMp1FkPgue19U57vGTdK7qWFiK-gs2YIA,7834
|
14
|
+
atlas_init/cli_cfn/example.py,sha256=WFDWHHrOWIljmWlbcLY5K3rSIGoZu7G5lwuamHGghJI,8607
|
15
15
|
atlas_init/cli_cfn/files.py,sha256=kwKDh__O__it2Shz3pHhnle4XUesRd4P929twxUODfI,2651
|
16
16
|
atlas_init/cli_helper/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
17
|
-
atlas_init/cli_helper/go.py,sha256
|
17
|
+
atlas_init/cli_helper/go.py,sha256=-K3tg-OAqPyKiebiBQFxnM-eNPlmjaKIxQnDRtsx_NQ,9833
|
18
18
|
atlas_init/cli_helper/run.py,sha256=va1eFP-hRvM76lVzvqH8eqGnyfcbzgR0zCMbL9Neb58,3660
|
19
19
|
atlas_init/cli_helper/run_manager.py,sha256=USNRHSm1zuu4H9NRamnxQ2D4gKzrHLk8dZe0G95Be14,9022
|
20
20
|
atlas_init/cli_helper/sdk.py,sha256=exh58-VZwxtosaxM269C62EEy1VnpJPOVziPDPkGsmE,2983
|
@@ -22,7 +22,7 @@ atlas_init/cli_helper/sdk_auto_changes.py,sha256=oWyXw7P0PdO28hclRvza_RcIVXAyzu0
|
|
22
22
|
atlas_init/cli_helper/tf_runner.py,sha256=V8pfxPSDBSeQWkR27kI8JLu-MEadUR9TGnoXBjSP4G4,3610
|
23
23
|
atlas_init/cli_root/__init__.py,sha256=Mf0wqy4kqq8pmbjLa98zOGuUWv0bLk2OYGc1n1_ZmZ4,223
|
24
24
|
atlas_init/cli_root/go_test.py,sha256=roQIOS-qVfNhJMztR-V3hjtxFMf7-Ioy3e1ffqtTRyo,4601
|
25
|
-
atlas_init/cli_root/trigger.py,sha256=
|
25
|
+
atlas_init/cli_root/trigger.py,sha256=5TMc_depk9MOkfEfq3WWWgyCpPmAvoZywmeNnU0QZGg,8520
|
26
26
|
atlas_init/cli_tf/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
27
27
|
atlas_init/cli_tf/app.py,sha256=Y3cAj8XbOT8FESSpVagOuQyfplWSaJPz9lYiigyNj0M,11611
|
28
28
|
atlas_init/cli_tf/changelog.py,sha256=biWYKf1pZvXZ-jEgcZ5q9sY7nTGrL2PuI0h9mCILf_g,3181
|
@@ -60,7 +60,7 @@ atlas_init/repos/go_sdk.py,sha256=1OzM9DjHEAzAAuI9ygoRRuhUK2gqpOhXExXRqhqa0tg,17
|
|
60
60
|
atlas_init/repos/path.py,sha256=5XsXrxpyQi2bkV_qOtbIhL7-XGwW68XUmCTOdyfoz1A,4517
|
61
61
|
atlas_init/settings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
62
62
|
atlas_init/settings/config.py,sha256=Cb483vmKOnNUK6m5KlhDiGeDJcZoJ1vHREdiddYONuQ,7037
|
63
|
-
atlas_init/settings/env_vars.py,sha256=
|
63
|
+
atlas_init/settings/env_vars.py,sha256=lqHL1UC6PxS9Vk3SvyfCVFUxCUQAk39XeAFnJ0HKloo,9291
|
64
64
|
atlas_init/settings/env_vars_generated.py,sha256=eUKjyv0pFxWGzbSpAdjHnx3v2t1rtioV4wdNFwEg8J8,2121
|
65
65
|
atlas_init/settings/env_vars_modules.py,sha256=fqVndOn8ZesuudijakzPZKsrXnm-iezGHvVx2bOng2o,1810
|
66
66
|
atlas_init/settings/interactive.py,sha256=Xy1Z5WMAOSaJ-vQI_4xjAbSR92rWQgnffwVoDT27L68,340
|
@@ -98,8 +98,8 @@ atlas_init/tf/modules/vpc_peering/vpc_peering.tf,sha256=hJ3KJdGbLpOQednUpVuiJ0Cq
|
|
98
98
|
atlas_init/tf/modules/vpc_privatelink/atlas-privatelink.tf,sha256=FloaaX1MNDvoMZxBnEopeLKyfIlq6kaX2dmx8WWlXNU,1298
|
99
99
|
atlas_init/tf/modules/vpc_privatelink/variables.tf,sha256=gktHCDYD4rz6CEpLg5aiXcFbugw4L5S2Fqc52QYdJyc,255
|
100
100
|
atlas_init/tf/modules/vpc_privatelink/versions.tf,sha256=G0u5V_Hvvrkux_tqfOY05pA-GzSp_qILpfx1dZaTGDc,237
|
101
|
-
atlas_init-0.4.
|
102
|
-
atlas_init-0.4.
|
103
|
-
atlas_init-0.4.
|
104
|
-
atlas_init-0.4.
|
105
|
-
atlas_init-0.4.
|
101
|
+
atlas_init-0.4.5.dist-info/METADATA,sha256=bXkM3--BfYHokuVp5f7iuFIaCkIIAJoZgrst1aNwZZc,5723
|
102
|
+
atlas_init-0.4.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
103
|
+
atlas_init-0.4.5.dist-info/entry_points.txt,sha256=oSNFIEAS9nUZyyZ8Fc-0F0U5j-NErygy01LpJVSHapQ,57
|
104
|
+
atlas_init-0.4.5.dist-info/licenses/LICENSE,sha256=aKnucPyXnK1A-aXn4vac71zRpcB5BXjDyl4PDyi_hZg,1069
|
105
|
+
atlas_init-0.4.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|