|
1 | 1 | #include "validators.h" |
2 | 2 |
|
| 3 | +#include <ydb/core/config/protos/marker.pb.h> |
3 | 4 | #include <ydb/core/protos/blobstorage.pb.h> |
4 | 5 | #include <ydb/core/protos/blobstorage_disk.pb.h> |
5 | 6 |
|
| 7 | +#include <library/cpp/protobuf/json/util.h> |
| 8 | + |
| 9 | +#include <util/string/builder.h> |
| 10 | + |
6 | 11 | #include <map> |
7 | 12 | #include <set> |
8 | 13 |
|
@@ -161,6 +166,37 @@ EValidationResult ValidateStaticGroup(const NKikimrConfig::TAppConfig& current, |
161 | 166 | return EValidationResult::Ok; |
162 | 167 | } |
163 | 168 |
|
| 169 | +EValidationResult ValidateDatabaseConfig(const NKikimrConfig::TAppConfig& config, std::vector<TString>& msg) { |
| 170 | + const auto* desc = config.GetDescriptor(); |
| 171 | + const auto* reflection = config.GetReflection(); |
| 172 | + |
| 173 | + for (int i = 0; i < desc->field_count(); i++) { |
| 174 | + const auto* field = desc->field(i); |
| 175 | + |
| 176 | + if (field->options().GetExtension(NKikimrConfig::NMarkers::AllowInDatabaseConfig)) { |
| 177 | + continue; |
| 178 | + } |
| 179 | + |
| 180 | + if (!field->is_repeated()) { |
| 181 | + if (!reflection->HasField(config, field)) { |
| 182 | + continue; |
| 183 | + } |
| 184 | + } else { |
| 185 | + if (!reflection->FieldSize(config, field)) { |
| 186 | + continue; |
| 187 | + } |
| 188 | + } |
| 189 | + |
| 190 | + auto fieldName = field->name(); |
| 191 | + NProtobufJson::ToSnakeCaseDense(&fieldName); |
| 192 | + msg.push_back(TStringBuilder() << "'" << fieldName << "' " |
| 193 | + << "is not allowed to be used in the database configuration"); |
| 194 | + return EValidationResult::Error; |
| 195 | + } |
| 196 | + |
| 197 | + return EValidationResult::Ok; |
| 198 | +} |
| 199 | + |
164 | 200 | EValidationResult ValidateConfig(const NKikimrConfig::TAppConfig& config, std::vector<TString>& msg) { |
165 | 201 | if (config.HasAuthConfig()) { |
166 | 202 | NKikimr::NConfig::EValidationResult result = NKikimr::NConfig::ValidateAuthConfig(config.GetAuthConfig(), msg); |
|
0 commit comments