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

binbashar / leverage / 11222088369

07 Oct 2024 06:55PM UTC coverage: 59.901% (-9.3%) from 69.151%
11222088369

push

github

web-flow
[BV-195] Run toolbox with the host user (#269)

* chore: building local image + adapting code

* path fixes

* update tests

* make it a package so poetry doesn't complain

* user newer image (that supports groupadd/useradd binaries)

* tweaks

* verify if image already exists locally

* fix coverage path

* ensure_image unit tests

* Feature/support python 3.12 (#279)

* adding python 3.12 in pyproject.toml

* autogenerating python 3.12 in poetry.lock

* keep using scripts from toolbox

* fix test references

* removing ipdb

* merge master

* Bump default Toolbox-version to 1.3.2-0.2.0

---------

Co-authored-by: Exequiel Barrirero <exequielrafaela@users.noreply.github.com>
Co-authored-by: Angelo Fenoglio <angelo.fenoglio@binbash.com.ar>

206 of 504 branches covered (40.87%)

Branch coverage included in aggregate %.

65 of 69 new or added lines in 5 files covered. (94.2%)

4 existing lines in 1 file now uncovered.

2450 of 3930 relevant lines covered (62.34%)

0.62 hits per line

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

41.67
/leverage/modules/shell.py
1
import click
1✔
2

3
from leverage._utils import CustomEntryPoint
1✔
4
from leverage.container import get_docker_client, TerraformContainer
1✔
5
from leverage.modules.utils import env_var_option, mount_option, auth_sso, auth_mfa
1✔
6

7

8
@click.command()
1✔
9
@mount_option
1✔
10
@env_var_option
1✔
11
@auth_mfa
1✔
12
@auth_sso
1✔
13
def shell(mount, env_var, mfa, sso):
1✔
14
    """
15
    Run a shell in a generic container. It supports mounting local paths and injecting arbitrary environment variables.
16
    It also supports AWS credentials injection via mfa/sso.
17

18
    Syntax:
19
    leverage shell --mount <local-path> <container-path> --env-var <name> <value>
20

21
    Example:
22
    leverage shell --mount /home/user/bin/ /usr/bin/ --env-var env dev
23

24
    Both mount and env-var parameters can be provided multiple times.
25

26
    Example:
27
    leverage shell --mount /home/user/bin/ /usr/bin/ --mount /etc/config.ini /etc/config.ini --env-var init 5 --env-var env dev
28
    """
29
    if env_var:
×
30
        env_var = dict(env_var)
×
31
    # TODO: TerraformContainer is the only class supporting sso/mfa auth automagically
32
    #       Move this capacity into a mixin later
33
    container = TerraformContainer(get_docker_client(), mounts=mount, env_vars=env_var)
×
34
    container.ensure_image()
×
35

36
    # auth
37
    container.disable_authentication()
×
38
    if sso:
×
39
        container.enable_sso()
×
40
    if mfa:
×
41
        container.enable_mfa()
×
42

43
    with CustomEntryPoint(container, entrypoint=""):
×
44
        container._start(container.SHELL)
×
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

© 2026 Coveralls, Inc