diff options
author | Tristan Sloughter <[email protected]> | 2015-03-31 17:48:17 -0500 |
---|---|---|
committer | Tristan Sloughter <[email protected]> | 2015-03-31 17:48:17 -0500 |
commit | f03450a49a906b7d0ea060f49cc651a8fa3f3b7b (patch) | |
tree | 3f47f9dd515980b5bf7cf4974fe1467107f09111 /src/rlx_prv_overlay.erl | |
parent | a2e8eaa4fb6307e0d71ba932de6eb9378ddae937 (diff) | |
parent | d1f1c8dc134cb1d4c832cfb0171ca7b859a2a600 (diff) | |
download | relx-f03450a49a906b7d0ea060f49cc651a8fa3f3b7b.tar.gz relx-f03450a49a906b7d0ea060f49cc651a8fa3f3b7b.tar.bz2 relx-f03450a49a906b7d0ea060f49cc651a8fa3f3b7b.zip |
Merge pull request #319 from lrascao/feature/support_overlay_inclusion
support overlay file inclusion
Diffstat (limited to 'src/rlx_prv_overlay.erl')
-rw-r--r-- | src/rlx_prv_overlay.erl | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/rlx_prv_overlay.erl b/src/rlx_prv_overlay.erl index ab0f74e..cdce915 100644 --- a/src/rlx_prv_overlay.erl +++ b/src/rlx_prv_overlay.erl @@ -161,6 +161,21 @@ read_overlay_vars(State, OverlayVars, FileNames) -> Error end. +-spec check_overlay_inclusion(rlx_state:t(), string(), proplists:proplist()) -> + proplists:proplist(). +check_overlay_inclusion(State, RelativeRoot, Terms) -> + check_overlay_inclusion(State, RelativeRoot, Terms, []). + +-spec check_overlay_inclusion(rlx_state:t(), string(), proplists:proplist(), proplists:proplist()) -> + proplists:proplist(). +check_overlay_inclusion(State, RelativeRoot, [File|T], Terms) when is_list(File) -> + IncludedTerms = merge_overlay_vars(State, [filename:join(RelativeRoot, File)]), + check_overlay_inclusion(State, RelativeRoot, T, Terms ++ IncludedTerms); +check_overlay_inclusion(State, RelativeRoot, [Tuple|T], Terms) -> + check_overlay_inclusion(State, RelativeRoot, T, Terms ++ [Tuple]); +check_overlay_inclusion(_State, _RelativeRoot, [], Terms) -> + Terms. + -spec merge_overlay_vars(rlx_state:t(), [file:name()]) -> proplists:proplist(). merge_overlay_vars(State, FileNames) -> @@ -169,7 +184,11 @@ merge_overlay_vars(State, FileNames) -> RelativePath = filename:join(RelativeRoot, erlang:iolist_to_binary(FileName)), case file:consult(RelativePath) of {ok, Terms} -> - lists:ukeymerge(1, lists:ukeysort(1, Terms), Acc); + % the location of the included overlay files will be relative + %% to the current one being read + OverlayRelativeRoot = filename:dirname(FileName), + NewTerms = check_overlay_inclusion(State, OverlayRelativeRoot, Terms), + lists:ukeymerge(1, lists:ukeysort(1, NewTerms), Acc); {error, Reason} -> ec_cmd_log:warn(rlx_state:log(State), format_error({unable_to_read_varsfile, FileName, Reason})), |