atlas-init 0.3.7__py3-none-any.whl → 0.4.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/typer_app.py CHANGED
@@ -7,16 +7,48 @@ import typer
7
7
 
8
8
  from atlas_init import running_in_repo
9
9
  from atlas_init.cli_cfn.app import app as app_cfn
10
+ from atlas_init.cli_helper.run import add_to_clipboard
11
+ from atlas_init.cli_root import set_dry_run
10
12
  from atlas_init.cli_tf.app import app as app_tf
13
+ from atlas_init.cloud.aws import download_from_s3, upload_to_s3
11
14
  from atlas_init.settings.env_vars import (
12
15
  DEFAULT_PROFILE,
13
- as_env_var_name,
14
- env_var_names,
16
+ ENV_CLIPBOARD_COPY,
17
+ ENV_PROFILE,
18
+ ENV_PROJECT_NAME,
19
+ ENV_S3_PROFILE_BUCKET,
20
+ init_settings,
15
21
  )
16
22
  from atlas_init.settings.rich_utils import configure_logging, hide_secrets
17
23
 
18
24
  logger = logging.getLogger(__name__)
19
- app = typer.Typer(name="atlas_init", invoke_without_command=True, no_args_is_help=True)
25
+
26
+
27
+ def sync_on_done(return_value, s3_profile_bucket: str = "", use_clipboard: str = "", **kwargs):
28
+ logger.info(f"sync_on_done return_value={return_value} and {kwargs}")
29
+ settings = init_settings(non_required=True)
30
+ if s3_profile_bucket:
31
+ logger.info(f"using s3 bucket for profile sync: {s3_profile_bucket}")
32
+ upload_to_s3(settings.profile_dir, s3_profile_bucket)
33
+ if use_clipboard:
34
+ settings = settings or init_settings()
35
+ match use_clipboard:
36
+ case "manual":
37
+ env_path = settings.env_file_manual
38
+ case _:
39
+ env_path = settings.env_vars_generated
40
+ if env_path.exists():
41
+ clipboard_content = "\n".join(f"export {line}" for line in env_path.read_text().splitlines())
42
+ add_to_clipboard(clipboard_content, logger)
43
+ logger.info(f"loaded env-vars from {env_path} to clipboard ✅")
44
+
45
+
46
+ app = typer.Typer(
47
+ name="atlas_init",
48
+ invoke_without_command=True,
49
+ no_args_is_help=True,
50
+ result_callback=sync_on_done,
51
+ )
20
52
  app.add_typer(app_cfn, name="cfn")
21
53
  app.add_typer(app_tf, name="tf")
22
54
 
@@ -41,26 +73,49 @@ def main(
41
73
  DEFAULT_PROFILE,
42
74
  "-p",
43
75
  "--profile",
44
- envvar=env_var_names("profile"),
76
+ envvar=ENV_PROFILE,
45
77
  help="used to load .env_manual, store terraform state and variables, and dump .env files.",
46
78
  ),
47
79
  project_name: str = typer.Option(
48
80
  "",
49
81
  "--project",
50
- envvar=env_var_names("project_name"),
82
+ envvar=ENV_PROJECT_NAME,
51
83
  help="atlas project name to create",
52
84
  ),
53
85
  show_secrets: bool = typer.Option(False, help="show secrets in the logs"),
86
+ dry_run: bool = typer.Option(False, help="dry-run mode"),
87
+ s3_profile_bucket: str = typer.Option(
88
+ "",
89
+ "-s3",
90
+ "--s3-profile-bucket",
91
+ help="s3 bucket to store profiles will be synced before and after the command",
92
+ envvar=ENV_S3_PROFILE_BUCKET,
93
+ ),
94
+ use_clipboard: str = typer.Option(
95
+ "",
96
+ help="add env-vars to clipboard, manual=.env-manual file, other value=.env-generated file",
97
+ envvar=ENV_CLIPBOARD_COPY,
98
+ ),
54
99
  ):
100
+ set_dry_run(dry_run)
55
101
  if profile != DEFAULT_PROFILE:
56
- os.environ[as_env_var_name("profile")] = profile
102
+ os.environ[ENV_PROFILE] = profile
57
103
  if project_name != "":
58
- os.environ[as_env_var_name("project_name")] = project_name
59
- log_handler = configure_logging(log_level)
60
- logger.info(f"running in repo: {running_in_repo()} python location:{sys.executable}")
61
- if not show_secrets:
62
- hide_secrets(log_handler, {**os.environ})
104
+ os.environ[ENV_PROJECT_NAME] = project_name
105
+ if use_clipboard:
106
+ os.environ[ENV_CLIPBOARD_COPY] = use_clipboard
107
+ is_running_in_repo = running_in_repo()
108
+ handler = configure_logging(app, log_level, is_running_in_repo=is_running_in_repo)
109
+ logger.info(f"running in atlas-init repo: {is_running_in_repo} python location:{sys.executable}")
63
110
  logger.info(f"in the app callback, log-level: {log_level}, command: {format_cmd(ctx)}")
111
+ if s3_bucket := s3_profile_bucket:
112
+ logger.info(f"using s3 bucket for profile sync: {s3_bucket}")
113
+ settings = init_settings(non_required=True)
114
+ download_from_s3(settings.profile_dir, s3_bucket)
115
+ settings = init_settings(required_env_vars=[])
116
+ if not show_secrets:
117
+ # must happen after init_settings that might load some env-vars
118
+ hide_secrets(handler, {**os.environ})
64
119
 
65
120
 
66
121
  def format_cmd(ctx: typer.Context) -> str:
@@ -1,11 +1,11 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: atlas-init
3
- Version: 0.3.7
3
+ Version: 0.4.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
7
7
  Author-email: EspenAlbert <albertespen@gmail.com>
8
- License: MIT
8
+ License-Expression: MIT
9
9
  Classifier: Development Status :: 4 - Beta
10
10
  Classifier: Programming Language :: Python
11
11
  Classifier: Programming Language :: Python :: 3.12
@@ -1,37 +1,39 @@
1
- atlas_init/__init__.py,sha256=6fPQOXGNVhrm-NHeu2MniZbhzKrbg2XjuDcXCG4gGqY,372
1
+ atlas_init/__init__.py,sha256=Apo32gKgpNqF8mnbsNQRTC3jDk0A8kgYlHfKm0SQkf8,372
2
2
  atlas_init/__main__.py,sha256=dY1dWWvwxRZMmnOFla6RSfti-hMeLeKdoXP7SVYqMUc,52
3
- atlas_init/atlas_init.yaml,sha256=OAosOZw4kjhTWcPeEv0jtztRFWRhsie8D9r5afySAxM,2065
4
- atlas_init/cli.py,sha256=xOnAOUccHDLkivICdF0GsLhccr_IxvnTKTbe1KGW7kU,8971
3
+ atlas_init/atlas_init.yaml,sha256=DN9zGb8Ll6krET9FgRSSYkvwLAaRNhrd1n-yPanbv9w,2283
4
+ atlas_init/cli.py,sha256=De4198R8ylSowyJlkhjbgboniu6BQcMtzNcHi9xdRC4,9246
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=nJbSuaAVhVzbxqNup1m5Nmszl2X3FOtZyI7Rjmz4JSs,2096
8
+ atlas_init/typer_app.py,sha256=RjOZRIV-hacWksgjLB0ip4DgA1fz5x-yHRWuSwSGEws,4254
9
9
  atlas_init/cli_cfn/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- atlas_init/cli_cfn/app.py,sha256=iMukpUDgsAgZh_U_APGZB3gmewOo-3vtFK0byJuDz9w,6649
11
- atlas_init/cli_cfn/aws.py,sha256=GbohR7uczSGwQjLEYozCmlxbeIHo1uwQIJMwsh7kF7M,17894
10
+ atlas_init/cli_cfn/app.py,sha256=DCwEp7kwJMytuy13jHr2M1jJ6sMWTthOc-LkHtNvoew,6104
11
+ atlas_init/cli_cfn/aws.py,sha256=NQ4vj6oN7m0SkOwoU5Og0iqrRIhSIhAgBbYj4zLlj38,17886
12
12
  atlas_init/cli_cfn/cfn_parameter_finder.py,sha256=tAadNF1M_U2BTY-m9fXVXFXNQRvfudOja97jT3AiVaI,10811
13
- atlas_init/cli_cfn/example.py,sha256=pQNpFreuv58O3lanLy5Kunp8GxG8i9PWjuWsYlpv2tg,8320
14
- atlas_init/cli_cfn/files.py,sha256=vjop9G8rGMgyRe4fX5eWNX5H-YGAmk-fNUqUGErI7xg,1720
13
+ atlas_init/cli_cfn/contract.py,sha256=6gRCvKRh6bn6BiQ3wyai_XNUwbWSqSRlg5GFvSdEcRc,7886
14
+ atlas_init/cli_cfn/example.py,sha256=_JuFyNEb7QvD4T8jQyAPI3TgnHW0wz0kVuncB5UkbEA,8530
15
+ atlas_init/cli_cfn/files.py,sha256=kwKDh__O__it2Shz3pHhnle4XUesRd4P929twxUODfI,2651
15
16
  atlas_init/cli_helper/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
- atlas_init/cli_helper/go.py,sha256=_ytiX-EUqdZdBvzchQVRmlbrbbdXw4sf_FJdsCtffb8,8412
17
- atlas_init/cli_helper/run.py,sha256=njE_ua8x_glOo6eOGa4NgZqpLcqOo3eALydrZ0bCXW4,3486
17
+ atlas_init/cli_helper/go.py,sha256=rD2xQpgPBhMfoj8q9V7r2nD6eLVK8VCiPD2NYBW8Df4,8636
18
+ atlas_init/cli_helper/run.py,sha256=wrt4YvMrqYhODbsSF-SRnqDw2LCu-gR7UPeURMMm6aE,3635
19
+ atlas_init/cli_helper/run_manager.py,sha256=JDIi6eRaTF6AEQE_s8cxMPf62k2nuh_tBNjFvL7dbZ8,8990
18
20
  atlas_init/cli_helper/sdk.py,sha256=exh58-VZwxtosaxM269C62EEy1VnpJPOVziPDPkGsmE,2983
19
21
  atlas_init/cli_helper/sdk_auto_changes.py,sha256=oWyXw7P0PdO28hclRvza_RcIVXAyzu0lCYTJTNBDMeo,189
20
- atlas_init/cli_helper/tf_runner.py,sha256=OYdC-Y6i-xRh8_LCudKdtP7CEYEO9e67nVhholN29eg,3636
21
- atlas_init/cli_root/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
- atlas_init/cli_root/go_test.py,sha256=tWQgIoL2K1XdQfvU7wlA1ckBULfC9XrrF6SUs928KWg,4438
23
- atlas_init/cli_root/trigger.py,sha256=oEgqb_l25tyYgUaFHEuChcOCJA7k3mnRa4D-Myz-Igs,5789
22
+ atlas_init/cli_helper/tf_runner.py,sha256=ZEh4WlI-6RV84uBtGNcFgAr8M03As-BLz4fu9wCPULw,3327
23
+ atlas_init/cli_root/__init__.py,sha256=Mf0wqy4kqq8pmbjLa98zOGuUWv0bLk2OYGc1n1_ZmZ4,223
24
+ atlas_init/cli_root/go_test.py,sha256=Xteq1zKqEtrejlSZPOXGgMq7LTxjbUPvsHZZ4o-PRT0,4593
25
+ atlas_init/cli_root/trigger.py,sha256=In3oS-z8gYYsPxQjHsGmqB1AsUtHPDTxwva5arsajvU,8227
24
26
  atlas_init/cli_tf/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
27
  atlas_init/cli_tf/app.py,sha256=0Y5c-Pc9ibOz6kXvFlL-yhH_fx1nHLgBgK9OAVqjX9s,11390
26
28
  atlas_init/cli_tf/changelog.py,sha256=biWYKf1pZvXZ-jEgcZ5q9sY7nTGrL2PuI0h9mCILf_g,3181
27
29
  atlas_init/cli_tf/debug_logs.py,sha256=NvIEtOb30aK_drYgNyYDsXt7uNtw6L9vhIZicANyDRQ,10022
28
- atlas_init/cli_tf/debug_logs_test_data.py,sha256=-KfhlVgp00zXzV0XMVbABEwKpBZ_r2B-cjBKLuhiBZU,9471
30
+ atlas_init/cli_tf/debug_logs_test_data.py,sha256=s85x78pFweVyqL2BchkLuvuG9hm-bwl8zcSO-IQqm6c,9736
29
31
  atlas_init/cli_tf/debug_logs_test_data_package_config.py,sha256=BOAgln1pWne_ZhP6a0SM2ddn2csr0sgGkYf2kMS_V9o,1666
30
- atlas_init/cli_tf/github_logs.py,sha256=VD7qhlXNuG21eTuJ5VI7rsflp5WHSodfngkRVgQlumw,8114
32
+ atlas_init/cli_tf/github_logs.py,sha256=ny-sr5UKxzE-6QzblyaCmJdHe7xNR1Om0smlQhq6qng,8257
31
33
  atlas_init/cli_tf/go_test_run.py,sha256=LQUQ-3zJ8EUCixwu33QTAzUns3um793osst8tE0UKjk,6792
32
34
  atlas_init/cli_tf/go_test_run_format.py,sha256=OUd6QPHDeTzbwVuh6MhP-xXgjOOGP9W_sCLJ8KylBTs,1201
33
35
  atlas_init/cli_tf/go_test_summary.py,sha256=agr4SITgxchjgOzRpScoTUk-iG38QDLkpnsMtTW9GTY,5382
34
- atlas_init/cli_tf/mock_tf_log.py,sha256=1Q5OWkDM1Dxac5vhG-vMVGScDBnXmwruZjsHDya5Uu4,7546
36
+ atlas_init/cli_tf/mock_tf_log.py,sha256=-ZOtQmy9w7k7HvrywMqlgohZ6Kerojk-P_xtiTaZ4sc,7555
35
37
  atlas_init/cli_tf/schema.py,sha256=iwvb4wD2Wba0MMu7ooTNAIi1jHbpLiXGPOT51_o_YW8,12431
36
38
  atlas_init/cli_tf/schema_go_parser.py,sha256=PiRfFFVnkhltxcGFfOCgH53wwzIEynw2BXmSfaINLL8,8294
37
39
  atlas_init/cli_tf/schema_inspection.py,sha256=ujLvGfg3baByND4nRD0drZoI45STxo3VfYvim-PfVOc,1764
@@ -49,17 +51,18 @@ atlas_init/cli_tf/hcl/cli.py,sha256=6V1kU_a1c4LA3rS7sWN821gQex00fb70AUyd07xO0es,
49
51
  atlas_init/cli_tf/hcl/cluster_mig.py,sha256=kMb_0V_XWr_iQj-mZZ-mmzIvYOLfuC4FYGYYSe9VKkQ,12496
50
52
  atlas_init/cli_tf/hcl/parser.py,sha256=NVe55u386U7YSKdT8ZCJ-rPV7O3BgNoyZ_bHsjxGYjQ,4814
51
53
  atlas_init/cloud/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
52
- atlas_init/cloud/aws.py,sha256=97kkURWHFAKDIw4704aFmyoeAfQKL11IXMyaQbZUt80,2473
54
+ atlas_init/cloud/aws.py,sha256=AXVobJ724S6OeEs_uXH9dvecc_klnXqejRnI7KaLyzo,4935
53
55
  atlas_init/repos/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
56
  atlas_init/repos/cfn.py,sha256=rjyVVxRhWL65tdAbEHT72UReK2h99Bj6RA4O2pBO-bc,2466
55
57
  atlas_init/repos/go_sdk.py,sha256=1OzM9DjHEAzAAuI9ygoRRuhUK2gqpOhXExXRqhqa0tg,1793
56
58
  atlas_init/repos/path.py,sha256=wrT8e01OBoAHj8iMrxqutgqWu-BHPe9-bEWtcZRu238,4187
57
59
  atlas_init/settings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
58
- atlas_init/settings/config.py,sha256=HIytZom8RRvpLGy6u8CpZ83tmFXI6v1tO3iSiuo08kc,6259
59
- atlas_init/settings/env_vars.py,sha256=mfpQp5Ja5tdW_mUg5Nqneb294JehQAheWNOpHvDLbg0,9844
60
+ atlas_init/settings/config.py,sha256=jQvLmPEocnXyfcKkTshp3TfQNPEuTayRauuOUqixPBA,6378
61
+ atlas_init/settings/env_vars.py,sha256=ZtpuRnCObUCki1RtwseGpm1Jd10wehWP9NneE-ZzJ84,10643
62
+ atlas_init/settings/env_vars_generated.py,sha256=0ae1KFgRMo4KzmfidI3oo_dkTWZy5uMEpx593qrwNaM,972
60
63
  atlas_init/settings/interactive.py,sha256=Xy1Z5WMAOSaJ-vQI_4xjAbSR92rWQgnffwVoDT27L68,340
61
64
  atlas_init/settings/path.py,sha256=KkXysu6-0AuSjsvYGknYGJX1hL2j1RD-Fpf8KsVYpkE,2618
62
- atlas_init/settings/rich_utils.py,sha256=5LgJUmc9wyJTsoS6xWKadrT0MoQREDaKvEOCuBLDXRg,1704
65
+ atlas_init/settings/rich_utils.py,sha256=aIENYZ18XDqpK-f8zSNwL8PnOlW4Wv0BUT4x3REWHBM,1993
63
66
  atlas_init/tf/.terraform.lock.hcl,sha256=DIojR50rr4fyLShYiQ-UpRV8z6vuBjwGWdK60FODoyM,6876
64
67
  atlas_init/tf/always.tf,sha256=ij6QKI8Lg0140bFZwOyiYK5c-2p5e7AGZ1qKbYyv6Os,1359
65
68
  atlas_init/tf/main.tf,sha256=DH0C8y9RDEHnSAZvL-TjE5MQjxj5ALfgk5zVO88cpZw,3960
@@ -88,7 +91,7 @@ atlas_init/tf/modules/vpc_peering/vpc_peering.tf,sha256=hJ3KJdGbLpOQednUpVuiJ0Cq
88
91
  atlas_init/tf/modules/vpc_privatelink/atlas-privatelink.tf,sha256=FloaaX1MNDvoMZxBnEopeLKyfIlq6kaX2dmx8WWlXNU,1298
89
92
  atlas_init/tf/modules/vpc_privatelink/variables.tf,sha256=gktHCDYD4rz6CEpLg5aiXcFbugw4L5S2Fqc52QYdJyc,255
90
93
  atlas_init/tf/modules/vpc_privatelink/versions.tf,sha256=G0u5V_Hvvrkux_tqfOY05pA-GzSp_qILpfx1dZaTGDc,237
91
- atlas_init-0.3.7.dist-info/METADATA,sha256=JsyU3TvkLcpLmTq0QDcuavjTz-J6l31nZf6qsTvljxs,5650
92
- atlas_init-0.3.7.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
93
- atlas_init-0.3.7.dist-info/entry_points.txt,sha256=oSNFIEAS9nUZyyZ8Fc-0F0U5j-NErygy01LpJVSHapQ,57
94
- atlas_init-0.3.7.dist-info/RECORD,,
94
+ atlas_init-0.4.0.dist-info/METADATA,sha256=VAQENKFxJsftUijGbvzjueVwsuiNsbOpEHlV7ZyQ-YQ,5661
95
+ atlas_init-0.4.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
96
+ atlas_init-0.4.0.dist-info/entry_points.txt,sha256=oSNFIEAS9nUZyyZ8Fc-0F0U5j-NErygy01LpJVSHapQ,57
97
+ atlas_init-0.4.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.26.3
2
+ Generator: hatchling 1.27.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any