Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge V2 - V3 compose file formats (optional version field) #7588

Merged
merged 7 commits into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions compose/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def project_from_options(project_dir, options, additional_options=None):
context=context,
environment=environment,
override_dir=override_dir,
compatibility=compatibility_from_options(project_dir, options, environment),
interpolate=(not additional_options.get('--no-interpolate')),
environment_file=environment_file
)
Expand Down Expand Up @@ -98,7 +97,6 @@ def get_config_from_options(base_dir, options, additional_options=None):
)
return config.load(
config.find(base_dir, config_path, environment, override_dir),
compatibility_from_options(config_path, options, environment),
not additional_options.get('--no-interpolate')
)

Expand All @@ -120,14 +118,14 @@ def unicode_paths(paths):

def get_project(project_dir, config_path=None, project_name=None, verbose=False,
context=None, environment=None, override_dir=None,
compatibility=False, interpolate=True, environment_file=None):
interpolate=True, environment_file=None):
aiordache marked this conversation as resolved.
Show resolved Hide resolved
if not environment:
environment = Environment.from_env_file(project_dir)
config_details = config.find(project_dir, config_path, environment, override_dir)
project_name = get_project_name(
config_details.working_dir, project_name, environment
)
config_data = config.load(config_details, compatibility, interpolate)
config_data = config.load(config_details, interpolate)

api_version = environment.get(
'COMPOSE_API_VERSION',
Expand Down Expand Up @@ -188,13 +186,3 @@ def normalize_name(name):
return normalize_name(project)

return 'default'


def compatibility_from_options(working_dir, options=None, environment=None):
"""Get compose v3 compatibility from --compatibility option
or from COMPOSE_COMPATIBILITY environment variable."""

compatibility_option = options.get('--compatibility')
compatibility_environment = environment.get_boolean('COMPOSE_COMPATIBILITY')

return compatibility_option or compatibility_environment
17 changes: 5 additions & 12 deletions compose/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from ..config.environment import Environment
from ..config.serialize import serialize_config
from ..config.types import VolumeSpec
from ..const import COMPOSEFILE_V2_2 as V2_2
from ..const import IS_WINDOWS_PLATFORM
from ..errors import StreamParseError
from ..progress_stream import StreamOutputError
Expand Down Expand Up @@ -205,7 +204,7 @@ class TopLevelCommand(object):
--project-directory PATH Specify an alternate working directory
(default: the path of the Compose file)
--compatibility If set, Compose will attempt to convert keys
in v3 files to their non-Swarm equivalent
in v3 files to their non-Swarm equivalent (DEPRECATED)
--env-file PATH Specify an alternate environment file

Commands:
Expand Down Expand Up @@ -882,16 +881,10 @@ def scale(self, options):
"""
timeout = timeout_from_opts(options)

if self.project.config_version == V2_2:
raise UserError(
'The scale command is incompatible with the v2.2 format. '
'Use the up command with the --scale flag instead.'
)
else:
log.warning(
'The scale command is deprecated. '
'Use the up command with the --scale flag instead.'
)
log.warning(
'The scale command is deprecated. '
'Use the up command with the --scale flag instead.'
)

for service_name, num in parse_scale_args(options['SERVICE=NUM']).items():
self.project.get_service(service_name).scale(num, timeout=timeout)
Expand Down
Loading