@flowfuse/driver-kubernetes 2.7.0 → 2.7.1-1e7bf08-202408281041.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.
package/kubernetes.js CHANGED
@@ -1,4 +1,5 @@
1
1
  const got = require('got')
2
+ const FormData = require('form-data')
2
3
  const k8s = require('@kubernetes/client-node')
3
4
  const _ = require('lodash')
4
5
  const awsEFS = require('./lib/aws-efs.js')
@@ -498,6 +499,11 @@ const getEndpoints = async (project) => {
498
499
  }
499
500
  }
500
501
 
502
+ const getStaticFileUrl = async (instance, filePath) => {
503
+ const prefix = instance.safeName.match(/^[0-9]/) ? 'srv-' : ''
504
+ return `http://${prefix}${instance.safeName}.${this._namespace}:2880/flowforge/files/_/${encodeURIComponent(filePath)}`
505
+ }
506
+
501
507
  module.exports = {
502
508
  /**
503
509
  * Initialises this driver
@@ -1117,5 +1123,64 @@ module.exports = {
1117
1123
  }
1118
1124
 
1119
1125
  return properties
1126
+ },
1127
+
1128
+ // Static Assets API
1129
+ listFiles: async (instance, filePath) => {
1130
+ const fileUrl = await getStaticFileUrl(instance, filePath)
1131
+ console.log(fileUrl)
1132
+ try {
1133
+ return got.get(fileUrl).json()
1134
+ } catch (err) {
1135
+ console.log(err)
1136
+ err.statusCode = err.response.statusCode
1137
+ throw err
1138
+ }
1139
+ },
1140
+
1141
+ updateFile: async (instance, filePath, update) => {
1142
+ const fileUrl = await getStaticFileUrl(instance, filePath)
1143
+ try {
1144
+ return got.put(fileUrl, {
1145
+ json: update
1146
+ })
1147
+ } catch (err) {
1148
+ err.statusCode = err.response.statusCode
1149
+ throw err
1150
+ }
1151
+ },
1152
+
1153
+ deleteFile: async (instance, filePath) => {
1154
+ const fileUrl = await getStaticFileUrl(instance, filePath)
1155
+ try {
1156
+ return got.delete(fileUrl)
1157
+ } catch (err) {
1158
+ err.statusCode = err.response.statusCode
1159
+ throw err
1160
+ }
1161
+ },
1162
+ createDirectory: async (instance, filePath, directoryName) => {
1163
+ const fileUrl = await getStaticFileUrl(instance, filePath)
1164
+ try {
1165
+ return got.post(fileUrl, {
1166
+ json: { path: directoryName }
1167
+ })
1168
+ } catch (err) {
1169
+ err.statusCode = err.response.statusCode
1170
+ throw err
1171
+ }
1172
+ },
1173
+ uploadFile: async (instance, filePath, fileBuffer) => {
1174
+ const form = new FormData()
1175
+ form.append('file', fileBuffer, { filename: filePath })
1176
+ const fileUrl = await getStaticFileUrl(instance, filePath)
1177
+ try {
1178
+ return got.post(fileUrl, {
1179
+ body: form
1180
+ })
1181
+ } catch (err) {
1182
+ err.statusCode = err.response.statusCode
1183
+ throw err
1184
+ }
1120
1185
  }
1121
1186
  }
package/lib/aws-efs.js CHANGED
@@ -31,7 +31,8 @@ async function lookupStorageClass (tagName) {
31
31
  if (found) {
32
32
  // console.log(storageClass)
33
33
  const apParams = {
34
- FileSystemId: fsList.FileSystems[i].FileSystemId
34
+ FileSystemId: fsList.FileSystems[i].FileSystemId,
35
+ MaxResults: 999
35
36
  }
36
37
  // console.log(apParams)
37
38
  const apListCommand = new DescribeAccessPointsCommand(apParams)
@@ -51,4 +52,4 @@ async function lookupStorageClass (tagName) {
51
52
 
52
53
  module.exports = {
53
54
  lookupStorageClass
54
- }
55
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowfuse/driver-kubernetes",
3
- "version": "2.7.0",
3
+ "version": "2.7.1-1e7bf08-202408281041.0",
4
4
  "description": "Kubernetes driver for FlowFuse",
5
5
  "main": "kubernetes.js",
6
6
  "scripts": {
@@ -23,6 +23,7 @@
23
23
  "dependencies": {
24
24
  "@aws-sdk/client-efs": "^3.600.0",
25
25
  "@kubernetes/client-node": "^0.18.1",
26
+ "form-data": "^4.0.0",
26
27
  "got": "^11.8.0",
27
28
  "lodash": "^4.17.21"
28
29
  },