@@ -134,32 +134,32 @@ func Target() string {
134134
135135// NoneDriver returns whether or not this test is using the none driver
136136func NoneDriver () bool {
137- return strings . Contains ( * startArgs , "--driver=none" ) || strings . Contains ( * startArgs , "--vm-driver= none" )
137+ return matchDriverFlag ( " none" )
138138}
139139
140140// HyperVDriver returns whether or not this test is using the Hyper-V driver
141141func HyperVDriver () bool {
142- return strings . Contains ( * startArgs , "--driver=hyperv" ) || strings . Contains ( * startArgs , "--vm-driver= hyperv" )
142+ return matchDriverFlag ( " hyperv" )
143143}
144144
145145// KVM returns true is is KVM driver
146146func KVMDriver () bool {
147- return strings . Contains ( * startArgs , "--driver= kvm") || strings . Contains ( * startArgs , "--vm-driver=kvm" ) || strings . Contains ( * startArgs , "--driver=kvm2" ) || strings . Contains ( * startArgs , "--vm-driver= kvm2" )
147+ return matchDriverFlag ( " kvm" , "kvm2" )
148148}
149149
150150// VirtualboxDriver returns whether or not this test is using the VirtualBox driver
151151func VirtualboxDriver () bool {
152- return strings . Contains ( * startArgs , "--driver=virtualbox" ) || strings . Contains ( * startArgs , "--vm-driver= virtualbox" )
152+ return matchDriverFlag ( " virtualbox" )
153153}
154154
155155// DockerDriver returns whether or not this test is using the docker or podman driver
156156func DockerDriver () bool {
157- return strings . Contains ( * startArgs , "--driver=docker" ) || strings . Contains ( * startArgs , "--vm-driver= docker" )
157+ return matchDriverFlag ( " docker" )
158158}
159159
160160// PodmanDriver returns whether or not this test is using the docker or podman driver
161161func PodmanDriver () bool {
162- return strings . Contains ( * startArgs , "--driver=podman" ) || strings . Contains ( * startArgs , "--vm-driver= podman" )
162+ return matchDriverFlag ( " podman" )
163163}
164164
165165// RootlessDriver returns whether or not this test is using the rootless KIC driver
@@ -172,9 +172,13 @@ func KicDriver() bool {
172172 return DockerDriver () || PodmanDriver ()
173173}
174174
175+ func HyperkitDriver () bool {
176+ return matchDriverFlag ("hyperkit" )
177+ }
178+
175179// NeedsAuxDriver Returns true if the driver needs an auxiliary driver (kvm, hyperkit,..)
176180func NeedsAuxDriver () bool {
177- return HyperVDriver () || KVMDriver ()
181+ return HyperkitDriver () || KVMDriver ()
178182}
179183
180184// VMDriver checks if the driver is a VM
@@ -228,3 +232,15 @@ func Seconds(n int) time.Duration {
228232func TestingKicBaseImage () bool {
229233 return strings .Contains (* startArgs , "base-image" )
230234}
235+
236+ func matchDriverFlag (names ... string ) bool {
237+ args := * startArgs
238+ for _ , name := range names {
239+ for _ , prefix := range []string {"--driver=" , "--vm-driver=" } {
240+ if strings .Contains (args , prefix + name ) {
241+ return true
242+ }
243+ }
244+ }
245+ return false
246+ }
0 commit comments