summaryrefslogtreecommitdiffstats
path: root/config/src/apps
diff options
context:
space:
mode:
authorHarald Musum <musum@yahooinc.com>2022-02-04 13:00:54 +0100
committerHarald Musum <musum@yahooinc.com>2022-02-04 13:00:54 +0100
commite841d183821bc157f3ae278ddcbd4491328c5057 (patch)
treef0bee5294c3069b25e49da91d9fec2c8c43d556c /config/src/apps
parentb186d78d65c3a839c21e56fc1e0459dea0f593de (diff)
Use installed config schema if none is given as option
Diffstat (limited to 'config/src/apps')
-rw-r--r--config/src/apps/vespa-get-config/getconfig.cpp37
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;