Skip to content

Commit

Permalink
cleanup environment
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiusens committed Apr 23, 2018
1 parent 9bd75a5 commit 23b67c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
7 changes: 5 additions & 2 deletions snapcraft/cli/env.py
Expand Up @@ -42,9 +42,12 @@ class BuilderEnvironmentConfig:
results in an error.
"""

def __init__(self, *, additional_providers: List[str]=None) -> None:
def __init__(self, *, default='host',
additional_providers: List[str]=None) -> None:
"""Instantiate a BuildEnvironmentConfig.
:param str default: the default provider to use among the list of valid
ones.
:param str additional_providers: Additional providers allowed in the
environment.
"""
Expand Down Expand Up @@ -76,7 +79,7 @@ def __init__(self, *, additional_providers: List[str]=None) -> None:
if use_lxd:
build_provider = 'lxd'
elif not build_provider:
build_provider = 'host'
build_provider = default
elif build_provider not in valid_providers:
raise errors.SnapcraftEnvironmentError(
'SNAPCRAFT_BUILD_ENVIRONMENT must be one of: {}.'.format(
Expand Down
8 changes: 3 additions & 5 deletions snapcraft/cli/lifecycle.py
Expand Up @@ -211,13 +211,11 @@ def cleanbuild(remote, debug, **kwargs):
If using a remote, a prior setup is required which is described on:
https://linuxcontainers.org/lxd/getting-started-cli/#multiple-hosts
"""
build_environment = env.BuilderEnvironmentConfig(
additional_providers=['multipass'])
# cleanbuild is a special snow flake, while all the other commands
# would work with the host as the build_provider it makes little
# sense in this scenario, so change it back to the default of lxd.
if build_environment.is_host:
build_environment.provider = 'lxd'
# sense in this scenario.
build_environment = env.BuilderEnvironmentConfig(
default='lxd', additional_providers=['multipass'])
project_options = get_project_options(**kwargs, debug=debug)
lifecycle.cleanbuild(project=project_options,
echoer=echo,
Expand Down

0 comments on commit 23b67c4

Please sign in to comment.