Skip to content

Commit

Permalink
Merge pull request #3141 from FlowFuse/update-driver-scope
Browse files Browse the repository at this point in the history
Update container loading for new module scopes
  • Loading branch information
knolleary authored Nov 29, 2023
2 parents 579f14a + fb7ddf9 commit 2004f93
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
14 changes: 9 additions & 5 deletions forge/containers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@ const fp = require('fastify-plugin')

const wrapper = require('./wrapper.js')

const DRIVER_MODULES = {
stub: './stub/index.js',
localfs: '@flowfuse/driver-localfs',
docker: '@flowfuse/driver-docker',
kubernetes: '@flowfuse/driver-kubernetes'
}

module.exports = fp(async function (app, _opts, next) {
const containerDialect = app.config.driver.type
const containerModule = containerDialect === 'stub'
? './stub/index.js'
: `@flowforge/${containerDialect}`

const containerModule = DRIVER_MODULES[containerDialect]
try {
const driver = require(containerModule)
await wrapper.init(app, driver, {
Expand All @@ -58,7 +62,7 @@ module.exports = fp(async function (app, _opts, next) {
await wrapper.shutdown()
})
} catch (err) {
app.log.error('Failed to load the container driver')
app.log.error(`Failed to load the container driver: ${containerDialect}`)
throw err
}

Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@fastify/swagger": "^8.10.1",
"@fastify/swagger-ui": "^1.9.0",
"@fastify/websocket": "^8.1.0",
"@flowforge/localfs": "^1.14.0",
"@flowfuse/driver-localfs": "^1.14.0",
"@headlessui/vue": "1.7.16",
"@heroicons/vue": "1.0.6",
"@immobiliarelabs/fastify-sentry": "^7.1.1",
Expand Down

0 comments on commit 2004f93

Please sign in to comment.