diff options
-rw-r--r-- | org/default_paths.org | 65 | ||||
-rw-r--r-- | org/meta_read_source_files.org | 65 | ||||
-rw-r--r-- | org/sdp.org | 4 | ||||
-rw-r--r-- | src/sdp/meta/metadoc.d | 4 | ||||
-rw-r--r-- | src/sdp/meta/read_config_files.d | 60 | ||||
-rw-r--r-- | src/sdp/output/paths_source.d | 65 |
6 files changed, 201 insertions, 62 deletions
diff --git a/org/default_paths.org b/org/default_paths.org index e18d3a5..93711dc 100644 --- a/org/default_paths.org +++ b/org/default_paths.org @@ -199,25 +199,15 @@ template ConfigFilePaths() { E _env, ) { struct ConfFilePaths { - auto possible_config_path_locations() { + auto possible_config_path_locations_document() { /+ FIX clean up conf paths ↓ +/ /+ config local site (file system only, not in pod) +/ - string _dot_pwd; - string _underscore_pwd; - string _dot_home; - /+ config document (& or local site) on filesystem +/ - string _sisudoc_conf_pwd; // think about - string _sisudoc_conf_pwd_a; - string _sisudoc_conf_pwd_b; - string _sisudoc_conf_pwd_c; - string _sisudoc_conf_pwd_d; - /+ config document in pod +/ - string _sisudoc_conf_pod; - string _sisudoc_conf_pod_text; /+ return paths +/ string[] _possible_config_path_locations; if (_manifest.is_pod) { /+ config document in pod +/ + string _sisudoc_conf_pod; + string _sisudoc_conf_pod_text; _sisudoc_conf_pod = asNormalizedPath(chainPath( to!string(_env["pwd"]), _manifest.pod_manifest_path ~ "/conf" @@ -232,16 +222,12 @@ template ConfigFilePaths() { _sisudoc_conf_pod, ]; } else { - /+ config local site (file system only, not in pod) +/ - _dot_pwd = asNormalizedPath(chainPath(to!string(_env["pwd"]), ".sisu")).array; - _underscore_pwd = asNormalizedPath(chainPath(to!string(_env["pwd"]), "_sisu")).array; - _dot_home = asNormalizedPath(chainPath(to!string(_env["home"]), ".sisu")).array; /+ config document (& or local site) on filesystem +/ - _sisudoc_conf_pwd = asNormalizedPath(chainPath(to!string(_env["pwd"]), "sisudoc/conf")).array; // think about - _sisudoc_conf_pwd_a = asNormalizedPath(chainPath(to!string(_env["pwd"]), "conf")).array; - _sisudoc_conf_pwd_b = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../conf")).array; - _sisudoc_conf_pwd_c = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../../conf")).array; - _sisudoc_conf_pwd_d = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../../../conf")).array; + string _sisudoc_conf_pwd = asNormalizedPath(chainPath(to!string(_env["pwd"]), "sisudoc/conf")).array; // think about + string _sisudoc_conf_pwd_a = asNormalizedPath(chainPath(to!string(_env["pwd"]), "conf")).array; + string _sisudoc_conf_pwd_b = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../conf")).array; + string _sisudoc_conf_pwd_c = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../../conf")).array; + string _sisudoc_conf_pwd_d = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../../../conf")).array; /+ return paths +/ _possible_config_path_locations = [ _sisudoc_conf_pwd, @@ -249,6 +235,41 @@ template ConfigFilePaths() { _sisudoc_conf_pwd_b, _sisudoc_conf_pwd_c, _sisudoc_conf_pwd_d, + ]; + } + /+ FIX clean up conf paths ↑ + (compare pwd to doc path location, and build config path) + +/ + return _possible_config_path_locations; + } + auto possible_config_path_locations_local_site() { + /+ FIX clean up conf paths ↓ +/ + /+ config local site (file system only, not in pod) +/ + string _dot_pwd = asNormalizedPath(chainPath(to!string(_env["pwd"]), ".sisu")).array; + string _underscore_pwd = asNormalizedPath(chainPath(to!string(_env["pwd"]), "_sisu")).array; + string _dot_home = asNormalizedPath(chainPath(to!string(_env["home"]), ".sisu")).array; + /+ return paths +/ + string[] _possible_config_path_locations; + if (_manifest.is_pod) { + _possible_config_path_locations = [ + _dot_pwd, + _underscore_pwd, + _dot_home, + "/etc/sisu" + ]; + } else { + /+ config document (& or local site) on filesystem +/ + string _sisudoc_conf_pwd = asNormalizedPath(chainPath(to!string(_env["pwd"]), "sisudoc/conf")).array; // think about + string _sisudoc_conf_pwd_a = asNormalizedPath(chainPath(to!string(_env["pwd"]), "conf")).array; + string _sisudoc_conf_pwd_b = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../conf")).array; + string _sisudoc_conf_pwd_c = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../../conf")).array; + string _sisudoc_conf_pwd_d = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../../../conf")).array; + _possible_config_path_locations = [ + _sisudoc_conf_pwd, + _sisudoc_conf_pwd_a, + _sisudoc_conf_pwd_b, + _sisudoc_conf_pwd_c, + _sisudoc_conf_pwd_d, _dot_pwd, _underscore_pwd, _dot_home, diff --git a/org/meta_read_source_files.org b/org/meta_read_source_files.org index b4b4d69..69d70d7 100644 --- a/org/meta_read_source_files.org +++ b/org/meta_read_source_files.org @@ -45,10 +45,45 @@ module sdp.meta.read_config_files; #+name: meta_config_file_in #+BEGIN_SRC d -static template configIn() { +static template configInSite() { <<imports_std>> - final string configIn(M,E,C)(M manifest, E env, C conf_sdl) { - auto possible_config_path_locations = ConfigFilePaths!()(manifest, env).possible_config_path_locations; + final string configInSite(M,E,C)(M manifest, E env, C conf_sdl) { + auto possible_config_path_locations = ConfigFilePaths!()(manifest, env).possible_config_path_locations_local_site; + string config_file_str; + foreach(pth; possible_config_path_locations) { + auto conf_file = format( + "%s/%s", + pth, + conf_sdl, + ); + if (config_file_str.length > 0) { + break; + } + try { + if (exists(conf_file)) { + debug(configfile) { + writeln(conf_file); + } + config_file_str = conf_file.readText; + break; + } + } + catch (ErrnoException ex) { + } + catch (FileException ex) { + } + } + return config_file_str; + } +} +#+END_SRC + +#+name: meta_config_file_in +#+BEGIN_SRC d +static template configInDoc() { + <<imports_std>> + final string configInDoc(M,E,C)(M manifest, E env, C conf_sdl) { + auto possible_config_path_locations = ConfigFilePaths!()(manifest, env).possible_config_path_locations_document; string config_file_str; foreach(pth; possible_config_path_locations) { auto conf_file = format( @@ -116,10 +151,15 @@ auto ConfigSDLang(string configuration, string conf_sdl_filename) { #+BEGIN_SRC d /+ +/ -static template configRead() { +static template configReadSite() { <<imports_std>> <<meta_config_file_import_sdlang>> - <<meta_config_file_sdlang_hub>> + <<meta_config_file_sdlang_hub_site>> +} +static template configReadDoc() { + <<imports_std>> + <<meta_config_file_import_sdlang>> + <<meta_config_file_sdlang_hub_doc>> } #+END_SRC @@ -133,10 +173,19 @@ import sdlang; Read in sdl config file name given, and return sdl root -#+name: meta_config_file_sdlang_hub +#+name: meta_config_file_sdlang_hub_site +#+BEGIN_SRC d +final auto configReadSite(M,E,C)(M manifest, E env, C conf_sdl) { + auto configuration = configInSite!()(manifest, env, conf_sdl); + auto sdl_root = ConfigSDLang!()(configuration, conf_sdl); + return sdl_root; +} +#+END_SRC + +#+name: meta_config_file_sdlang_hub_doc #+BEGIN_SRC d -final auto configRead(M,E,C)(M manifest, E env, C conf_sdl) { - auto configuration = configIn!()(manifest, env, conf_sdl); +final auto configReadDoc(M,E,C)(M manifest, E env, C conf_sdl) { + auto configuration = configInDoc!()(manifest, env, conf_sdl); auto sdl_root = ConfigSDLang!()(configuration, conf_sdl); return sdl_root; } diff --git a/org/sdp.org b/org/sdp.org index 13ce647..011fd85 100644 --- a/org/sdp.org +++ b/org/sdp.org @@ -552,8 +552,8 @@ foreach(arg; args[1..$]) { #+NAME: sdp_conf_files #+BEGIN_SRC d -auto sdl_root_config_document = configRead!()(_manifest, _env, "config_document"); // document config file -auto sdl_root_config_local_site = configRead!()(_manifest, _env, "config_local_site"); // local site config +auto sdl_root_config_document = configReadDoc!()(_manifest, _env, "config_document"); // document config file +auto sdl_root_config_local_site = configReadSite!()(_manifest, _env, "config_local_site"); // local site config auto conf_files_composite_make = confFilesSDLtoStruct!()(sdl_root_config_document, sdl_root_config_local_site); #+END_SRC diff --git a/src/sdp/meta/metadoc.d b/src/sdp/meta/metadoc.d index 8fafc24..eed9f55 100644 --- a/src/sdp/meta/metadoc.d +++ b/src/sdp/meta/metadoc.d @@ -36,8 +36,8 @@ template SiSUabstraction() { O _opt_action, M _manifest, ){ - auto sdl_root_config_document = configRead!()(_manifest, _env, "config_document"); // document config file - auto sdl_root_config_local_site = configRead!()(_manifest, _env, "config_local_site"); // local site config + auto sdl_root_config_document = configReadDoc!()(_manifest, _env, "config_document"); // document config file + auto sdl_root_config_local_site = configReadSite!()(_manifest, _env, "config_local_site"); // local site config auto conf_files_composite_make = confFilesSDLtoStruct!()(sdl_root_config_document, sdl_root_config_local_site); /+ ↓ read file (filename with path) +/ /+ ↓ file tuple of header and content +/ diff --git a/src/sdp/meta/read_config_files.d b/src/sdp/meta/read_config_files.d index b3c7f1b..d816619 100644 --- a/src/sdp/meta/read_config_files.d +++ b/src/sdp/meta/read_config_files.d @@ -4,14 +4,49 @@ meta_config_files.d +/ module sdp.meta.read_config_files; -static template configIn() { +static template configInSite() { import sdp.meta, sdp.output.paths_source, std.file, std.path; - final string configIn(M,E,C)(M manifest, E env, C conf_sdl) { - auto possible_config_path_locations = ConfigFilePaths!()(manifest, env).possible_config_path_locations; + final string configInSite(M,E,C)(M manifest, E env, C conf_sdl) { + auto possible_config_path_locations = ConfigFilePaths!()(manifest, env).possible_config_path_locations_local_site; + string config_file_str; + foreach(pth; possible_config_path_locations) { + auto conf_file = format( + "%s/%s", + pth, + conf_sdl, + ); + if (config_file_str.length > 0) { + break; + } + try { + if (exists(conf_file)) { + debug(configfile) { + writeln(conf_file); + } + config_file_str = conf_file.readText; + break; + } + } + catch (ErrnoException ex) { + } + catch (FileException ex) { + } + } + return config_file_str; + } +} +static template configInDoc() { + import + sdp.meta, + sdp.output.paths_source, + std.file, + std.path; + final string configInDoc(M,E,C)(M manifest, E env, C conf_sdl) { + auto possible_config_path_locations = ConfigFilePaths!()(manifest, env).possible_config_path_locations_document; string config_file_str; foreach(pth; possible_config_path_locations) { auto conf_file = format( @@ -63,15 +98,28 @@ static template ConfigSDLang() { } /+ +/ -static template configRead() { +static template configReadSite() { + import + sdp.meta, + sdp.output.paths_source, + std.file, + std.path; + + final auto configReadSite(M,E,C)(M manifest, E env, C conf_sdl) { + auto configuration = configInSite!()(manifest, env, conf_sdl); + auto sdl_root = ConfigSDLang!()(configuration, conf_sdl); + return sdl_root; + } +} +static template configReadDoc() { import sdp.meta, sdp.output.paths_source, std.file, std.path; - final auto configRead(M,E,C)(M manifest, E env, C conf_sdl) { - auto configuration = configIn!()(manifest, env, conf_sdl); + final auto configReadDoc(M,E,C)(M manifest, E env, C conf_sdl) { + auto configuration = configInDoc!()(manifest, env, conf_sdl); auto sdl_root = ConfigSDLang!()(configuration, conf_sdl); return sdl_root; } diff --git a/src/sdp/output/paths_source.d b/src/sdp/output/paths_source.d index 4f8eb54..b81448c 100644 --- a/src/sdp/output/paths_source.d +++ b/src/sdp/output/paths_source.d @@ -156,25 +156,15 @@ template ConfigFilePaths() { E _env, ) { struct ConfFilePaths { - auto possible_config_path_locations() { + auto possible_config_path_locations_document() { /+ FIX clean up conf paths ↓ +/ /+ config local site (file system only, not in pod) +/ - string _dot_pwd; - string _underscore_pwd; - string _dot_home; - /+ config document (& or local site) on filesystem +/ - string _sisudoc_conf_pwd; // think about - string _sisudoc_conf_pwd_a; - string _sisudoc_conf_pwd_b; - string _sisudoc_conf_pwd_c; - string _sisudoc_conf_pwd_d; - /+ config document in pod +/ - string _sisudoc_conf_pod; - string _sisudoc_conf_pod_text; /+ return paths +/ string[] _possible_config_path_locations; if (_manifest.is_pod) { /+ config document in pod +/ + string _sisudoc_conf_pod; + string _sisudoc_conf_pod_text; _sisudoc_conf_pod = asNormalizedPath(chainPath( to!string(_env["pwd"]), _manifest.pod_manifest_path ~ "/conf" @@ -189,16 +179,12 @@ template ConfigFilePaths() { _sisudoc_conf_pod, ]; } else { - /+ config local site (file system only, not in pod) +/ - _dot_pwd = asNormalizedPath(chainPath(to!string(_env["pwd"]), ".sisu")).array; - _underscore_pwd = asNormalizedPath(chainPath(to!string(_env["pwd"]), "_sisu")).array; - _dot_home = asNormalizedPath(chainPath(to!string(_env["home"]), ".sisu")).array; /+ config document (& or local site) on filesystem +/ - _sisudoc_conf_pwd = asNormalizedPath(chainPath(to!string(_env["pwd"]), "sisudoc/conf")).array; // think about - _sisudoc_conf_pwd_a = asNormalizedPath(chainPath(to!string(_env["pwd"]), "conf")).array; - _sisudoc_conf_pwd_b = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../conf")).array; - _sisudoc_conf_pwd_c = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../../conf")).array; - _sisudoc_conf_pwd_d = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../../../conf")).array; + string _sisudoc_conf_pwd = asNormalizedPath(chainPath(to!string(_env["pwd"]), "sisudoc/conf")).array; // think about + string _sisudoc_conf_pwd_a = asNormalizedPath(chainPath(to!string(_env["pwd"]), "conf")).array; + string _sisudoc_conf_pwd_b = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../conf")).array; + string _sisudoc_conf_pwd_c = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../../conf")).array; + string _sisudoc_conf_pwd_d = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../../../conf")).array; /+ return paths +/ _possible_config_path_locations = [ _sisudoc_conf_pwd, @@ -206,6 +192,41 @@ template ConfigFilePaths() { _sisudoc_conf_pwd_b, _sisudoc_conf_pwd_c, _sisudoc_conf_pwd_d, + ]; + } + /+ FIX clean up conf paths ↑ + (compare pwd to doc path location, and build config path) + +/ + return _possible_config_path_locations; + } + auto possible_config_path_locations_local_site() { + /+ FIX clean up conf paths ↓ +/ + /+ config local site (file system only, not in pod) +/ + string _dot_pwd = asNormalizedPath(chainPath(to!string(_env["pwd"]), ".sisu")).array; + string _underscore_pwd = asNormalizedPath(chainPath(to!string(_env["pwd"]), "_sisu")).array; + string _dot_home = asNormalizedPath(chainPath(to!string(_env["home"]), ".sisu")).array; + /+ return paths +/ + string[] _possible_config_path_locations; + if (_manifest.is_pod) { + _possible_config_path_locations = [ + _dot_pwd, + _underscore_pwd, + _dot_home, + "/etc/sisu" + ]; + } else { + /+ config document (& or local site) on filesystem +/ + string _sisudoc_conf_pwd = asNormalizedPath(chainPath(to!string(_env["pwd"]), "sisudoc/conf")).array; // think about + string _sisudoc_conf_pwd_a = asNormalizedPath(chainPath(to!string(_env["pwd"]), "conf")).array; + string _sisudoc_conf_pwd_b = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../conf")).array; + string _sisudoc_conf_pwd_c = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../../conf")).array; + string _sisudoc_conf_pwd_d = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../../../conf")).array; + _possible_config_path_locations = [ + _sisudoc_conf_pwd, + _sisudoc_conf_pwd_a, + _sisudoc_conf_pwd_b, + _sisudoc_conf_pwd_c, + _sisudoc_conf_pwd_d, _dot_pwd, _underscore_pwd, _dot_home, |