chore(license): change `key` type to `binary()`

So that the `raw_default` field in the schema JSON renders properly.
This commit is contained in:
Thales Macedo Garitezi 2022-12-07 09:15:42 -03:00
parent 48e1ba4832
commit a9d0143d5f
2 changed files with 16 additions and 7 deletions

View File

@ -24,12 +24,19 @@ main(Args) ->
["hocon" | Rest] ->
%% forward the call to hocon_cli
hocon_cli:main(Rest);
["check_license_key", Key] ->
check_license(#{key => list_to_binary(Key)});
["check_license_key", Key0] ->
Key = cleanup_key(Key0),
check_license(#{key => Key});
_ ->
do(Args)
end.
%% the key is a string (list) representation of a binary, so we need
%% to remove the leading and trailing angle brackets.
cleanup_key(Str0) ->
Str1 = iolist_to_binary(string:replace(Str0, "<<", "", leading)),
iolist_to_binary(string:replace(Str1, ">>", "", trailing)).
do(Args) ->
ok = do_with_halt(Args, "mnesia_dir", fun create_mnesia_dir/2),
ok = do_with_halt(Args, "chkconfig", fun("-config", X) -> chkconfig(X) end),

View File

@ -37,7 +37,7 @@ tags() ->
fields(key_license) ->
[
{key, #{
type => string(),
type => binary(),
default => default_license(),
%% so it's not logged
sensitive => true,
@ -85,7 +85,9 @@ check_license_watermark(Conf) ->
%% NOTE: when updating a new key, the schema doc in emqx_license_schema_i18n.conf
%% should be updated accordingly
default_license() ->
"MjIwMTExCjAKMTAKRXZhbHVhdGlvbgpjb250YWN0QGVtcXguaW8KZ"
"GVmYXVsdAoyMDIzMDEwOQoxODI1CjEwMAo=.MEUCIG62t8W15g05f"
"1cKx3tA3YgJoR0dmyHOPCdbUxBGxgKKAiEAhHKh8dUwhU+OxNEaOn"
"8mgRDtiT3R8RZooqy6dEsOmDI=".
<<
"MjIwMTExCjAKMTAKRXZhbHVhdGlvbgpjb250YWN0QGVtcXguaW8KZ"
"GVmYXVsdAoyMDIzMDEwOQoxODI1CjEwMAo=.MEUCIG62t8W15g05f"
"1cKx3tA3YgJoR0dmyHOPCdbUxBGxgKKAiEAhHKh8dUwhU+OxNEaOn"
"8mgRDtiT3R8RZooqy6dEsOmDI="
>>.