Skip to content

Commit

Permalink
refactor runtime version election
Browse files Browse the repository at this point in the history
  • Loading branch information
hellt committed Jun 16, 2021
1 parent 793cb48 commit 91bcd27
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions clab/clab.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,17 @@ func WithTimeout(dur time.Duration) ClabOption {

func WithRuntime(name string, d bool, dur time.Duration, gracefulShutdown bool) ClabOption {
return func(c *CLab) {
if name == "" {
name = os.Getenv("CLAB_RUNTIME")
if name == "" {
name = runtime.DockerRuntime
}
// define runtime name.
// order of preference: cli flag -> env var -> default value of docker
envN := os.Getenv("CLAB_RUNTIME")
switch {
case name != "":
case envN != "":
name = envN
default:
name = runtime.DockerRuntime
}

if rInit, ok := runtime.ContainerRuntimes[name]; ok {
c.Runtime = rInit()
err := c.Runtime.Init(
Expand Down

0 comments on commit 91bcd27

Please sign in to comment.