@flowfuse/driver-docker 2.21.1 → 2.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,7 +15,7 @@ jobs:
15
15
  steps:
16
16
  - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
17
17
  - name: Use Node.js ${{ matrix.node-version }}
18
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
18
+ uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
19
19
  with:
20
20
  node-version: ${{ matrix.node-version }}
21
21
  - name: Install Dependencies
@@ -9,10 +9,10 @@ jobs:
9
9
  runs-on: ubuntu-latest
10
10
  steps:
11
11
  - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
12
- - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
12
+ - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
13
13
  with:
14
14
  node-version: 18
15
15
  - run: npm ci --omit dev
16
- - uses: JS-DevTools/npm-publish@19c28f1ef146469e409470805ea4279d47c3d35c # v3.1.1
16
+ - uses: JS-DevTools/npm-publish@ad693561f8a5b5d4c76f14407da60aa15cb10f90 # v4.0.1
17
17
  with:
18
18
  token: ${{ secrets.NPM_PUBLISH_TOKEN }}
package/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ #### 2.22.0: Release
2
+
3
+ - Bump JS-DevTools/npm-publish from 3.1.1 to 4.0.0 (#148)
4
+ - add team broker mqtt agent support (#147) @hardillb
5
+ - Bump JS-DevTools/npm-publish from 4.0.0 to 4.0.1 (#149) @app/dependabot
6
+
7
+ #### 2.21.2: Release
8
+
9
+ - Bump actions/setup-node from 4.4.0 to 5.0.0 (#145)
10
+
1
11
  #### 2.21.1: Release
2
12
 
3
13
 
package/docker.js CHANGED
@@ -181,9 +181,16 @@ const getStaticFileUrl = async (instance, filePath) => {
181
181
  return `http://${instance.id}:2880/flowforge/files/_/${encodeURIComponent(filePath)}`
182
182
  }
183
183
 
184
+ const getBrokerName = (broker) => {
185
+ const agent = broker.constructor.name === 'TeamBrokerAgent'
186
+ const name = `mqtt-schema-agent-${broker.Team.hashid.toLowerCase()}-${agent ? 'team-broker' : broker.hashid.toLowerCase()}`
187
+ return name
188
+ }
189
+
184
190
  const createMQttTopicAgent = async (broker) => {
191
+ const agent = broker.constructor.name === 'TeamBrokerAgent'
185
192
  const image = this._app.config.driver.options?.mqttSchemaContainer || `${this._app.config.driver.options?.registry ? this._app.config.driver.options.registry + '/' : ''}flowfuse/mqtt-schema-agent`
186
- const name = `mqtt-schema-agent-${broker.Team.hashid.toLowerCase()}-${broker.hashid.toLowerCase()}`
193
+ const name = getBrokerName(broker)
187
194
  const contOptions = {
188
195
  Image: image,
189
196
  name,
@@ -207,8 +214,11 @@ const createMQttTopicAgent = async (broker) => {
207
214
  const { token } = await broker.refreshAuthTokens()
208
215
  contOptions.Env.push(`FORGE_TEAM_TOKEN=${token}`)
209
216
  contOptions.Env.push(`FORGE_URL=${this._app.config.api_url}`)
210
- contOptions.Env.push(`FORGE_BROKER_ID=${broker.hashid}`)
217
+ contOptions.Env.push(`FORGE_BROKER_ID=${agent ? 'team-broker' : broker.hashid}`)
211
218
  contOptions.Env.push(`FORGE_TEAM_ID=${broker.Team.hashid}`)
219
+ if (agent) {
220
+ contOptions.Env.push('FORGE_TIMEOUT=24')
221
+ }
212
222
 
213
223
  const containerList = await this._docker.listImages()
214
224
  let containerFound = false
@@ -381,7 +391,7 @@ module.exports = {
381
391
  brokers.forEach(async (broker) => {
382
392
  if (broker.Team) {
383
393
  if (broker.state === 'running') {
384
- const name = `mqtt-schema-agent-${broker.Team.hashid.toLowerCase()}-${broker.hashid.toLowerCase()}`
394
+ const name = getBrokerName(broker)
385
395
  this._app.log.info(`[docker] Testing MQTT Agent ${name} container exists`)
386
396
  this._app.log.debug(`${name}`)
387
397
  let container
@@ -733,7 +743,7 @@ module.exports = {
733
743
  createMQttTopicAgent(broker)
734
744
  },
735
745
  stopBrokerAgent: async (broker) => {
736
- const name = `mqtt-schema-agent-${broker.Team.hashid.toLowerCase()}-${broker.hashid.toLowerCase()}`
746
+ const name = getBrokerName(broker)
737
747
  try {
738
748
  const container = await this._docker.getContainer(name)
739
749
  await container.stop()
@@ -743,7 +753,7 @@ module.exports = {
743
753
  }
744
754
  },
745
755
  getBrokerAgentState: async (broker) => {
746
- const name = `mqtt-schema-agent-${broker.Team.hashid.toLowerCase()}-${broker.hashid.toLowerCase()}`
756
+ const name = getBrokerName(broker)
747
757
  try {
748
758
  const status = await got.get(`http://${name}:3500/api/v1/status`).json()
749
759
  return status
@@ -752,7 +762,7 @@ module.exports = {
752
762
  }
753
763
  },
754
764
  sendBrokerAgentCommand: async (broker, command) => {
755
- const name = `mqtt-schema-agent-${broker.Team.hashid.toLowerCase()}-${broker.hashid.toLowerCase()}`
765
+ const name = getBrokerName(broker)
756
766
  if (command === 'start' || command === 'restart') {
757
767
  try {
758
768
  await got.post(`http://${name}:3500/api/v1/commands/start`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowfuse/driver-docker",
3
- "version": "2.21.1",
3
+ "version": "2.22.0",
4
4
  "description": "Docker driver for FlowFuse",
5
5
  "main": "docker.js",
6
6
  "scripts": {