chore(xo-server/Xo): pass config as named param

As done in xo-proxy.
This commit is contained in:
Julien Fontanet 2021-04-07 10:18:15 +02:00
parent 8109253eeb
commit 7024c7d598
11 changed files with 11 additions and 11 deletions

View File

@ -718,7 +718,7 @@ export default async function main(args) {
}
// Creates main object.
const xo = new Xo(config)
const xo = new Xo({ config })
// Register web server close on XO stop.
xo.on('stop', () => fromCallback.call(webServer, 'stop'))

View File

@ -14,7 +14,7 @@ const log = createLogger('xo:authentification')
const noSuchAuthenticationToken = id => noSuchObject(id, 'authenticationToken')
export default class {
constructor(xo, { authentication: config }) {
constructor(xo, { config: { authentication: config } }) {
this._defaultTokenValidity = parseDuration(config.defaultTokenValidity)
this._maxTokenValidity = parseDuration(config.maxTokenValidity)
this._throttlingDelay = parseDuration(config.throttlingDelay)

View File

@ -215,7 +215,7 @@ export default class BackupNg {
return this._runningRestores
}
constructor(app: any, config) {
constructor(app: any, { config }) {
this._app = app
this._logger = undefined
this._runningRestores = new Set()

View File

@ -6,7 +6,7 @@ import { deduped } from '@vates/disposable/deduped'
import { RemoteAdapter } from '@xen-orchestra/backups/RemoteAdapter'
export default class BackupsRemoteAdapter {
constructor(app, { backups }) {
constructor(app, { config: { backups } }) {
this._app = app
this._config = backups
}

View File

@ -13,7 +13,7 @@ export default class Http {
return this._agent
}
constructor(_, { httpProxy = firstDefined(process.env.http_proxy, process.env.HTTP_PROXY) }) {
constructor(_, { config: { httpProxy = firstDefined(process.env.http_proxy, process.env.HTTP_PROXY) } }) {
this._hasOwnHttpProxy = httpProxy != null
this.setHttpProxy(httpProxy)

View File

@ -94,7 +94,7 @@ export default class metadataBackup {
return this._runningMetadataRestores
}
constructor(app: any, { backups }) {
constructor(app: any, { config: { backups } }) {
this._app = app
this._backupOptions = backups
this._logger = undefined

View File

@ -39,7 +39,7 @@ const assertProxyAddress = (proxy, address) => {
}
export default class Proxy {
constructor(app, conf) {
constructor(app, { config: conf }) {
this._app = app
const xoProxyConf = (this._xoProxyConf = conf['xo-proxy'])
const rules = {

View File

@ -17,7 +17,7 @@ const obfuscateRemote = ({ url, ...remote }) => {
}
export default class {
constructor(xo, { remoteOptions }) {
constructor(xo, { config: { remoteOptions } }) {
this._handlers = { __proto__: null }
this._remoteOptions = remoteOptions
this._remotes = new Remotes({

View File

@ -48,7 +48,7 @@ const valueEncoding = {
}
export default class {
constructor(xo, config) {
constructor(xo, { config }) {
const dir = `${config.datadir}/leveldb`
this._db = ensureDir(dir).then(() => levelup(dir))
}

View File

@ -36,7 +36,7 @@ const log = createLogger('xo:xo-mixins:xen-servers')
// - _xapis[server.id] id defined
// - _serverIdsByPool[xapi.pool.$id] is server.id
export default class {
constructor(xo, { guessVhdSizeOnImport, xapiMarkDisconnectedDelay, xapiOptions }) {
constructor(xo, { config: { guessVhdSizeOnImport, xapiMarkDisconnectedDelay, xapiOptions } }) {
this._objectConflicts = { __proto__: null } // TODO: clean when a server is disconnected.
const serversDb = (this._servers = new Servers({
connection: xo._redis,

View File

@ -19,7 +19,7 @@ const log = createLogger('xo:xo')
@mixin(Object.values(mixins))
export default class Xo extends EventEmitter {
constructor(config) {
constructor({ config }) {
super()
// a lot of mixins adds listener for start/stop/… events