# Iniz: support "wildcardInclusions"

**URL:** <https://talk.openmrs.org/t/iniz-support-wildcardinclusions/34455>\
**Category:** Development\
**Tags:** initializer\
**Created:** [August 20, 2021, 5:59pm UTC](https://talk.openmrs.org/t/iniz-support-wildcardinclusions/34455 "2021-08-20T17:59:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mogoodrich](https://talk.openmrs.org/user_avatar/talk.openmrs.org/mogoodrich/32/3324_2.png) [@mogoodrich](https://talk.openmrs.org/u/mogoodrich)\
**Post date:** [August 20, 2021, 5:59pm UTC](https://talk.openmrs.org/t/iniz-support-wildcardinclusions/34455/1 "2021-08-20T17:59:10Z")

</div>

@mksd and others:

The Iniz loader currently supports specifying a list of wildcard exclusions, and all files that match those patterns are excluded:

> <https://github.com/mekomsolutions/openmrs-module-initializer/blob/master/api/src/main/java/org/openmrs/module/initializer/api/loaders/Loader.java#L52>

Thought about expanding this allow the specification of files to _include_, instead of exclude?

At PIH, we’d like a little more fine-grained control of what metadata we install where, and I think having this option would facilitate that.

In case you are interested in the weeds, in our Haiti implementation, there are some locations we only want to install at one of our sites (Mirebalais).

So I could see having two location csv files: locations.csv locations-mirebalais.

… where locations are installed at all the sites, but “location-mirebalais” is only installed at Mirebalais.

We’ve already got some custom code to invoke the Iniz loading:

> <https://github.com/PIH/openmrs-module-pihcore/blob/master/api/src/main/java/org/openmrs/module/pihcore/setup/InitializerSetup.java#L73>

… so one way for us to support this conditional-loading-by-site generically within our own implementations would be to modify the above code to call unsafeLoad first with an exclusion wildcard value like “_-_” (skip any file with a hyphen) and then again with an inclusion wildcard value of “\*-[current\_site\_name]”.

Thoughts?

Take care, Mark

---

<div class="post-metadata">

**Author:** ![mksd](https://talk.openmrs.org/user_avatar/talk.openmrs.org/mksd/32/11729_2.png) [@mksd](https://talk.openmrs.org/u/mksd)\
**Post date:** [August 25, 2021, 9:40am UTC](https://talk.openmrs.org/t/iniz-support-wildcardinclusions/34455/2 "2021-08-25T09:40:13Z")

</div>

Hi @mogoodrich,

In short: sure. For the record @ibacher and I we briefly discussed this on the original PR: [Bundle a standalone validator tool · Issue #84 · mekomsolutions/openmrs-module-initializer · GitHub](https://github.com/mekomsolutions/openmrs-module-initializer/issues/84#issuecomment-749177724)

We dropped it at the time, but basically the main question was to figure out what to do when both the inclusions and exclusions lists are specified at the same time for a domain?

* * *

Also for the record, this is the piece of code where deep down the wildcard exclusions list is eventually processed:

> <https://github.com/mekomsolutions/openmrs-module-initializer/blob/f15f65ece98374487c2596cd8ad8f3e479b7eb0c/api/src/main/java/org/openmrs/module/initializer/api/ConfigDirUtil.java#L168-L178>

---

<div class="post-metadata">

**Author:** ![mogoodrich](https://talk.openmrs.org/user_avatar/talk.openmrs.org/mogoodrich/32/3324_2.png) [@mogoodrich](https://talk.openmrs.org/u/mogoodrich)\
**Post date:** [August 25, 2021, 2:06pm UTC](https://talk.openmrs.org/t/iniz-support-wildcardinclusions/34455/3 "2021-08-25T14:06:15Z")

</div>

Cool, that makes total sense… I, do, was wondering what do it if someone try to do both an include and an exclude (and I think I agree with the @ibacher thought of not allowing both). I’ll dig into this deeper and come up with a proposal in the coming days/weeks.

---

<div class="post-metadata">

**Author:** ![mogoodrich](https://talk.openmrs.org/user_avatar/talk.openmrs.org/mogoodrich/32/3324_2.png) [@mogoodrich](https://talk.openmrs.org/u/mogoodrich)\
**Post date:** [August 27, 2021, 1:32pm UTC](https://talk.openmrs.org/t/iniz-support-wildcardinclusions/34455/4 "2021-08-27T13:32:47Z")

</div>

@mksd@ibacher ticketed here:

> <https://github.com/mekomsolutions/openmrs-module-initializer/issues/132>
>
> The runtime properties configuration of Iniz provides support for a "initializer….exclude.\[domain\]" properties. For example, from the documentation:
> 
> \`initializer.exclude.concepts=\*diags\*,\*interventions\*\`
> 
> This tells iniz, when parsing the "concepts" directory, to exclude all files that match the wildcard patterns specified.
> 
> We'd like to support an equivalent "include" function, ie:
> 
> \`initializer.exclude.concepts=\*diags\*,\*interventions\*\`
> 
> ... would \*only\* include files that contain "diags" and "interventions" in the name.
> 
> We do \*not\* need to support both an "include" and an "exclude" for the same domain in the same configuration... we can throw an exception in this case.
> 
> Note that when we implement this, we want to make the method to do this publicly accessible, as some implementations (PIH) access the Loader API methods directly.  
> 
> Currently, the Loader provides a method with a signature:
> 
> https://github.com/mekomsolutions/openmrs-module-initializer/blob/master/api/src/main/java/org/openmrs/module/initializer/api/loaders/Loader.java#L42
> 
> Ideally, we'd like something like
> 
> \`void loadUnsafe(List\<String\> wildcardIncludes, boolean doThrow) throws Exception;\`
> 
> ... but this won't work because it has the same method signature as the previous function.
> 
> Perhaps something like this (though admittedly this is ugly, open to other ideas):
> 
> \`void loadUnsafe(List\<String\> wildcards, boolean include, boolean doThrow) throws Exception;\`
> 
> (So passing "true" to the include parameter would make it interpret the wildcard list as a include list, and false would have it interpret it as a exclude list)

---

<div class="post-metadata">

**Author:** ![burke](https://talk.openmrs.org/user_avatar/talk.openmrs.org/burke/32/17_2.png) [@burke](https://talk.openmrs.org/u/burke)\
**Post date:** [August 29, 2021, 12:34am UTC](https://talk.openmrs.org/t/iniz-support-wildcardinclusions/34455/5 "2021-08-29T00:34:28Z")

</div>

I would expect inclusions to be processed first and exclusions second. Inclusions define the scope and exclusions filter within that scope. So, including `“*.csv”` and excluding `“f*”` would give you all CSVs that don’t start with an f.

---

<div class="post-metadata">

**Author:** ![mksd](https://talk.openmrs.org/user_avatar/talk.openmrs.org/mksd/32/11729_2.png) [@mksd](https://talk.openmrs.org/u/mksd)\
**Post date:** [August 30, 2021, 7:01pm UTC](https://talk.openmrs.org/t/iniz-support-wildcardinclusions/34455/6 "2021-08-30T19:01:23Z")

</div>

That feels natural and is definitely fine with me, as long as it’s properly documented in the end.

@mogoodrich if you agree and that it responds to your use cases, you could add this in the issue’s description as part of the acceptance criteria?

---

<div class="post-metadata">

**Author:** ![mogoodrich](https://talk.openmrs.org/user_avatar/talk.openmrs.org/mogoodrich/32/3324_2.png) [@mogoodrich](https://talk.openmrs.org/u/mogoodrich)\
**Post date:** [August 30, 2021, 8:11pm UTC](https://talk.openmrs.org/t/iniz-support-wildcardinclusions/34455/7 "2021-08-30T20:11:06Z")

</div>

@mksd yep, makes sense to me, I will update/alter the issue…
