Skip to content

Commit b61243b

Browse files
committed
feat: Allow attaching the volume in machines.create
1 parent b0ddea6 commit b61243b

5 files changed

Lines changed: 28 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ VOLUME_ID=$(obelisk client execution submit -f --json activity-flyio:fly-http/vo
6363
}' | jq -r '.[-1].ok.ok.id')
6464
```
6565

66-
Destroy the volume:
66+
Delete the volume:
6767
```sh
6868
obelisk client execution submit -f activity-flyio:fly-http/volumes@1.0.0-beta.delete -- \
6969
\"$FLY_APP_NAME\" \"$VOLUME_ID\"

fly-http/src/machine.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub(crate) mod ser {
2020
use crate::activity_flyio::fly_http::regions::Region;
2121
use crate::exports::activity_flyio::fly_http::machines::{
2222
CpuKind, ExecResponse, GuestConfig, HostStatus, InitConfig, Machine, MachineConfig,
23-
MachineRestart, RestartPolicy, StopConfig,
23+
MachineRestart, Mount, RestartPolicy, StopConfig,
2424
};
2525
use serde::de::DeserializeOwned;
2626
use serde::{Deserialize, Serialize};
@@ -77,6 +77,7 @@ pub(crate) mod ser {
7777
env: Option<HashMap<String, String>>,
7878
restart: Option<MachineRestartSer>,
7979
stop_config: Option<StopConfigSer>,
80+
mounts: Option<Vec<Mount>>,
8081
}
8182

8283
#[derive(Serialize, Deserialize, Debug)]
@@ -160,6 +161,12 @@ pub(crate) mod ser {
160161
timeout: Option<u64>,
161162
}
162163

164+
#[derive(Serialize, Deserialize, Debug)]
165+
pub(crate) struct MountSer {
166+
volume: String,
167+
path: String,
168+
}
169+
163170
#[derive(Deserialize)]
164171
pub(crate) struct MachineCreateResponseSer {
165172
pub(crate) id: String,
@@ -306,6 +313,7 @@ pub(crate) mod ser {
306313
restart,
307314
init,
308315
stop_config,
316+
mounts: wit.mounts,
309317
}
310318
}
311319
}
@@ -353,6 +361,7 @@ pub(crate) mod ser {
353361
restart,
354362
init,
355363
stop_config,
364+
mounts: ser.mounts,
356365
}
357366
}
358367
}

fly-http/src/snapshots/fly_http__machine__tests__machine_deserialization.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ MachineSer {
4040
},
4141
),
4242
stop_config: None,
43+
mounts: None,
4344
},
4445
created_at: "2025-09-10T12:03:04Z",
4546
updated_at: "2025-09-10T12:03:07Z",

fly-http/wit/activity-flyio_fly-http@1.0.0-beta/fly.wit

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ interface machines {
5959
env: option<list<tuple<string, string>>>,
6060
restart: option<machine-restart>,
6161
stop-config: option<stop-config>,
62+
mounts: option<list<mount>>,
63+
}
64+
65+
record mount {
66+
volume: string,
67+
path: string,
6268
}
6369

6470
record guest-config {

scripts/fly-http-machine-config.json.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
cat <<EOF
3+
cat <<EOF
44
{
55
"image": "$FLY_IMAGE",
66
"init": {
@@ -13,6 +13,14 @@ cat <<EOF
1313
},
1414
"restart": {
1515
"policy": "no"
16-
}
16+
}$(if [ -n "$VOLUME_ID" ]; then
17+
echo ',
18+
"mounts": [
19+
{
20+
"volume": "'"$VOLUME_ID"'",
21+
"path": "/opt"
22+
}
23+
]'
24+
fi)
1725
}
1826
EOF

0 commit comments

Comments
 (0)