@@ -63,7 +63,7 @@ func (a *app) addUserdata(spec *flintlocktypes.MicroVMSpec, input *CreateInput)
63
63
return nil
64
64
}
65
65
66
- //TODO: this whole thing needs rewriting
66
+ // TODO: this whole thing needs rewriting
67
67
func (a * app ) convertCreateInputToReq (input * CreateInput ) (* flintlocktypes.MicroVMSpec , error ) {
68
68
req := & flintlocktypes.MicroVMSpec {
69
69
Id : input .Name ,
@@ -77,7 +77,7 @@ func (a *app) convertCreateInputToReq(input *CreateInput) (*flintlocktypes.Micro
77
77
Image : input .KernelImage ,
78
78
AddNetworkConfig : input .KernelAddNetConf ,
79
79
Filename : & input .KernelFileName ,
80
- //TODO: additional args
80
+ // TODO: additional args
81
81
},
82
82
RootVolume : & flintlocktypes.Volume {
83
83
Id : "root" ,
@@ -103,7 +103,7 @@ func (a *app) convertCreateInputToReq(input *CreateInput) (*flintlocktypes.Micro
103
103
metaFromFile := input .MetadataFromFile [i ]
104
104
metaparts := strings .Split (metaFromFile , "=" )
105
105
if len (metaparts ) != 2 {
106
- //TODO: proper error
106
+ // TODO: proper error
107
107
return nil , fmt .Errorf ("metadata not in name=pathtofile format" )
108
108
}
109
109
content , err := os .ReadFile (metaparts [1 ])
@@ -117,14 +117,14 @@ func (a *app) convertCreateInputToReq(input *CreateInput) (*flintlocktypes.Micro
117
117
netInt := input .NetworkInterfaces [i ]
118
118
netParts := strings .Split (netInt , ":" )
119
119
if len (netParts ) < 1 || len (netParts ) > 4 {
120
- //TODO: proper error
120
+ // TODO: proper error
121
121
return nil , fmt .Errorf ("network interfaces not in correct format, expect name:type:[macaddress]:[ipaddress]" )
122
122
}
123
123
124
124
macAddress := ""
125
125
ipAddress := ""
126
126
name := netParts [0 ]
127
- intType := netParts [1 ] //TODO: validate the types
127
+ intType := netParts [1 ] // TODO: validate the types
128
128
129
129
if name == "eth0" {
130
130
return nil , fmt .Errorf ("you cannot use eth0 as the name of the interface as this is reserved" )
@@ -165,6 +165,25 @@ func (a *app) convertCreateInputToReq(input *CreateInput) (*flintlocktypes.Micro
165
165
req .Interfaces = append (req .Interfaces , apiIface )
166
166
}
167
167
168
+ for i := range input .Volumes {
169
+ volume := input .Volumes [i ]
170
+ volParts := strings .Split (volume , "=" )
171
+ if len (volParts ) != 3 {
172
+ // TODO: proper error
173
+ return nil , fmt .Errorf ("volume not in correct format, expect name=containerimage=mountpoint" )
174
+ }
175
+
176
+ apiVolume := & flintlocktypes.Volume {
177
+ Id : volParts [0 ],
178
+ IsReadOnly : false ,
179
+ MountPoint : volParts [2 ],
180
+ Source : & flintlocktypes.VolumeSource {
181
+ ContainerSource : & volParts [1 ],
182
+ },
183
+ }
184
+ req .AdditionalVolumes = append (req .AdditionalVolumes , apiVolume )
185
+ }
186
+
168
187
return req , nil
169
188
}
170
189
0 commit comments