From 37ca5d681372c5af4a2442de512643ad827b13e9 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Wed, 22 Aug 2018 15:32:32 +0200 Subject: [PATCH] =?UTF-8?q?getEngineConfigFilePath=20is=20only=20used=20du?= =?UTF-8?q?ring=20test=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … so moving it in test files for now. Signed-off-by: Vincent Demeester --- internal/containerizedengine/engine.go | 30 --------------------- internal/containerizedengine/engine_test.go | 30 +++++++++++++++++++++ 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/internal/containerizedengine/engine.go b/internal/containerizedengine/engine.go index 0b6f04690a..fb8d8d8474 100644 --- a/internal/containerizedengine/engine.go +++ b/internal/containerizedengine/engine.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "io" - "strings" "syscall" "time" @@ -89,35 +88,6 @@ func (c baseClient) getEngineImage(engine containerd.Container) (string, error) return image.Name(), nil } -// getEngineConfigFilePath will extract the config file location from the engine flags -func (c baseClient) getEngineConfigFilePath(ctx context.Context, engine containerd.Container) (string, error) { - spec, err := engine.Spec(ctx) - configFile := "" - if err != nil { - return configFile, err - } - for i := 0; i < len(spec.Process.Args); i++ { - arg := spec.Process.Args[i] - if strings.HasPrefix(arg, "--config-file") { - if strings.Contains(arg, "=") { - split := strings.SplitN(arg, "=", 2) - configFile = split[1] - } else { - if i+1 >= len(spec.Process.Args) { - return configFile, ErrMalformedConfigFileParam - } - configFile = spec.Process.Args[i+1] - } - } - } - - if configFile == "" { - // TODO - any more diagnostics to offer? - return configFile, ErrEngineConfigLookupFailure - } - return configFile, nil -} - var ( engineWaitInterval = 500 * time.Millisecond engineWaitTimeout = 60 * time.Second diff --git a/internal/containerizedengine/engine_test.go b/internal/containerizedengine/engine_test.go index 8e6a8d2147..0e7d4da23d 100644 --- a/internal/containerizedengine/engine_test.go +++ b/internal/containerizedengine/engine_test.go @@ -3,6 +3,7 @@ package containerizedengine import ( "context" "fmt" + "strings" "syscall" "testing" "time" @@ -535,3 +536,32 @@ func TestGetEngineConfigFilePathMalformed1(t *testing.T) { _, err := client.getEngineConfigFilePath(ctx, container) assert.Assert(t, err == ErrMalformedConfigFileParam) } + +// getEngineConfigFilePath will extract the config file location from the engine flags +func (c baseClient) getEngineConfigFilePath(ctx context.Context, engine containerd.Container) (string, error) { + spec, err := engine.Spec(ctx) + configFile := "" + if err != nil { + return configFile, err + } + for i := 0; i < len(spec.Process.Args); i++ { + arg := spec.Process.Args[i] + if strings.HasPrefix(arg, "--config-file") { + if strings.Contains(arg, "=") { + split := strings.SplitN(arg, "=", 2) + configFile = split[1] + } else { + if i+1 >= len(spec.Process.Args) { + return configFile, ErrMalformedConfigFileParam + } + configFile = spec.Process.Args[i+1] + } + } + } + + if configFile == "" { + // TODO - any more diagnostics to offer? + return configFile, ErrEngineConfigLookupFailure + } + return configFile, nil +}