aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/rlx_config.erl8
-rw-r--r--src/rlx_prv_overlay.erl21
-rw-r--r--test/rlx_release_SUITE.erl5
3 files changed, 17 insertions, 17 deletions
diff --git a/src/rlx_config.erl b/src/rlx_config.erl
index ee58db5..b341ae7 100644
--- a/src/rlx_config.erl
+++ b/src/rlx_config.erl
@@ -303,8 +303,9 @@ list_of_overlay_vars_files(undefined) ->
[];
list_of_overlay_vars_files([]) ->
[];
-list_of_overlay_vars_files([H | _]=FileNames) when erlang:is_list(H) ->
- FileNames;
+list_of_overlay_vars_files([H | _]=Vars) when erlang:is_list(H) ;
+ is_tuple(H) ->
+ Vars;
list_of_overlay_vars_files(FileName) when is_list(FileName) ->
[FileName].
@@ -328,7 +329,8 @@ merge_configs([{Key, Value} | CliTerms], ConfigTerms) ->
end;
overlay_vars ->
case lists:keyfind(overlay_vars, 1, ConfigTerms) of
- {_, [H | _] = Vars} when is_list(H) ->
+ {_, [H | _] = Vars} when is_list(H) ;
+ is_tuple(H) ->
MergedValue = Vars ++ Value,
merge_configs(CliTerms, lists:keyreplace(overlay_vars, 1, ConfigTerms, {Key, MergedValue}));
{_, Vars} when is_list(Vars) ->
diff --git a/src/rlx_prv_overlay.erl b/src/rlx_prv_overlay.erl
index 645f691..516d238 100644
--- a/src/rlx_prv_overlay.erl
+++ b/src/rlx_prv_overlay.erl
@@ -145,7 +145,8 @@ get_overlay_vars_from_file(State, OverlayVars) ->
OverlayVars;
[] ->
OverlayVars;
- [H | _]=FileNames when is_list(H) ->
+ [H | _]=FileNames when is_list(H) ;
+ is_tuple(H) ->
read_overlay_vars(State, OverlayVars, FileNames);
FileName when is_list(FileName) ->
read_overlay_vars(State, OverlayVars, [FileName])
@@ -181,30 +182,24 @@ check_overlay_inclusion(_State, _RelativeRoot, [], Terms) ->
proplists:proplist().
merge_overlay_vars(State, FileNames) ->
RelativeRoot = get_relative_root(State),
- lists:foldl(fun(FileName, Acc) ->
- RelativePath = filename:join(RelativeRoot, erlang:iolist_to_binary(FileName)),
+ lists:foldl(fun(FileName, Acc) when is_list(FileName) ->
+ RelativePath = filename:join(RelativeRoot, 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);
{ok, Terms} ->
%% 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:foldl(fun(NewTerm, A) ->
- lists:keystore(element(1, NewTerm), 1, A, NewTerm)
+ lists:keystore(element(1, NewTerm), 1, A, NewTerm)
end, Acc, NewTerms);
{error, Reason} ->
ec_cmd_log:warn(rlx_state:log(State),
format_error({unable_to_read_varsfile, FileName, Reason})),
Acc
- end
+ end;
+ (Var, Acc) ->
+ lists:keystore(element(1, Var), 1, Acc, Var)
end, [], FileNames).
-spec render_overlay_vars(proplists:proplist(), proplists:proplist(),
diff --git a/test/rlx_release_SUITE.erl b/test/rlx_release_SUITE.erl
index affc0ad..052b5c2 100644
--- a/test/rlx_release_SUITE.erl
+++ b/test/rlx_release_SUITE.erl
@@ -665,8 +665,10 @@ overlay_release(Config) ->
TestFileFull = filename:join(TestDirFull, TestFile),
SecondTestDir = "second_test_dir",
rlx_test_utils:write_config(ConfigFile,
- [{overlay_vars, [OverlayVars1, OverlayVars2, OverlayVars4]},
+ [{overlay_vars, [{var_list_dir, "non-file-variable-list"},
+ OverlayVars1, OverlayVars2, OverlayVars4]},
{overlay, [{mkdir, "{{target_dir}}/fooo"},
+ {mkdir, "{{target_dir}}/{{var_list_dir}}"},
{copy, OverlayVars1,
"{{target_dir}}/{{foo_dir}}/vars1.config"},
{copy, OverlayVars1,
@@ -727,6 +729,7 @@ overlay_release(Config) ->
?assert(lists:member({goal_app_2, "0.0.1"}, AppSpecs)),
?assert(lists:member({lib_dep_1, "0.0.1", load}, AppSpecs)),
+ ?assert(ec_file:exists(filename:join([OutputDir, "foo", "non-file-variable-list"]))),
?assert(ec_file:exists(filename:join([OutputDir, "foo", "fooo"]))),
?assert(ec_file:exists(filename:join([OutputDir, "foo", "foodir", "vars1.config"]))),
?assert(ec_file:exists(filename:join([OutputDir, "foo", "yahoo", "vars1.config"]))),