@@ -63,7 +63,7 @@ func (a *app) addUserdata(spec *flintlocktypes.MicroVMSpec, input *CreateInput)
6363 return nil
6464}
6565
66- //TODO: this whole thing needs rewriting
66+ // TODO: this whole thing needs rewriting
6767func (a * app ) convertCreateInputToReq (input * CreateInput ) (* flintlocktypes.MicroVMSpec , error ) {
6868 req := & flintlocktypes.MicroVMSpec {
6969 Id : input .Name ,
@@ -77,7 +77,7 @@ func (a *app) convertCreateInputToReq(input *CreateInput) (*flintlocktypes.Micro
7777 Image : input .KernelImage ,
7878 AddNetworkConfig : input .KernelAddNetConf ,
7979 Filename : & input .KernelFileName ,
80- //TODO: additional args
80+ // TODO: additional args
8181 },
8282 RootVolume : & flintlocktypes.Volume {
8383 Id : "root" ,
@@ -103,7 +103,7 @@ func (a *app) convertCreateInputToReq(input *CreateInput) (*flintlocktypes.Micro
103103 metaFromFile := input .MetadataFromFile [i ]
104104 metaparts := strings .Split (metaFromFile , "=" )
105105 if len (metaparts ) != 2 {
106- //TODO: proper error
106+ // TODO: proper error
107107 return nil , fmt .Errorf ("metadata not in name=pathtofile format" )
108108 }
109109 content , err := os .ReadFile (metaparts [1 ])
@@ -117,14 +117,14 @@ func (a *app) convertCreateInputToReq(input *CreateInput) (*flintlocktypes.Micro
117117 netInt := input .NetworkInterfaces [i ]
118118 netParts := strings .Split (netInt , ":" )
119119 if len (netParts ) < 1 || len (netParts ) > 4 {
120- //TODO: proper error
120+ // TODO: proper error
121121 return nil , fmt .Errorf ("network interfaces not in correct format, expect name:type:[macaddress]:[ipaddress]" )
122122 }
123123
124124 macAddress := ""
125125 ipAddress := ""
126126 name := netParts [0 ]
127- intType := netParts [1 ] //TODO: validate the types
127+ intType := netParts [1 ] // TODO: validate the types
128128
129129 if name == "eth0" {
130130 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
165165 req .Interfaces = append (req .Interfaces , apiIface )
166166 }
167167
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+
168187 return req , nil
169188}
170189
0 commit comments