mirror of https://github.com/dapr/cli.git
Show correct container runtime in init logging (#1250)
* Show correct container runtime in init logging Init logging now logs using container runtime specified by the user instead of always logging "Docker" Signed-off-by: Thorsten Hans <thorsten.hans@gmail.com> #1209 * tests: set test name in test data to remove fmt import Signed-off-by: Thorsten Hans <thorsten.hans@gmail.com> * remove usage of golang.org/x/text and log container runtime names as they are Signed-off-by: Thorsten Hans <thorsten.hans@gmail.com> * ensure modified files do not introduce linting errors Signed-off-by: Thorsten Hans <thorsten.hans@gmail.com> --------- Signed-off-by: Thorsten Hans <thorsten.hans@gmail.com> Co-authored-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com>
This commit is contained in:
parent
211e57b915
commit
06a4c6bddc
|
@ -164,7 +164,7 @@ func Init(runtimeVersion, dashboardVersion string, dockerNetwork string, slimMod
|
|||
// If --slim installation is not requested, check if docker is installed.
|
||||
conatinerRuntimeAvailable := utils.IsDockerInstalled() || utils.IsPodmanInstalled()
|
||||
if !conatinerRuntimeAvailable {
|
||||
return errors.New("could not connect to Docker. Docker may not be installed or running")
|
||||
return fmt.Errorf("could not connect to %s. %s may not be installed or running", containerRuntime, containerRuntime)
|
||||
}
|
||||
|
||||
// Initialize default registry only if any of --slim or --image-registry or --from-dir are not given.
|
||||
|
|
|
@ -18,6 +18,8 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/dapr/cli/utils"
|
||||
)
|
||||
|
||||
func TestStandaloneConfig(t *testing.T) {
|
||||
|
@ -310,3 +312,24 @@ func TestIsAirGapInit(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestInitLogActualContainerRuntimeName(t *testing.T) {
|
||||
tests := []struct {
|
||||
containerRuntime string
|
||||
testName string
|
||||
}{
|
||||
{"podman", "Init should log podman as container runtime"},
|
||||
{"docker", "Init should log docker as container runtime"},
|
||||
}
|
||||
conatinerRuntimeAvailable := utils.IsDockerInstalled() || utils.IsPodmanInstalled()
|
||||
if conatinerRuntimeAvailable {
|
||||
t.Skip("Skipping test as container runtime is available")
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.testName, func(t *testing.T) {
|
||||
err := Init(latestVersion, latestVersion, "", false, "", "", test.containerRuntime, "", "")
|
||||
assert.NotNil(t, err)
|
||||
assert.Contains(t, err.Error(), test.containerRuntime)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue