Skip to content

Commit 1f23f82

Browse files
authored
feat: add private network to function and container (#303)
* feat: add private network to function and container --------- Co-authored-by: RemyMach
1 parent affa499 commit 1f23f82

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ functions:
179179
input:
180180
key-a: "value-a"
181181
key-b: "value-b"
182+
183+
# ID of the private network to attach the function to
184+
privateNetworkId: "3fd741d4-f686-4afc-bcea-d720c695748f"
182185
```
183186

184187
### Container-specific configuration
@@ -264,6 +267,9 @@ custom:
264267
# Deprecated: number of simultaneous requests to handle
265268
# Please use scalingOption of type concurrentRequests instead
266269
# maxConcurrency: 20
270+
271+
# ID of the private network to attach the container to
272+
privateNetworkId: "3fd741d4-f686-4afc-bcea-d720c695748f"
267273
```
268274

269275
## Supported commands

deploy/lib/createContainers.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ module.exports = {
154154
sandbox: container.sandbox,
155155
health_check: adaptHealthCheckToAPI(container.healthCheck),
156156
scaling_option: adaptScalingOptionToAPI(container.scalingOption),
157+
private_network_id: container.privateNetworkId,
157158
};
158159

159160
// checking if there is custom_domains set on container creation.
@@ -177,6 +178,13 @@ module.exports = {
177178
},
178179

179180
async updateSingleContainer(container, foundContainer) {
181+
let privateNetworkId = container.privateNetworkId;
182+
const hasToDeletePrivateNetwork =
183+
foundContainer.private_network_id && !container.privateNetworkId;
184+
if (hasToDeletePrivateNetwork) {
185+
privateNetworkId = "";
186+
}
187+
180188
const params = {
181189
redeploy: false,
182190
environment_variables: container.env,
@@ -201,6 +209,7 @@ module.exports = {
201209
sandbox: container.sandbox,
202210
health_check: adaptHealthCheckToAPI(container.healthCheck),
203211
scaling_option: adaptScalingOptionToAPI(container.scalingOption),
212+
private_network_id: privateNetworkId,
204213
};
205214

206215
// note about maxConcurrency deprecation

deploy/lib/createFunctions.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ Runtime lifecycle doc : https://www.scaleway.com/en/docs/compute/functions/refer
183183
domain_name: func.domain_name,
184184
http_option: func.httpOption,
185185
sandbox: func.sandbox,
186+
private_network_id: func.privateNetworkId,
186187
};
187188

188189
const availableRuntimes = await this.listRuntimes();
@@ -208,6 +209,13 @@ Runtime lifecycle doc : https://www.scaleway.com/en/docs/compute/functions/refer
208209
},
209210

210211
async updateSingleFunction(func, foundFunc) {
212+
let privateNetworkId = func.privateNetworkId;
213+
const hasToDeletePrivateNetwork =
214+
foundFunc.private_network_id && !func.privateNetworkId;
215+
if (hasToDeletePrivateNetwork) {
216+
privateNetworkId = "";
217+
}
218+
211219
const params = {
212220
redeploy: false,
213221
environment_variables: func.env,
@@ -226,6 +234,7 @@ Runtime lifecycle doc : https://www.scaleway.com/en/docs/compute/functions/refer
226234
domain_name: func.domain_name,
227235
http_option: func.httpOption,
228236
sandbox: func.sandbox,
237+
private_network_id: privateNetworkId,
229238
};
230239

231240
const availableRuntimes = await this.listRuntimes();

0 commit comments

Comments
 (0)