github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/pkg/machine/e2e/config_init.go (about) 1 package e2e 2 3 import ( 4 "strconv" 5 ) 6 7 type initMachine struct { 8 /* 9 --cpus uint Number of CPUs (default 1) 10 --disk-size uint Disk size in GB (default 100) 11 --ignition-path string Path to ignition file 12 --image-path string Path to qcow image (default "testing") 13 -m, --memory uint Memory in MB (default 2048) 14 --now Start machine now 15 --rootful Whether this machine should prefer rootful container execution 16 --timezone string Set timezone (default "local") 17 -v, --volume stringArray Volumes to mount, source:target 18 --volume-driver string Optional volume driver 19 20 */ 21 cpus *uint 22 diskSize *uint 23 ignitionPath string 24 imagePath string 25 memory *uint 26 now bool 27 timezone string 28 rootful bool 29 volumes []string 30 31 cmd []string 32 } 33 34 func (i *initMachine) buildCmd(m *machineTestBuilder) []string { 35 cmd := []string{"machine", "init"} 36 if i.cpus != nil { 37 cmd = append(cmd, "--cpus", strconv.Itoa(int(*i.cpus))) 38 } 39 if i.diskSize != nil { 40 cmd = append(cmd, "--disk-size", strconv.Itoa(int(*i.diskSize))) 41 } 42 if l := len(i.ignitionPath); l > 0 { 43 cmd = append(cmd, "--ignition-path", i.ignitionPath) 44 } 45 if l := len(i.imagePath); l > 0 { 46 cmd = append(cmd, "--image-path", i.imagePath) 47 } 48 if i.memory != nil { 49 cmd = append(cmd, "--memory", strconv.Itoa(int(*i.memory))) 50 } 51 if l := len(i.timezone); l > 0 { 52 cmd = append(cmd, "--timezone", i.timezone) 53 } 54 for _, v := range i.volumes { 55 cmd = append(cmd, "--volume", v) 56 } 57 if i.now { 58 cmd = append(cmd, "--now") 59 } 60 cmd = append(cmd, m.name) 61 i.cmd = cmd 62 return cmd 63 } 64 65 func (i *initMachine) withCPUs(num uint) *initMachine { 66 i.cpus = &num 67 return i 68 } 69 func (i *initMachine) withDiskSize(size uint) *initMachine { 70 i.diskSize = &size 71 return i 72 } 73 74 func (i *initMachine) withIgnitionPath(path string) *initMachine { 75 i.ignitionPath = path 76 return i 77 } 78 79 func (i *initMachine) withImagePath(path string) *initMachine { 80 i.imagePath = path 81 return i 82 } 83 84 func (i *initMachine) withMemory(num uint) *initMachine { 85 i.memory = &num 86 return i 87 } 88 89 func (i *initMachine) withNow() *initMachine { 90 i.now = true 91 return i 92 } 93 94 func (i *initMachine) withTimezone(tz string) *initMachine { 95 i.timezone = tz 96 return i 97 } 98 99 func (i *initMachine) withVolume(v string) *initMachine { 100 i.volumes = append(i.volumes, v) 101 return i 102 }