@@ -117,23 +117,23 @@ end}.
117117
118118{translation, "rabbit.cluster_formation.peer_discovery_aws.aws_hostname_paths",
119119fun(Conf) ->
120- Settings = cuttlefish_variable:filter_by_prefix("cluster_formation.aws.hostname_path", Conf),
121- %% Helper function for number validation
122- IsNumberString = fun(Str) ->
123- case string:to_integer(Str) of
124- {_, ""} -> true;
125- _ -> false
126- end
127- end,
128- %% Extract and sort numbered paths (hostname_path.1, hostname_path.2, etc.)
129- NumberedPaths = [{list_to_integer(N) , V} ||
130- {["cluster_formation", "aws", "hostname_path", N], V} <- Settings,
131- IsNumberString(N)],
132- case NumberedPaths of
133- [] -> cuttlefish:unset();
134- _ ->
135- SortedPaths = lists:sort(NumberedPaths ),
136- [rabbit_peer_discovery_util:as_list(V) || {_, V} <- SortedPaths ]
120+ case cuttlefish_variable:filter_by_prefix("cluster_formation.aws.hostname_path", Conf) of
121+ [] ->
122+ cuttlefish:unset();
123+ L ->
124+ %% Extract and sort numbered paths (hostname_path.1, hostname_path.2, etc.)
125+ L1 = lists:map(
126+ fun ({["cluster_formation", "aws", "hostname_path", N], V}) ->
127+ case string:to_integer(N) of
128+ {I, ""} ->
129+ {I , V};
130+ _ ->
131+ cuttlefish:invalid(io_lib:format("Cannot convert ~p to an integer", [N]))
132+ end;
133+ (Other) ->
134+ cuttlefish:invalid(io_lib:format("~p is invalid", [Other]))
135+ end, L ),
136+ [rabbit_peer_discovery_util:as_list(V) || {_, V} <- lists:sort(L1) ]
137137 end
138138end}.
139139
0 commit comments