diff options
author | Bryan Paxton <39971740+starbelly@users.noreply.github.com> | 2019-03-07 10:54:01 -0600 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2019-03-07 09:54:01 -0700 |
commit | 209c02ec57c2cc3207ee0174c3af3675b8dc8f79 (patch) | |
tree | e07b25a27a2c4cc438db75d8d066179b4e57f3f7 /src/rebar_hex_repos.erl | |
parent | 9e2e54afd74104ecb05c55e033803f41932eb940 (diff) |
Fix fetching of private packages from orgs on hex repos (#2020)
- vendor in hex_core at v0.5.0
- Change where repo_name should be the org and not the parent
- Changed rebar_utils:url_append_path/2 to not explicitly add a '?',
this is returned in the Query chunk by http_uri:parse/1 (e.g., "?foo=bar")
- update organization_merging test to expect the sub-repo as the repo_name
- Add tests for rebar_utils:url_append_path/2
- Stop referencing/setting "organization" in config and use new
organization settings (api_repository and repo_organization)
- Do not set (assume) the read key is valid for any/every repo
- Set repo_organization and api_repository to org
- Update tests to check for new config opts
Diffstat (limited to 'src/rebar_hex_repos.erl')
-rw-r--r-- | src/rebar_hex_repos.erl | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/rebar_hex_repos.erl b/src/rebar_hex_repos.erl index babaa32..ed5b1a8 100644 --- a/src/rebar_hex_repos.erl +++ b/src/rebar_hex_repos.erl @@ -20,6 +20,7 @@ api_url => binary(), api_key => binary(), repo_url => binary(), + repo_key => binary(), repo_public_key => binary(), repo_verify => binary(), repo_verify_origin => binary()}. @@ -68,17 +69,21 @@ repos(HexConfig) -> merge_repos(RepoList ++ [HexDefaultConfig]) end. -%% merge repos must add a field repo_name to work with hex_core 0.4.0 +%% merge repos must add a field repo_name to work with r3_hex_core 0.5.0 -spec merge_repos([repo()]) -> [repo()]. merge_repos(Repos) -> - lists:foldl(fun(R=#{name := Name}, ReposAcc) -> - %% private organizations include the parent repo before a : + lists:foldl(fun(R = #{name := Name}, ReposAcc) -> + %% private orgs are in the format of <<"parent:org">> case rebar_string:split(Name, <<":">>) of [Repo, Org] -> - %% hex_core uses repo_name for parent + + %% We set the repo_organization and api_organization to org + %% for fetching and publishing private packages. update_repo_list(R#{name => Name, - repo_name => Repo, - organization => Org, + repo_name => Org, + repo_organization => Org, + api_organization => Org, + api_repository => Org, parent => Repo}, ReposAcc); _ -> update_repo_list(R#{repo_name => Name}, ReposAcc) @@ -86,15 +91,15 @@ merge_repos(Repos) -> end, [], Repos). update_organizations(Repos) -> - lists:map(fun(Repo=#{organization := Organization, + lists:map(fun(Repo=#{repo_name := RepoName, parent := ParentName}) -> {ok, Parent} = get_repo_config(ParentName, Repos), ParentRepoUrl = rebar_utils:to_list(maps:get(repo_url, Parent)), - {ok, RepoUrl} = + {ok, _RepoUrl} = rebar_utils:url_append_path(ParentRepoUrl, - filename:join("repos", rebar_utils:to_list(Organization))), + filename:join("repos", rebar_utils:to_list(RepoName))), %% still let the organization config override this constructed repo url - maps:merge(Parent#{repo_url => rebar_utils:to_binary(RepoUrl)}, Repo); + maps:merge(Parent#{repo_url => rebar_utils:to_binary(ParentRepoUrl)}, Repo); (Repo) -> Repo end, Repos). @@ -107,7 +112,7 @@ update_repo_list(R, []) -> [R]. default_repo() -> - HexDefaultConfig = hex_core:default_config(), + HexDefaultConfig = r3_hex_core:default_config(), HexDefaultConfig#{name => ?PUBLIC_HEX_REPO, repo_verify_origin => repo_verify_origin()}. repo_verify_origin() -> |