diff options
-rw-r--r-- | src/rcl_prv_discover.erl | 16 | ||||
-rw-r--r-- | src/rcl_state.erl | 17 | ||||
-rw-r--r-- | test/rclt_release_SUITE.erl | 1 |
3 files changed, 19 insertions, 15 deletions
diff --git a/src/rcl_prv_discover.erl b/src/rcl_prv_discover.erl index 2f88354..10fb28b 100644 --- a/src/rcl_prv_discover.erl +++ b/src/rcl_prv_discover.erl @@ -48,9 +48,9 @@ do(State0) -> case rcl_rel_discovery:do(State0, LibDirs, AppMeta) of {ok, Releases} -> State1 = rcl_state:available_apps(State0, AppMeta), - State3 = lists:foldl(fun add_if_not_found/2, - State1, Releases), - {ok, State3}; + {ok, rcl_state:discovered_releases(State1, lists:foldl(fun add/2, + ec_dictionary:new(ec_dict), + Releases))}; Error -> Error end; @@ -68,16 +68,10 @@ format_error(_) -> %%% Internal Functions %%%=================================================================== %% @doc only add the release if its not documented in the system -add_if_not_found(Rel, State) -> +add(Rel, Dict) -> RelName = rcl_release:name(Rel), RelVsn = rcl_release:vsn(Rel), - try - rcl_state:get_release(State, RelName, RelVsn), - State - catch - throw:not_found -> - rcl_state:add_release(State, Rel) - end. + ec_dictionary:add({RelName, RelVsn}, Rel, Dict). get_lib_dirs(State) -> LibDirs0 = rcl_state:lib_dirs(State), diff --git a/src/rcl_state.erl b/src/rcl_state.erl index 6fd5655..6568541 100644 --- a/src/rcl_state.erl +++ b/src/rcl_state.erl @@ -42,6 +42,8 @@ get_release/3, update_release/2, releases/1, + discovered_releases/1, + discovered_releases/2, default_release/1, default_release/3, available_apps/1, @@ -72,9 +74,8 @@ default_release :: {rcl_release:name(), rcl_release:vsn()}, sys_config :: file:filename() | undefined, overrides :: [{AppName::atom(), Directory::file:filename()}], - releases :: ec_dictionary:dictionary({ReleaseName::atom(), - ReleaseVsn::string()}, - rcl_release:t()), + releases :: releases(), + discovered_releases :: releases(), config_values :: ec_dictionary:dictionary(Key::atom(), Value::term())}). @@ -87,6 +88,7 @@ rcl_release:t()). -type cmd_args() :: proplists:proplist(). -type caller() :: command_line | api. + -opaque t() :: record(state_t). %%============================================================================ @@ -107,6 +109,7 @@ new(PropList, Target) goals=proplists:get_value(goals, PropList, []), providers = [], releases=ec_dictionary:new(ec_dict), + discovered_releases=ec_dictionary:new(ec_dict), config_values=ec_dictionary:new(ec_dict), overrides = proplists:get_value(overrides, PropList, []), root_dir = proplists:get_value(root_dir, PropList, Root), @@ -197,6 +200,14 @@ get_release(#state_t{releases=Releases}, Name, Vsn) -> releases(#state_t{releases=Releases}) -> Releases. +-spec discovered_releases(t()) -> releases(). +discovered_releases(#state_t{discovered_releases=Releases}) -> + Releases. + +-spec discovered_releases(t(), releases()) -> t(). +discovered_releases(State, Releases) -> + State#state_t{discovered_releases=Releases}. + -spec default_release(t()) -> {rcl_release:name() | undefined, rcl_release:vsn() | undefined}. default_release(#state_t{default_release=Def}) -> diff --git a/test/rclt_release_SUITE.erl b/test/rclt_release_SUITE.erl index dd03b9f..b5ea9de 100644 --- a/test/rclt_release_SUITE.erl +++ b/test/rclt_release_SUITE.erl @@ -245,7 +245,6 @@ make_implicit_config_release(Config) -> {ok, FooRoot} = file:get_cwd(), {ok, State} = relcool:do(undefined, undefined, [], [LibDir1], 2, OutputDir, undefined), - [{{foo, "0.0.1"}, Release}] = ec_dictionary:to_list(rcl_state:releases(State)), ?assert(ec_file:exists(OutputDir)), AppSpecs = rcl_release:applications(Release), |