From 6f51c0be2e5a2fba33088715aaf855f2e8c518cc Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 3 Oct 2017 17:47:40 +0200 Subject: [PATCH] Added useful feature: include other paths in sami This way you can include other repositories into the Salt.Mine XML: ... http://from.other.source/repository.xml --- src/lay/lay/laySaltGrains.cc | 19 +++++++++++++++++++ src/lay/lay/laySaltGrains.h | 7 +++++++ 2 files changed, 26 insertions(+) diff --git a/src/lay/lay/laySaltGrains.cc b/src/lay/lay/laySaltGrains.cc index cc0c06b1a..3fcc9fe14 100644 --- a/src/lay/lay/laySaltGrains.cc +++ b/src/lay/lay/laySaltGrains.cc @@ -23,6 +23,7 @@ #include "laySaltGrains.h" #include "tlString.h" #include "tlFileUtils.h" +#include "tlLog.h" #include #include @@ -235,6 +236,7 @@ SaltGrains::from_path (const std::string &path, const std::string &prefix) static tl::XMLElementList s_group_struct = tl::make_member (&SaltGrains::name, &SaltGrains::set_name, "name") + + tl::make_member (&SaltGrains::include, "include") + tl::make_element (&SaltGrains::begin_collections, &SaltGrains::end_collections, &SaltGrains::add_collection, "group", &s_group_struct) + tl::make_element (&SaltGrains::begin_grains, &SaltGrains::end_grains, &SaltGrains::add_grain, "salt-grain", SaltGrain::xml_elements ()); @@ -254,6 +256,23 @@ SaltGrains::load (tl::InputStream &p) s_xml_struct.parse (source, *this); } +void +SaltGrains::include (const std::string &src) +{ + if (! src.empty ()) { + + if (tl::verbosity () >= 20) { + tl::log << "Including package index from " << src; + } + + lay::SaltGrains g; + g.load (src); + m_collections.splice (m_collections.end (), g.m_collections); + m_grains.splice (m_grains.end (), g.m_grains); + + } +} + void SaltGrains::save (const std::string &p) const { diff --git a/src/lay/lay/laySaltGrains.h b/src/lay/lay/laySaltGrains.h index 2dc524a5a..0a5dceaa7 100644 --- a/src/lay/lay/laySaltGrains.h +++ b/src/lay/lay/laySaltGrains.h @@ -108,6 +108,13 @@ public: */ void set_path (const std::string &p); + /** + * @brief Includes a list from an external source into this list + * This method reads the other list from the source (an URL) and + * merges it into this. + */ + void include (const std::string &src); + /** * @brief Gets the collections which are members of this collection (begin iterator) */