fix clone state; example routine

This commit is contained in:
garrettmills
2020-06-14 09:07:26 -05:00
parent 361a307d8d
commit afb35ebad8
9 changed files with 162 additions and 63 deletions

View File

@@ -1,5 +1,7 @@
const AbstractGitState = require('./AbstractGitState')
// TODO add 'bare' option
// TODO add 'new_repo' option (rm -rf .git && git init)
class CloneState extends AbstractGitState {
async apply() {

View File

@@ -15,11 +15,12 @@ class hosts extends Service {
get(name) {
const config = this.config[name]
config.name = name
if ( !config ) {
throw new Error(`Could not get host ${name}: No such host configured.`)
}
config.name = name
if ( config.type === 'localhost' ) {
const host = this.app.di().make(LocalHost, config)
this._running_hosts.push(host)

View File

@@ -12,18 +12,21 @@ const Routine = require('../classes/routine/Routine')
*/
class RoutinesService extends Service {
static get services() {
return [...super.services, 'app', 'configs', 'hosts']
return [...super.services, 'injector', 'configs', 'hosts']
}
async get(name) {
this.app.make(Routine)
const config = this.configs.get(`routines:${name}`)
if ( !config ) {
throw new Error(`Unable to find a routine with the name: ${name}`)
}
const hosts = {}
for ( const host_name of config.hosts ) {
hosts[host_name] = await this.hosts.get(host_name)
}
return new Routine(hosts, config, config.type)
return this.injector.make(Routine, hosts, config, config.type)
}
}