diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-02-04 14:38:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-04 14:38:06 +0100 |
commit | 1c30e549f27a2e84ecf0336dc2bc6d980295e5af (patch) | |
tree | f128b287c466711573b411ce3b09217e930ff0d7 /config/src | |
parent | 977313847c8b93403e2ebf6b643b603de2d0bf16 (diff) | |
parent | e841d183821bc157f3ae278ddcbd4491328c5057 (diff) |
Merge pull request #21067 from vespa-engine/hmusum/always-use-schema-in-vespa-get-config
Use installed config schema if none is given as option
Diffstat (limited to 'config/src')
-rw-r--r-- | config/src/apps/vespa-get-config/getconfig.cpp | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/config/src/apps/vespa-get-config/getconfig.cpp b/config/src/apps/vespa-get-config/getconfig.cpp index e6375ac9c47..347d92e0ef4 100644 --- a/config/src/apps/vespa-get-config/getconfig.cpp +++ b/config/src/apps/vespa-get-config/getconfig.cpp @@ -93,7 +93,7 @@ GetConfig::Main() int c = -1; std::vector<vespalib::string> defSchema; - const char *schema = nullptr; + const char *schemaString = nullptr; const char *defName = nullptr; const char *defMD5 = ""; std::string defNamespace("config"); @@ -119,7 +119,7 @@ GetConfig::Main() int retval = 1; switch (c) { case 'a': - schema = optArg; + schemaString = optArg; break; case 'n': defName = optArg; @@ -184,17 +184,30 @@ GetConfig::Main() defNamespace = std::string(tmp, defName - tmp - 1); } - if (schema != nullptr) { - std::ifstream is; - is.open(schema); - std::string item; - while (std::getline(is, item)) { - if (item.find("namespace=") == std::string::npos) { - defSchema.push_back(item); - } - } - is.close(); + std::string schema; + if (schemaString == nullptr) { + std::ostringstream tmp; + tmp << getenv("VESPA_HOME"); + tmp << "/share/vespa/configdefinitions/"; + tmp << defName; + tmp << ".def"; + schema = tmp.str(); + } else { + schema = schemaString; } + if (debugging) { + printf("Using schema in %s\n", schema.c_str()); + } + std::ifstream is; + is.open(schema); + std::string item; + while (std::getline(is, item)) { + if (item.find("namespace=") == std::string::npos) { + defSchema.push_back(item); + } + } + is.close(); + std::ostringstream tmp; tmp << "tcp/"; tmp << serverHost; |