• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

binbashar / leverage / 13871569654

15 Mar 2025 09:25AM UTC coverage: 60.982% (+0.3%) from 60.662%
13871569654

Pull #299

github

Franr
black
Pull Request #299: BL-143 | Version warning

206 of 470 branches covered (43.83%)

Branch coverage included in aggregate %.

11 of 14 new or added lines in 2 files covered. (78.57%)

3 existing lines in 1 file now uncovered.

2576 of 4092 relevant lines covered (62.95%)

0.63 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.68
/leverage/leverage.py
1
"""
2
    Binbash Leverage Command-line tool.
3
"""
4

5
import rich
1✔
6
from packaging.version import Version
1✔
7

8
import click
1✔
9

10
from leverage import __version__, conf, MINIMUM_VERSIONS
1✔
11
from leverage._internals import pass_state
1✔
12
from leverage.modules.aws import aws
1✔
13
from leverage.modules.credentials import credentials
1✔
14
from leverage.modules import run, project, terraform, tfautomv, kubectl, shell
1✔
15
from leverage.path import NotARepositoryError
1✔
16

17

18
@click.group(invoke_without_command=True)
1✔
19
@click.option("-v", "--verbose", is_flag=True, help="Increase output verbosity.")
1✔
20
@click.version_option(version=__version__)
1✔
21
@pass_state
1✔
22
@click.pass_context
1✔
23
def leverage(context, state, verbose):
1✔
24
    """Leverage Reference Architecture projects command-line tool."""
25
    # --verbose | -v
26
    state.verbosity = verbose
1✔
27
    if context.invoked_subcommand is None:
1✔
28
        # leverage called with no subcommand
29
        click.echo(context.get_help())
1✔
30

31
    # if there is a version restriction set, make sure we satisfy it
32
    try:
1✔
33
        config = conf.load()
1✔
NEW
34
    except NotARepositoryError:
×
35
        # restrictions are only verified within a leverage project
NEW
36
        return
×
37

38
    # check if the current versions are lower than the minimum required
39
    if not (current_values := config.get("TERRAFORM_IMAGE_TAG")):
1✔
40
        # at some points of the project (the init), the config file is not created yet
NEW
41
        return
×
42
    # validate both TOOLBOX and TF versions
43
    for key, current in zip(MINIMUM_VERSIONS, current_values.split("-")):
1✔
44
        if Version(current) < Version(MINIMUM_VERSIONS[key]):
1✔
45
            rich.print(
1✔
46
                f"[red]WARNING[/red]\tYour current {key} version ({current}) is lower than the required minimum ({MINIMUM_VERSIONS[key]})."
47
            )
48

49

50
# Add modules to leverage
51
leverage.add_command(run)
1✔
52
leverage.add_command(project)
1✔
53
leverage.add_command(terraform)
1✔
54
leverage.add_command(terraform, name="tf")
1✔
55
leverage.add_command(credentials)
1✔
56
leverage.add_command(aws)
1✔
57
leverage.add_command(tfautomv)
1✔
58
leverage.add_command(kubectl)
1✔
59
leverage.add_command(kubectl, name="kc")
1✔
60
leverage.add_command(shell)
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc