Skip to content

Commit

Permalink
fix: Make default_environment a top-level setting (meltano#6582)
Browse files Browse the repository at this point in the history
  • Loading branch information
WillDaSilva committed Aug 9, 2022
1 parent 27d5e58 commit 25c0aed
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
12 changes: 8 additions & 4 deletions src/meltano/cli/cli.py
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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

0 comments on commit 25c0aed

Please sign in to comment.