Add package absent state
This commit is contained in:
parent
a6c0b5884a
commit
7e94f9792a
24
app/classes/state/os/PackageAbsentState.js
Normal file
24
app/classes/state/os/PackageAbsentState.js
Normal file
@ -0,0 +1,24 @@
|
||||
const State = require('../State')
|
||||
|
||||
class PackageAbsentState extends State {
|
||||
constructor(host, config) {
|
||||
if ( !host.packages ) {
|
||||
throw new Error(`Cannot apply package absent state to host ${host.name}: missing package manager API.`)
|
||||
}
|
||||
super(host, config)
|
||||
}
|
||||
|
||||
async reverse() {
|
||||
return this._host.packages.install(this._config.package)
|
||||
}
|
||||
|
||||
async check() {
|
||||
return !(await this._host.packages.is_installed(this._config.package))
|
||||
}
|
||||
|
||||
async apply() {
|
||||
return this._host.packages.uninstall(this._config.package)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = PackageAbsentState
|
@ -14,7 +14,6 @@ class StatesService extends Service {
|
||||
// TODO apache and nginx states - virtual host, reverse proxy
|
||||
// TODO package repository states - import keys, install repository
|
||||
// TODO service manager states - service enabled, service installed, stopped
|
||||
// TODO package states - uninstalled
|
||||
|
||||
'fs.file': require('../classes/state/fs/FileState'),
|
||||
'fs.directory': require('../classes/state/fs/DirectoryState'),
|
||||
@ -30,6 +29,7 @@ class StatesService extends Service {
|
||||
'os.cmd': require('../classes/state/os/CommandState'),
|
||||
|
||||
'package.present': require('../classes/state/os/PackageState'),
|
||||
'package.absent': require('../classes/state/os/PackageAbsentState'),
|
||||
'package.updates': require('../classes/state/os/UpdateState'),
|
||||
'package.cache.clear': require('../classes/state/os/PackageCacheClearedState'),
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user