Prepare for first package
This commit is contained in:
@@ -14,7 +14,7 @@ const SystemDManager = require('../logical/services/SystemDManager')
|
||||
|
||||
class Host extends Injectable {
|
||||
static get services() {
|
||||
return [...super.services, 'utility']
|
||||
return [...super.services, 'utility', 'app']
|
||||
}
|
||||
|
||||
_temp_path_command = 'mktemp -d'
|
||||
@@ -39,11 +39,13 @@ class Host extends Injectable {
|
||||
this.config = config
|
||||
this.name = config.name
|
||||
|
||||
const injector = this.app.di()
|
||||
|
||||
if ( config.packages && config.packages.type ) {
|
||||
if ( config.packages.type === 'dnf' ) {
|
||||
this.packages = new DNFManager(this)
|
||||
this.packages = injector.make(DNFManager, this)
|
||||
} else if ( config.packages.type === 'apt' ) {
|
||||
this.packages = new APTManager(this)
|
||||
this.packages = injector.make(APTManager, this)
|
||||
} else {
|
||||
throw new Error(`Invalid or unknown package manager type: ${config.packages.type}`)
|
||||
}
|
||||
@@ -51,11 +53,13 @@ class Host extends Injectable {
|
||||
|
||||
if ( config.services && config.services.type ) {
|
||||
if ( config.services.type === 'systemd' ) {
|
||||
this.services = new SystemDManager(this)
|
||||
this.services = injector.make(SystemDManager, this)
|
||||
} else {
|
||||
throw new Error(`Invalid or unknown service manager type: ${config.services.type}`)
|
||||
}
|
||||
}
|
||||
|
||||
this.injector = injector
|
||||
}
|
||||
|
||||
async execute(command) {
|
||||
@@ -82,16 +86,19 @@ class Host extends Injectable {
|
||||
|
||||
async get_temp_path() {
|
||||
const path_string = await this.run_line_result(this._temp_path_command)
|
||||
return new UniversalPath(this, path_string, UniversalPath.PATH_TYPE_DIRECTORY)
|
||||
return this.injector.make(UniversalPath, this, path_string, UniversalPath.PATH_TYPE_DIRECTORY)
|
||||
// return new UniversalPath(this, path_string, UniversalPath.PATH_TYPE_DIRECTORY)
|
||||
}
|
||||
|
||||
async get_temp_file() {
|
||||
const file_string = await this.run_line_result(this._temp_file_command)
|
||||
return new UniversalPath(this, file_string, UniversalPath.PATH_TYPE_FILE)
|
||||
return this.injector.make(UniversalPath, this, file_string, UniversalPath.PATH_TYPE_FILE)
|
||||
// return new UniversalPath(this, file_string, UniversalPath.PATH_TYPE_FILE)
|
||||
}
|
||||
|
||||
async get_path(local_path) {
|
||||
const host_path = new UniversalPath(this, local_path)
|
||||
const host_path = this.injector.make(UniversalPath, this, local_path)
|
||||
// const host_path = new UniversalPath(this, local_path)
|
||||
await host_path.classify()
|
||||
return host_path
|
||||
}
|
||||
|
||||
19
app/compat/ConfigUnit.js
Normal file
19
app/compat/ConfigUnit.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const ConfigUnit = require('libflitter/config/ConfigUnit')
|
||||
const path = require('path')
|
||||
|
||||
class CompatConfigUnit extends ConfigUnit {
|
||||
/**
|
||||
* Get the name of the service provided by this unit: 'services'
|
||||
* @returns {string} - 'services'
|
||||
*/
|
||||
static get name() {
|
||||
return 'configs'
|
||||
}
|
||||
|
||||
constructor() {
|
||||
const base_dir = path.resolve(__dirname, '..', '..', 'config')
|
||||
super(base_dir)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = CompatConfigUnit
|
||||
19
app/compat/ServicesUnit.js
Normal file
19
app/compat/ServicesUnit.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const ServicesUnit = require('libflitter/services/ServicesUnit')
|
||||
const path = require('path')
|
||||
|
||||
class CompatServicesUnit extends ServicesUnit {
|
||||
/**
|
||||
* Get the name of the service provided by this unit: 'services'
|
||||
* @returns {string} - 'services'
|
||||
*/
|
||||
static get name() {
|
||||
return 'services'
|
||||
}
|
||||
|
||||
constructor() {
|
||||
const base_dir = path.resolve(__dirname, '..', 'services')
|
||||
super(base_dir)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = CompatServicesUnit
|
||||
@@ -4,7 +4,7 @@ const RemoteHost = require('../classes/metal/RemoteHost')
|
||||
|
||||
class hosts extends Service {
|
||||
static get services() {
|
||||
return [...super.services, 'configs']
|
||||
return [...super.services, 'configs', 'app']
|
||||
}
|
||||
|
||||
_running_hosts = []
|
||||
@@ -21,11 +21,11 @@ class hosts extends Service {
|
||||
}
|
||||
|
||||
if ( config.type === 'localhost' ) {
|
||||
const host = new LocalHost(config)
|
||||
const host = this.app.di().make(LocalHost, config)
|
||||
this._running_hosts.push(host)
|
||||
return host
|
||||
} else if ( config.type === 'ssh' ) {
|
||||
const host = new RemoteHost(config)
|
||||
const host = this.app.di().make(RemoteHost, config)
|
||||
this._running_hosts.push(host)
|
||||
return host
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user