fix deploy params
This commit is contained in:
parent
3db88cc129
commit
6a51ce8627
@ -551,7 +551,7 @@ handle_container_request(Ref, Request, Socket) ->
|
||||
decode_container_command(#'Command.Container'{action = {list, #'Command.Container.ContainerList'{}}}) ->
|
||||
#{<<"action">> => <<"list">>};
|
||||
decode_container_command(#'Command.Container'{action = {deploy, #'Command.Container.ContainerDeploy'{task_id = TaskId, params = Params}}}) ->
|
||||
#{<<"action">> => <<"deploy">>, <<"task_id">> => TaskId, <<"params">> => decode_term_payload(Params)};
|
||||
#{<<"action">> => <<"deploy">>, <<"task_id">> => TaskId, <<"params">> => decode_json_payload(Params)};
|
||||
decode_container_command(#'Command.Container'{action = {start, #'Command.Container.ContainerStart'{target = Target}}}) ->
|
||||
#{<<"action">> => <<"start">>, <<"target">> => decode_container_target(Target)};
|
||||
decode_container_command(#'Command.Container'{action = {stop, #'Command.Container.ContainerStop'{target = Target, timeout_seconds = TimeoutSeconds}}}) ->
|
||||
@ -571,14 +571,14 @@ decode_container_target(#'Command.Container.ContainerTarget'{name = Name, id = I
|
||||
decode_container_target(undefined) ->
|
||||
#{<<"name">> => <<>>, <<"id">> => <<>>}.
|
||||
|
||||
-spec decode_term_payload(iodata()) -> term().
|
||||
decode_term_payload(Payload) ->
|
||||
-spec decode_json_payload(iodata()) -> term().
|
||||
decode_json_payload(Payload) ->
|
||||
Bin = iolist_to_binary(Payload),
|
||||
try binary_to_term(Bin, [safe]) of
|
||||
try json:decode(Bin) of
|
||||
Term ->
|
||||
Term
|
||||
catch
|
||||
error:_ ->
|
||||
_:_ ->
|
||||
Bin
|
||||
end.
|
||||
|
||||
@ -728,4 +728,4 @@ to_bool(1) ->
|
||||
to_bool(false) ->
|
||||
false;
|
||||
to_bool(0) ->
|
||||
false.
|
||||
false.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user