@@ -224,6 +224,50 @@ var _ = Describe("podman machine init", func() {
224
224
Expect (sshSession .outputToString ()).To (ContainSubstring ("example" ))
225
225
})
226
226
227
+ It ("machine init with ignition path" , func () {
228
+ skipIfWSL ("Ignition is not compatible with WSL machines since they are not based on Fedora CoreOS" )
229
+
230
+ tmpDir , err := os .MkdirTemp ("" , "" )
231
+ defer func () { _ = utils .GuardedRemoveAll (tmpDir ) }()
232
+ Expect (err ).ToNot (HaveOccurred ())
233
+
234
+ tmpFile , err := os .CreateTemp (tmpDir , "test-ignition-*.ign" )
235
+ Expect (err ).ToNot (HaveOccurred ())
236
+
237
+ mockIgnitionContent := `{"ignition":{"version":"3.4.0"},"passwd":{"users":[{"name":"core"}]}}`
238
+
239
+ _ , err = tmpFile .WriteString (mockIgnitionContent )
240
+ Expect (err ).ToNot (HaveOccurred ())
241
+
242
+ err = tmpFile .Close ()
243
+ Expect (err ).ToNot (HaveOccurred ())
244
+
245
+ name := randomString ()
246
+ i := new (initMachine )
247
+ session , err := mb .setName (name ).setCmd (i .withImage (mb .imagePath ).withIgnitionPath (tmpFile .Name ())).run ()
248
+ Expect (err ).ToNot (HaveOccurred ())
249
+ Expect (session ).To (Exit (0 ))
250
+
251
+ configDir := filepath .Join (testDir , ".config" , "containers" , "podman" , "machine" , testProvider .VMType ().String ())
252
+
253
+ // test that all required machine files are created
254
+ fileExtensions := []string {".lock" , ".json" , ".ign" }
255
+ for _ , ext := range fileExtensions {
256
+ filename := filepath .Join (configDir , fmt .Sprintf ("%s%s" , name , ext ))
257
+
258
+ _ , err := os .Stat (filename )
259
+ Expect (err ).ToNot (HaveOccurred (), fmt .Sprintf ("file %v does not exist" , filename ))
260
+ }
261
+
262
+ // enforce that the raw ignition is copied over verbatim
263
+ createdIgn := filepath .Join (configDir , fmt .Sprintf ("%s%s" , name , ".ign" ))
264
+ contentWanted , err := os .ReadFile (tmpFile .Name ())
265
+ Expect (err ).ToNot (HaveOccurred ())
266
+ contentGot , err := os .ReadFile (createdIgn )
267
+ Expect (err ).ToNot (HaveOccurred ())
268
+ Expect (contentWanted ).To (Equal (contentGot ), "The ignition file provided and the ignition file created do not match" )
269
+ })
270
+
227
271
It ("machine init rootless docker.sock check" , func () {
228
272
i := initMachine {}
229
273
name := randomString ()
0 commit comments