@@ -43,6 +43,8 @@ pub struct ActionServiceConfiguration {
4343pub struct RuntimeServiceConfiguration {
4444 token : String ,
4545 identifier : String ,
46+ #[ serde( default ) ]
47+ resolved_modules : Vec < String > ,
4648}
4749
4850#[ derive( Serialize , Deserialize , Clone , Default ) ]
@@ -144,6 +146,24 @@ impl ServiceConfiguration {
144146 }
145147 }
146148
149+ pub fn collect_modules ( & self ) -> Vec < String > {
150+ let actions: Vec < String > = self
151+ . actions
152+ . iter ( )
153+ . map ( |x| format ! ( "action.{}" , x. service_name) )
154+ . collect ( ) ;
155+ let runtime: Vec < String > = self
156+ . runtimes
157+ . iter ( )
158+ . flat_map ( |x| match x. resolved_modules . is_empty ( ) {
159+ true => vec ! [ x. identifier. clone( ) ] ,
160+ false => x. resolved_modules . clone ( ) ,
161+ } )
162+ . collect ( ) ;
163+
164+ vec ! [ actions, runtime] . concat ( )
165+ }
166+
147167 pub fn from_path ( path : impl AsRef < Path > ) -> Self {
148168 let mut data = String :: new ( ) ;
149169
@@ -203,14 +223,20 @@ mod tests {
203223 RuntimeServiceConfiguration {
204224 token: String :: from( "taurus-token" ) ,
205225 identifier: String :: from( "taurus" ) ,
226+ resolved_modules: vec![
227+ String :: from( "taurus-boolean" ) ,
228+ String :: from( "taurus-number" ) ,
229+ ] ,
206230 } ,
207231 RuntimeServiceConfiguration {
208232 token: String :: from( "draco-rest-token" ) ,
209233 identifier: String :: from( "draco-rest" ) ,
234+ resolved_modules: vec![ ] ,
210235 } ,
211236 RuntimeServiceConfiguration {
212237 token: String :: from( "draco-cron-token" ) ,
213238 identifier: String :: from( "draco-cron" ) ,
239+ resolved_modules: vec![ ] ,
214240 } ,
215241 ] ,
216242 }
@@ -278,6 +304,22 @@ mod tests {
278304 assert ! ( !config. has_service( & String :: from( "action-token" ) , & String :: from( "taurus-x" ) ) ) ;
279305 }
280306
307+ #[ test]
308+ fn collect_modules_uses_definition_source_identifiers ( ) {
309+ let config = fixture ( ) ;
310+
311+ assert_eq ! (
312+ config. collect_modules( ) ,
313+ vec![
314+ String :: from( "action.action-identifier" ) ,
315+ String :: from( "taurus-boolean" ) ,
316+ String :: from( "taurus-number" ) ,
317+ String :: from( "draco-rest" ) ,
318+ String :: from( "draco-cron" ) ,
319+ ]
320+ ) ;
321+ }
322+
281323 #[ test]
282324 fn get_action_configuration_requires_matching_token_and_identifier ( ) {
283325 let config: ServiceConfiguration = SerializableServiceConfiguration {
0 commit comments