Skip to content

Commit

Permalink
chore: fix dockerengine isContainerRunning for linux (#5670)
Browse files Browse the repository at this point in the history
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.
  • Loading branch information
iamhopaul123 authored Feb 12, 2024
1 parent 5ee9a70 commit f3b1576
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/pkg/docker/dockerengine/dockerengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ func (c DockerCmdClient) CheckDockerEngineRunning() error {
return ErrDockerCommandNotFound
}
buf := &bytes.Buffer{}
err := c.runner.Run("docker", []string{"info", "-f", "json"}, exec.Stdout(buf))
err := c.runner.Run("docker", []string{"info", "-f", "{{json .}}"}, exec.Stdout(buf))
if err != nil {
return fmt.Errorf("get docker info: %w", err)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/pkg/docker/dockerengine/dockerengine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,15 +425,15 @@ func TestDockerCommand_CheckDockerEngineRunning(t *testing.T) {
"error running docker info": {
setupMocks: func(controller *gomock.Controller) {
mockCmd = NewMockCmd(controller)
mockCmd.EXPECT().Run("docker", []string{"info", "-f", "json"}, gomock.Any()).Return(mockError)
mockCmd.EXPECT().Run("docker", []string{"info", "-f", "{{json .}}"}, gomock.Any()).Return(mockError)
},

wantedErr: fmt.Errorf("get docker info: some error"),
},
"return when docker engine is not started": {
setupMocks: func(controller *gomock.Controller) {
mockCmd = NewMockCmd(controller)
mockCmd.EXPECT().Run("docker", []string{"info", "-f", "json"}, gomock.Any()).
mockCmd.EXPECT().Run("docker", []string{"info", "-f", "{{json .}}"}, gomock.Any()).
Do(func(_ string, _ []string, opt exec.CmdOption) {
cmd := &osexec.Cmd{}
opt(cmd)
Expand All @@ -449,7 +449,7 @@ func TestDockerCommand_CheckDockerEngineRunning(t *testing.T) {
"success": {
setupMocks: func(controller *gomock.Controller) {
mockCmd = NewMockCmd(controller)
mockCmd.EXPECT().Run("docker", []string{"info", "-f", "json"}, gomock.Any()).
mockCmd.EXPECT().Run("docker", []string{"info", "-f", "{{json .}}"}, gomock.Any()).
Do(func(_ string, _ []string, opt exec.CmdOption) {
cmd := &osexec.Cmd{}
opt(cmd)
Expand Down

0 comments on commit f3b1576

Please sign in to comment.