debug: add env var flag K3D_DEBUG_DISABLE_DOCKER_INIT to test k3s as pid 1
This commit is contained in:
parent
d21882a01c
commit
81a41bdab1
@ -25,6 +25,8 @@ package docker
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/containerd/containerd/log"
|
||||
@ -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{}
|
||||
|
@ -23,6 +23,8 @@ THE SOFTWARE.
|
||||
package docker
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/go-test/deep"
|
||||
@ -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{
|
||||
|
Loading…
Reference in New Issue
Block a user