From 2f05c0a6f0ab3e7b89b6e402998bdabedd2d52d9 Mon Sep 17 00:00:00 2001 From: ttt161 Date: Tue, 3 Jun 2025 09:55:36 +0300 Subject: [PATCH 1/3] update configurator for canal --- config/config.yaml | 2 ++ rebar.lock | 4 ---- rel_scripts/configurator.escript | 22 ++++++++++++++++++++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index 21c829e..388e3d7 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -346,6 +346,8 @@ postgres: another_processor_pool: database: another_processor_db size: 10 + vault_token_path: /var/run/secrets/kubernetes.io/serviceaccount/token + vault_role: machinegun ## Progressor namespaces settings diff --git a/rebar.lock b/rebar.lock index a43373d..dfa7e3f 100644 --- a/rebar.lock +++ b/rebar.lock @@ -36,10 +36,6 @@ {<<"gproc">>,{pkg,<<"gproc">>,<<"0.9.0">>},0}, {<<"grpcbox">>,{pkg,<<"grpcbox">>,<<"0.17.1">>},1}, {<<"hackney">>,{pkg,<<"hackney">>,<<"1.18.0">>},1}, - {<<"hamcrest">>, - {git,"https://github.com/basho/hamcrest-erlang.git", - {ref,"ad3dbab419762fc2d5821abb88b989da006b85c6"}}, - 2}, {<<"hpack">>,{pkg,<<"hpack_erl">>,<<"0.3.0">>},3}, {<<"idna">>,{pkg,<<"idna">>,<<"6.1.1">>},2}, {<<"jsone">>,{pkg,<<"jsone">>,<<"1.8.0">>},3}, diff --git a/rel_scripts/configurator.escript b/rel_scripts/configurator.escript index 82c2ce6..5a7b090 100755 --- a/rel_scripts/configurator.escript +++ b/rel_scripts/configurator.escript @@ -566,10 +566,23 @@ procreg(YamlConfig) -> ). epg_connector(YamlConfig) -> - [ + Required = [ {databases, pg_databases(YamlConfig)}, {pools, pg_pools(YamlConfig)} - ]. + ], + WithOptional = add_optional( + Required, + {vault_token_path, to_string(?C:conf([postgres, vault_token_path], YamlConfig, undefined))} + ), + add_optional( + WithOptional, + {vault_role, to_string(?C:conf([postgres, vault_role], YamlConfig, undefined))} + ). + +add_optional(Conf, {_Key, undefined}) -> + Conf; +add_optional(Conf, Pair) -> + [Pair | Conf]. pg_databases(YamlConfig) -> lists:foldl( @@ -799,3 +812,8 @@ log_level_tuple_to_atom({<<"debug">>, NewLevel}) when is_binary(NewLevel) -> {debug, binary_to_atom(NewLevel)}; log_level_tuple_to_atom({Level, _NewLevel}) -> throw("Not supported logger level '" ++ binary_to_list(Level) ++ "'"). + +to_string(undefined) -> + undefined; +to_string(V) when is_binary(V) -> + unicode:characters_to_list(V). From cae86343d81eac850fe3abb3e45886450820fef3 Mon Sep 17 00:00:00 2001 From: ttt161 Date: Tue, 3 Jun 2025 10:14:51 +0300 Subject: [PATCH 2/3] fix issues --- config/config.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index 388e3d7..95a1ca2 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -346,14 +346,18 @@ postgres: another_processor_pool: database: another_processor_db size: 10 - vault_token_path: /var/run/secrets/kubernetes.io/serviceaccount/token - vault_role: machinegun + # Optional fields + # needs when canal configured to read postgres creds + #vault_token_path: /var/run/secrets/kubernetes.io/serviceaccount/token + #vault_role: machinegun ## Progressor namespaces settings progressor: prg_test_ns: some_processor_pool1 +# Optional section +# if not defined then canal will not be started canal: url: http://vault engine: kvv2 From d98118916d8674984e532c8da24a44fe01a0bbec Mon Sep 17 00:00:00 2001 From: ttt161 Date: Tue, 3 Jun 2025 17:07:57 +0300 Subject: [PATCH 3/3] fix format --- config/config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index 95a1ca2..c0c9f8d 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -347,9 +347,9 @@ postgres: database: another_processor_db size: 10 # Optional fields - # needs when canal configured to read postgres creds - #vault_token_path: /var/run/secrets/kubernetes.io/serviceaccount/token - #vault_role: machinegun + # needs when canal configured to read postgres creds + vault_token_path: /var/run/secrets/kubernetes.io/serviceaccount/token + vault_role: machinegun ## Progressor namespaces settings