@@ -216,6 +216,7 @@ image_copy_tmp_dir="storage"`
216216 })
217217 })
218218
219+
219220 Describe ("NewConfig" , func () {
220221 It ("should success with default config" , func () {
221222 // Given
@@ -347,6 +348,7 @@ image_copy_tmp_dir="storage"`
347348 gomega .Expect (config .Containers .Privileged ).To (gomega .BeTrue ())
348349 gomega .Expect (config .Containers .ReadOnly ).To (gomega .BeTrue ())
349350 gomega .Expect (config .Engine .ImageParallelCopies ).To (gomega .Equal (uint (10 )))
351+ gomega .Expect (config .Engine .Platform ).To (gomega .Equal ("linux/amd64" ))
350352 gomega .Expect (config .Engine .PlatformToOCIRuntime ).To (gomega .Equal (PlatformToOCIRuntimeMap ))
351353 gomega .Expect (config .Engine .ImageDefaultFormat ).To (gomega .Equal ("v2s2" ))
352354 gomega .Expect (config .Engine .CompressionFormat ).To (gomega .BeEquivalentTo ("zstd:chunked" ))
@@ -480,6 +482,68 @@ image_copy_tmp_dir="storage"`
480482 err = defConf .Engine .Validate ()
481483 gomega .Expect (err ).To (gomega .HaveOccurred ())
482484 })
485+
486+ It ("should succeed with valid platform" , func () {
487+ defConf , err := defaultConfig ()
488+ gomega .Expect (err ).ToNot (gomega .HaveOccurred ())
489+
490+ defConf .Engine .Platform = "linux/amd64"
491+ err = defConf .Engine .Validate ()
492+ gomega .Expect (err ).ToNot (gomega .HaveOccurred ())
493+
494+ defConf .Engine .Platform = "linux/arm64/v8"
495+ err = defConf .Engine .Validate ()
496+ gomega .Expect (err ).ToNot (gomega .HaveOccurred ())
497+ })
498+
499+ It ("should succeed with empty platform" , func () {
500+ defConf , err := defaultConfig ()
501+ gomega .Expect (err ).ToNot (gomega .HaveOccurred ())
502+
503+ defConf .Engine .Platform = ""
504+ err = defConf .Engine .Validate ()
505+ gomega .Expect (err ).ToNot (gomega .HaveOccurred ())
506+ })
507+
508+ It ("should fail with invalid platform" , func () {
509+ defConf , err := defaultConfig ()
510+ gomega .Expect (err ).ToNot (gomega .HaveOccurred ())
511+
512+ defConf .Engine .Platform = "linux"
513+ err = defConf .Engine .Validate ()
514+ gomega .Expect (err ).To (gomega .HaveOccurred ())
515+
516+ defConf .Engine .Platform = "linux/amd64/"
517+ err = defConf .Engine .Validate ()
518+ gomega .Expect (err ).To (gomega .HaveOccurred ())
519+
520+ defConf .Engine .Platform = "/amd64"
521+ err = defConf .Engine .Validate ()
522+ gomega .Expect (err ).To (gomega .HaveOccurred ())
523+ })
524+
525+ It ("should parse platform components correctly" , func () {
526+ defConf , err := defaultConfig ()
527+ gomega .Expect (err ).ToNot (gomega .HaveOccurred ())
528+
529+ defConf .Engine .Platform = "linux/amd64"
530+ os , arch , variant := defConf .Engine .PlatformComponents ()
531+ gomega .Expect (os ).To (gomega .Equal ("linux" ))
532+ gomega .Expect (arch ).To (gomega .Equal ("amd64" ))
533+ gomega .Expect (variant ).To (gomega .Equal ("" ))
534+
535+ defConf .Engine .Platform = "linux/arm64/v8"
536+ os , arch , variant = defConf .Engine .PlatformComponents ()
537+ gomega .Expect (os ).To (gomega .Equal ("linux" ))
538+ gomega .Expect (arch ).To (gomega .Equal ("arm64" ))
539+ gomega .Expect (variant ).To (gomega .Equal ("v8" ))
540+
541+ defConf .Engine .Platform = ""
542+ os , arch , variant = defConf .Engine .PlatformComponents ()
543+ gomega .Expect (os ).To (gomega .Equal ("" ))
544+ gomega .Expect (arch ).To (gomega .Equal ("" ))
545+ gomega .Expect (variant ).To (gomega .Equal ("" ))
546+ })
483547 })
484548
485549 Describe ("Service Destinations" , func () {
0 commit comments