diff --git a/cli/container.go b/cli/container.go index f499c5e0..64bb0d67 100644 --- a/cli/container.go +++ b/cli/container.go @@ -152,8 +152,10 @@ func createServer(spec *ClusterSpec) (string, error) { } // copy the registry configuration - if err := writeRegistriesConfigInContainer(spec, id); err != nil { - return "", err + if spec.RegistryEnabled { + if err := writeRegistriesConfigInContainer(spec, id); err != nil { + return "", err + } } if err := startContainer(id); err != nil { @@ -248,8 +250,10 @@ func createWorker(spec *ClusterSpec, postfix int) (string, error) { } // copy the registry configuration - if err := writeRegistriesConfigInContainer(spec, id); err != nil { - return "", err + if spec.RegistryEnabled { + if err := writeRegistriesConfigInContainer(spec, id); err != nil { + return "", err + } } if err := startContainer(id); err != nil { diff --git a/tests/01-basic.sh b/tests/01-basic.sh index c296b064..71597806 100755 --- a/tests/01-basic.sh +++ b/tests/01-basic.sh @@ -8,8 +8,15 @@ source "$CURR_DIR/common.sh" ######################################################################################### +FIXTURES_DIR=$CURR_DIR/fixtures + +# a dummy registries.yaml file +REGISTRIES_YAML=$FIXTURES_DIR/01-registries-empty.yaml + +######################################################################################### + info "Creating two clusters..." -$EXE create --wait 60 --name "c1" --api-port 6443 || failed "could not create cluster c1" +$EXE create --wait 60 --name "c1" --api-port 6443 -v $REGISTRIES_YAML:/etc/rancher/k3s/registries.yaml || failed "could not create cluster c1" $EXE create --wait 60 --name "c2" --api-port 6444 || failed "could not create cluster c2" info "Checking we have access to both clusters..." diff --git a/tests/common.sh b/tests/common.sh index fc726144..b536cdbb 100755 --- a/tests/common.sh +++ b/tests/common.sh @@ -58,12 +58,14 @@ check_url() { } check_k3d_clusters() { + [ -n "$EXE" ] || abort "EXE is not defined" for c in "c1" "c2" ; do kc=$($EXE get-kubeconfig --name "$c") - if kubectl --kubeconfig=$kc cluster-info ; then - passed "cluster $c is reachable" + [ -n "$kc" ] || abort "could not obtain a kubeconfig for $c" + if kubectl --kubeconfig="$kc" cluster-info ; then + passed "cluster $c is reachable (with kubeconfig=$kc)" else - warn "could not obtain cluster info for $c with kubeconfig=$kc. Contents:\n$(cat $kc)" + warn "could not obtain cluster info for $c (with kubeconfig=$kc). Contents:\n$(cat $kc)" return 1 fi done diff --git a/tests/fixtures/01-registries-empty.yaml b/tests/fixtures/01-registries-empty.yaml new file mode 100644 index 00000000..d39ac5dd --- /dev/null +++ b/tests/fixtures/01-registries-empty.yaml @@ -0,0 +1,4 @@ +mirrors: + "dummy.local": + endpoint: + - http://localhost:32000