diff options
| author | Ralph Amissah <ralph@amissah.com> | 2017-12-16 16:06:29 -0500 | 
|---|---|---|
| committer | Ralph Amissah <ralph@amissah.com> | 2019-04-10 15:14:14 -0400 | 
| commit | 8577facf7e0f06580d289ed5bf8cbded3ad2a9f1 (patch) | |
| tree | dcb62b94a7ef1af2c099ea8c70ee5f1283e30db3 /src/sdp/meta | |
| parent | 0.23.2 config paths for pod (diff) | |
target different type of config file locations
- config files for
  - local site configuration (not in pod)
  - document make (included in pod)
Diffstat (limited to 'src/sdp/meta')
| -rw-r--r-- | src/sdp/meta/metadoc.d | 4 | ||||
| -rw-r--r-- | src/sdp/meta/read_config_files.d | 60 | 
2 files changed, 56 insertions, 8 deletions
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;    }  | 
