Skip to content

Commit

Permalink
add lookup resolution to envvars command (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
ITProKyle authored Apr 3, 2020
1 parent b1bf5b1 commit 4f7f7b1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
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

0 comments on commit 4f7f7b1

Please sign in to comment.