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

fix: Make default_environment a top-level setting #6582

Merged
merged 2 commits into from Aug 9, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/meltano/cli/cli.py
@@ -1,6 +1,8 @@
"""Definition of the top-level Click group for the Meltano CLI."""

from __future__ import annotations

import logging # noqa: D100
import logging
import sys
from typing import NoReturn

Expand Down Expand Up @@ -77,11 +79,13 @@ def cli( # noqa: WPS231
ProjectSettingsService.config_override["cli.log_config"] = log_config

ctx.obj["verbosity"] = verbose

try: # noqa: WPS229
project = Project.find()
setup_logging(project)
project_setting_service = ProjectSettingsService(project)

readonly = ProjectSettingsService(project).get("project_readonly")
readonly = project_setting_service.get("project_readonly")
if readonly:
project.readonly = True
if project.readonly:
Expand All @@ -94,8 +98,8 @@ def cli( # noqa: WPS231
logger.info("No environment is active")
elif environment:
selected_environment = environment
elif project.meltano.default_environment:
selected_environment = project.meltano.default_environment
elif project_setting_service.get("default_environment"):
selected_environment = project_setting_service.get("default_environment")
is_default_environment = True
# activate environment
if selected_environment:
Expand Down
2 changes: 2 additions & 0 deletions src/meltano/core/bundle/settings.yml
@@ -1,5 +1,7 @@
settings:
# Project
- name: default_environment
value: dev
- name: send_anonymous_usage_stats
kind: boolean
value: true
Expand Down
3 changes: 0 additions & 3 deletions src/meltano/core/meltano_file.py
Expand Up @@ -20,7 +20,6 @@ class MeltanoFile(Canonical):
def __init__(
self,
version: int = VERSION,
default_environment: str | None = None,
plugins: dict[str, dict] = None,
schedules: list[dict] = None,
environments: list[dict] = None,
Expand All @@ -32,7 +31,6 @@ def __init__(

Args:
version: The meltano.yml version, currently always 1.
default_environment: The default environment to use for commands in this project.
plugins: Plugin configuration for this project.
schedules: Schedule configuration for this project.
environments: Environment configuration for this project.
Expand All @@ -43,7 +41,6 @@ def __init__(
super().__init__(
# Attributes will be listed in meltano.yml in this order:
version=version,
default_environment=default_environment,
extras=extras,
plugins=self.load_plugins(plugins or {}),
schedules=self.load_schedules(schedules or []),
Expand Down