Skip to content

Commit 81581a9

Browse files
Formatting
1 parent 11917b7 commit 81581a9

File tree

5 files changed

+20
-16
lines changed

5 files changed

+20
-16
lines changed

leverage/_backend_config.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,15 @@ def set_backend_key(config_file_path: Union[str, Path], key: str) -> None:
5151
and isinstance(config_tf["terraform"][0]["backend"], list)
5252
and "s3" in config_tf["terraform"][0]["backend"][0]
5353
):
54-
raise ExitError(1, f"Malformed config.tf: File must contain a terraform block with an S3 backend. "
54+
raise ExitError(
55+
1,
56+
f"Malformed config.tf: File must contain a terraform block with an S3 backend. "
5557
f"Expected structure:\n"
5658
f"terraform {{\n"
5759
f' backend "s3" {{\n'
5860
f" # configuration\n"
5961
f" }}\n"
60-
f"}}"
62+
f"}}",
6163
)
6264

6365
# Check if key already exists
@@ -157,7 +159,7 @@ def get_backend_key(config_file: Union[str, Path]) -> Optional[str]:
157159
1,
158160
f"Malformed [bold]config.tf[/bold] file. Missing backend block.\n"
159161
f"In some cases you may want to skip this check by using the --skip-validation flag, "
160-
f"e.g. the first time you initialize a tf-backend layer."
162+
f"e.g. the first time you initialize a tf-backend layer.",
161163
)
162164

163165
except lark.exceptions.UnexpectedInput as error:

leverage/leverage.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99

1010
from leverage import __version__, conf
1111
from leverage._internals import pass_state
12+
1213
# from leverage.modules.credentials import credentials
1314
from leverage.modules import aws, run, tofu, terraform
15+
1416
# from leverage.modules import run, project, tofu, terraform, tfautomv, kubectl, shell
1517
from leverage.path import NotARepositoryError, PathsHandler
1618

@@ -34,6 +36,7 @@ def leverage(context, state, verbose):
3436
return
3537
state.paths = PathsHandler(state.config)
3638

39+
3740
# Add modules to leverage
3841
leverage.add_command(run)
3942
# leverage.add_command(project)
@@ -44,4 +47,4 @@ def leverage(context, state, verbose):
4447
leverage.add_command(aws)
4548
# leverage.add_command(tfautomv)
4649
# leverage.add_command(kubectl)
47-
# leverage.add_command(kubectl, name="kc")
50+
# leverage.add_command(kubectl, name="kc")

leverage/modules/aws.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,12 @@ def login(awscli: Runner, paths: PathsHandler) -> None:
251251
logger.info(
252252
f"Attempting to automatically open the SSO authorization page in your default browser.\n"
253253
f"If the browser does not open or you wish to use a different device to authorize this request, open the following URL:\n"
254-
f"\n{paths.common_conf.get("sso_start_url")}\n"
254+
f"\n{paths.common_conf.get('sso_start_url')}\n"
255255
f"\nThen enter the code:\n"
256-
f"\n{device_authorization["userCode"]}\n"
256+
f"\n{device_authorization['userCode']}\n"
257257
)
258258
webbrowser.open_new_tab(
259-
f"{paths.common_conf.get("sso_start_url")}/#/device?user_code={device_authorization["userCode"]}"
259+
f"{paths.common_conf.get('sso_start_url')}/#/device?user_code={device_authorization['userCode']}"
260260
)
261261

262262
logger.debug(f"Attempting to create authorization token...")

leverage/modules/tf.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,10 @@ def tf_default_args(paths: PathsHandler) -> tuple:
144144
parameters for OpenTofu/Terraform.
145145
"""
146146
common_config_files = tuple(
147-
f"-var-file={common_file.as_posix()}"
148-
for common_file in paths.common_config_dir.glob("*.tfvars")
147+
f"-var-file={common_file.as_posix()}" for common_file in paths.common_config_dir.glob("*.tfvars")
149148
)
150149
account_config_files = tuple(
151-
f"-var-file={account_file.as_posix()}"
152-
for account_file in paths.account_config_dir.glob("*.tfvars")
150+
f"-var-file={account_file.as_posix()}" for account_file in paths.account_config_dir.glob("*.tfvars")
153151
)
154152
return common_config_files + account_config_files
155153

@@ -314,10 +312,12 @@ def validate_for_all_commands(layer, skip_validation=False):
314312
"""
315313
logger.debug(f"Checking layer {layer}...")
316314
if not skip_validation and not _validate_layout(layer):
317-
raise ExitError(1,
315+
raise ExitError(
316+
1,
318317
"Layer configuration doesn't seem to be valid. Exiting.\n"
319318
"If you are sure your configuration is actually correct "
320-
"you may skip this validation using the --skip-validation flag.")
319+
"you may skip this validation using the --skip-validation flag.",
320+
)
321321

322322

323323
# ###########################################################################
@@ -352,6 +352,7 @@ def _plan(tf: TFRunner, paths: PathsHandler, args: Sequence[str], working_dir: P
352352
if exit_code := tf.run("plan", *tf_default_args(), *args, working_dir=working_dir):
353353
raise Exit(exit_code)
354354

355+
355356
def has_a_plan_file(args: Sequence[str]) -> bool:
356357
"""Determine whether the list of arguments has a plan file at the end.
357358

leverage/modules/tfrunner.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ def run(
5555
"""
5656
return super().run(*args, env_vars=env_vars, working_dir=working_dir, interactive=interactive)
5757

58-
def exec(
59-
self, *args: str, env_vars: Optional[Dict[str, str]] = None, working_dir: Optional[Path] = None
60-
):
58+
def exec(self, *args: str, env_vars: Optional[Dict[str, str]] = None, working_dir: Optional[Path] = None):
6159
"""
6260
Execute the Terraform/OpenTofu binary in non-interactive mode (captures output).
6361

0 commit comments

Comments
 (0)