Skip to content

Commit

Permalink
debug: add env var flag K3D_DEBUG_DISABLE_DOCKER_INIT to test k3s as …
Browse files Browse the repository at this point in the history
…pid 1
  • Loading branch information
iwilltry42 committed Oct 1, 2021
1 parent d21882a commit 81a41bd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/runtimes/docker/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ package docker
import (
"context"
"fmt"
"os"
"strconv"
"strings"

"github.com/containerd/containerd/log"
Expand All @@ -44,10 +46,16 @@ import (

// TranslateNodeToContainer translates a k3d node specification to a docker container representation
func TranslateNodeToContainer(node *k3d.Node) (*NodeInDocker, error) {
init := true
if disableInit, err := strconv.ParseBool(os.Getenv("K3D_DEBUG_DISABLE_DOCKER_INIT")); err == nil && disableInit {
l.Log().Traceln("docker-init disabled for all containers")
init = false
}

/* initialize everything that we need */
containerConfig := docker.Config{}
hostConfig := docker.HostConfig{
Init: &[]bool{true}[0],
Init: &init,
ExtraHosts: node.ExtraHosts,
}
networkingConfig := network.NetworkingConfig{}
Expand Down
5 changes: 5 additions & 0 deletions pkg/runtimes/docker/translate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ THE SOFTWARE.
package docker

import (
"os"
"strconv"
"testing"

"github.com/go-test/deep"
Expand Down Expand Up @@ -58,6 +60,9 @@ func TestTranslateNodeToContainer(t *testing.T) {
}

init := true
if disableInit, err := strconv.ParseBool(os.Getenv("K3D_DEBUG_DISABLE_DOCKER_INIT")); err == nil && disableInit {
init = false
}

expectedRepresentation := &NodeInDocker{
ContainerConfig: container.Config{
Expand Down

0 comments on commit 81a41bd

Please sign in to comment.