Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions ydb/tools/merge_yaml/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include <ydb/library/yaml_config/yaml_config.h>
#include <ydb/library/yaml_config/yaml_config_parser.h>
#include <ydb/library/fyamlcpp/fyamlcpp.h>

#include <fstream>

using namespace NKikimr;

int main(int argc, char **argv) {
if (argc != 4) {
Cerr << "usage: " << argv[0] << " <input_yaml> <tenant> <output_yaml>" << Endl;
return 1;
}

auto inputFile = argv[1];
auto tenant = argv[2];
auto outputFile = argv[3];

std::ifstream inputStream(inputFile);
std::ofstream outputStream(outputFile);

if (!inputStream.is_open() || !outputStream.is_open()) {
Cerr << "Can't open file " << (inputStream.is_open() ? outputFile : inputFile) << Endl;
return 1;
}

std::stringstream inputBuf;
TStringStream outputBuf;

inputBuf << inputStream.rdbuf();
inputStream.close();

auto doc = NFyaml::TDocument::Parse(inputBuf.str());
auto [resolved, node] = NYamlConfig::Resolve(
doc,
{
NYamlConfig::TNamedLabel{"tenant", tenant},
}
);

outputBuf << node;

outputStream << outputBuf.Str();

if (outputStream.flush().fail()) {
Cerr << "Can't write to file " << outputFile << Endl;
return 1;
}

outputStream.close();

return 0;
}
12 changes: 12 additions & 0 deletions ydb/tools/merge_yaml/ya.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
PROGRAM()

SRCS(
main.cpp
)

PEERDIR(
ydb/library/yaml_config
ydb/library/fyamlcpp
)

END()
1 change: 1 addition & 0 deletions ydb/tools/ya.make
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
RECURSE(
blobsan
cfg
merge_yaml
partcheck
query_replay
query_replay_yt
Expand Down