mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 09:17:46 +01:00
Fallback to main secrets.yaml for packages (#5604)
This commit is contained in:
parent
f6e8d97981
commit
cfbf3681f3
1 changed files with 13 additions and 1 deletions
|
@ -18,6 +18,7 @@ from esphome.core import (
|
||||||
MACAddress,
|
MACAddress,
|
||||||
TimePeriod,
|
TimePeriod,
|
||||||
DocumentRange,
|
DocumentRange,
|
||||||
|
CORE,
|
||||||
)
|
)
|
||||||
from esphome.helpers import add_class_to_obj
|
from esphome.helpers import add_class_to_obj
|
||||||
from esphome.util import OrderedDict, filter_yaml_files
|
from esphome.util import OrderedDict, filter_yaml_files
|
||||||
|
@ -240,7 +241,18 @@ class ESPHomeLoader(yaml.SafeLoader):
|
||||||
|
|
||||||
@_add_data_ref
|
@_add_data_ref
|
||||||
def construct_secret(self, node):
|
def construct_secret(self, node):
|
||||||
|
try:
|
||||||
secrets = _load_yaml_internal(self._rel_path(SECRET_YAML))
|
secrets = _load_yaml_internal(self._rel_path(SECRET_YAML))
|
||||||
|
except EsphomeError as e:
|
||||||
|
if self.name == CORE.config_path:
|
||||||
|
raise e
|
||||||
|
try:
|
||||||
|
main_config_dir = os.path.dirname(CORE.config_path)
|
||||||
|
main_secret_yml = os.path.join(main_config_dir, SECRET_YAML)
|
||||||
|
secrets = _load_yaml_internal(main_secret_yml)
|
||||||
|
except EsphomeError as er:
|
||||||
|
raise EsphomeError(f"{e}\n{er}") from er
|
||||||
|
|
||||||
if node.value not in secrets:
|
if node.value not in secrets:
|
||||||
raise yaml.MarkedYAMLError(
|
raise yaml.MarkedYAMLError(
|
||||||
f"Secret '{node.value}' not defined", node.start_mark
|
f"Secret '{node.value}' not defined", node.start_mark
|
||||||
|
|
Loading…
Reference in a new issue