Reimplement %ansible_collection_url to accept the collection namespace and name as arguments instead of requiring oblique control macros. This also adds some basic tests to ensure that the macro behaves properly.epel8
parent
e3d150ec90
commit
c67bd58e79
@ -1 +1,25 @@
|
|||||||
%ansible_collection_url() https://galaxy.ansible.com/%{collection_namespace}/%{collection_name}
|
# Note(gotmax23): I'm trying to get rid of the need for control macros in favor
|
||||||
|
# of a metadata based approach. %%ansible_collection_url is the only macro that
|
||||||
|
# requires manually specifying the collection namespace and name, as it is used
|
||||||
|
# at the SRPM build stage.
|
||||||
|
#
|
||||||
|
# Currently, this macro supports either passing this information as arguments
|
||||||
|
# or defining the control macros. In order to reduce confusion, this is not an
|
||||||
|
# either or approach. Both arguments must be passed OR both control macros must
|
||||||
|
# be defined.
|
||||||
|
|
||||||
|
%ansible_collection_url() %{lua:
|
||||||
|
local namespace_name = nil
|
||||||
|
if rpm.expand("%collection_namespace") ~= "%collection_namespace"
|
||||||
|
and rpm.expand("%collection_name") ~= "%collection_name" then
|
||||||
|
namespace_name = rpm.expand("%collection_namespace") .. "/" .. rpm.expand("%collection_name")
|
||||||
|
end
|
||||||
|
if rpm.expand("%1") ~= "%1" and rpm.expand("%2") ~= "%2" then
|
||||||
|
namespace_name = rpm.expand("%1") .. "/" .. rpm.expand("%2")
|
||||||
|
end
|
||||||
|
if not namespace_name then
|
||||||
|
rpm.expand("%{error:%%ansible_collection_url: You must pass the collection " ..
|
||||||
|
"namespace as the first arg and the collection name as the second}")
|
||||||
|
end
|
||||||
|
print("https://galaxy.ansible.com/" .. namespace_name)
|
||||||
|
}
|
||||||
|
Loading…
Reference in new issue