Skip to content

Commit 37ca5d6

Browse files
committed
getEngineConfigFilePath is only used during test…
… so moving it in test files for now. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 08cf36d commit 37ca5d6

2 files changed

Lines changed: 30 additions & 30 deletions

File tree

internal/containerizedengine/engine.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"fmt"
66
"io"
7-
"strings"
87
"syscall"
98
"time"
109

@@ -89,35 +88,6 @@ func (c baseClient) getEngineImage(engine containerd.Container) (string, error)
8988
return image.Name(), nil
9089
}
9190

92-
// getEngineConfigFilePath will extract the config file location from the engine flags
93-
func (c baseClient) getEngineConfigFilePath(ctx context.Context, engine containerd.Container) (string, error) {
94-
spec, err := engine.Spec(ctx)
95-
configFile := ""
96-
if err != nil {
97-
return configFile, err
98-
}
99-
for i := 0; i < len(spec.Process.Args); i++ {
100-
arg := spec.Process.Args[i]
101-
if strings.HasPrefix(arg, "--config-file") {
102-
if strings.Contains(arg, "=") {
103-
split := strings.SplitN(arg, "=", 2)
104-
configFile = split[1]
105-
} else {
106-
if i+1 >= len(spec.Process.Args) {
107-
return configFile, ErrMalformedConfigFileParam
108-
}
109-
configFile = spec.Process.Args[i+1]
110-
}
111-
}
112-
}
113-
114-
if configFile == "" {
115-
// TODO - any more diagnostics to offer?
116-
return configFile, ErrEngineConfigLookupFailure
117-
}
118-
return configFile, nil
119-
}
120-
12191
var (
12292
engineWaitInterval = 500 * time.Millisecond
12393
engineWaitTimeout = 60 * time.Second

internal/containerizedengine/engine_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package containerizedengine
33
import (
44
"context"
55
"fmt"
6+
"strings"
67
"syscall"
78
"testing"
89
"time"
@@ -535,3 +536,32 @@ func TestGetEngineConfigFilePathMalformed1(t *testing.T) {
535536
_, err := client.getEngineConfigFilePath(ctx, container)
536537
assert.Assert(t, err == ErrMalformedConfigFileParam)
537538
}
539+
540+
// getEngineConfigFilePath will extract the config file location from the engine flags
541+
func (c baseClient) getEngineConfigFilePath(ctx context.Context, engine containerd.Container) (string, error) {
542+
spec, err := engine.Spec(ctx)
543+
configFile := ""
544+
if err != nil {
545+
return configFile, err
546+
}
547+
for i := 0; i < len(spec.Process.Args); i++ {
548+
arg := spec.Process.Args[i]
549+
if strings.HasPrefix(arg, "--config-file") {
550+
if strings.Contains(arg, "=") {
551+
split := strings.SplitN(arg, "=", 2)
552+
configFile = split[1]
553+
} else {
554+
if i+1 >= len(spec.Process.Args) {
555+
return configFile, ErrMalformedConfigFileParam
556+
}
557+
configFile = spec.Process.Args[i+1]
558+
}
559+
}
560+
}
561+
562+
if configFile == "" {
563+
// TODO - any more diagnostics to offer?
564+
return configFile, ErrEngineConfigLookupFailure
565+
}
566+
return configFile, nil
567+
}

0 commit comments

Comments
 (0)