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

add lookup resolution to envvars command #216

Merged
merged 2 commits into from
Apr 3, 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- lookups are now resolved when using the `runway envvars` command

## Added
- ACM CloudFormation hook

Expand Down
27 changes: 17 additions & 10 deletions runway/commands/runway/envvars.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
"""
from __future__ import print_function
from typing import Dict # noqa pylint: disable=unused-import

import logging
import os
import platform
import sys
from typing import Dict # noqa pylint: disable=unused-import

from ..runway_command import RunwayCommand, get_env
from ...context import Context
from ...util import merge_dicts, merge_nested_environment_dicts
from ..runway_command import RunwayCommand, get_env

LOGGER = logging.getLogger('runway')

Expand All @@ -43,18 +45,23 @@ class EnvVars(RunwayCommand):

def execute(self):
"""Output Runway-defined environment variables."""
if self.runway_config.get('deployments'):
if self.runway_config.deployments:
context = Context(
env_name=get_env(self.env_root,
self.runway_config.ignore_git_branch),
env_region=None,
env_root=self.env_root,
env_vars=os.environ.copy()
)
env_vars = {}
for i in self.runway_config.get('deployments'):
env_vars = merge_dicts(env_vars, i.get('env_vars', {}))
for deployment in self.runway_config.deployments:
deployment.resolve(context, self.runway_vars)
env_vars = merge_dicts(env_vars, deployment.env_vars)
if env_vars:
env_vars = merge_nested_environment_dicts(
env_vars,
env_name=get_env(
os.getcwd(),
ignore_git_branch=self.runway_config.get('ignore_git_branch'),
),
env_root=os.getcwd()
env_name=context.env_name,
env_root=context.env_root
)

if 'MSYSTEM' in os.environ and (
Expand Down