Skip to content

Commit 3de75ef

Browse files
committed
Allow file for config source to be specified explicitly
This change allows a "file" config source to also specify the source path of the file to process. This means that when configuring containerd with the option --config-source=file=/foo/bar.toml the file /foo/bar.toml will be used as the source config instead of the output config file. Signed-off-by: Evan Lezar <[email protected]>
1 parent 09da5c9 commit 3de75ef

File tree

1 file changed

+12
-2
lines changed
  • cmd/nvidia-ctk-installer/container/runtime/containerd

1 file changed

+12
-2
lines changed

cmd/nvidia-ctk-installer/container/runtime/containerd/containerd.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"encoding/json"
2121
"fmt"
2222
"path/filepath"
23+
"strings"
2324

2425
log "github.com/sirupsen/logrus"
2526
cli "github.com/urfave/cli/v3"
@@ -174,10 +175,19 @@ func GetLowlevelRuntimePaths(o *container.Options, co *Options) ([]string, error
174175
func getRuntimeConfig(o *container.Options, co *Options) (engine.Interface, error) {
175176
var loaders []toml.Loader
176177
for _, configSource := range o.ConfigSources {
177-
switch configSource {
178+
parts := strings.SplitN(configSource, "=", 2)
179+
source := parts[0]
180+
switch source {
178181
case "file":
179-
loaders = append(loaders, toml.FromFile(o.TopLevelConfigPath))
182+
fileSourcePath := o.TopLevelConfigPath
183+
if len(parts) > 1 {
184+
fileSourcePath = parts[1]
185+
}
186+
loaders = append(loaders, toml.FromFile(fileSourcePath))
180187
case "command":
188+
if len(parts) > 1 {
189+
log.Warnf("Ignoring additional command argument %q", parts[1])
190+
}
181191
loaders = append(loaders, containerd.CommandLineSource(o.HostRootMount, o.ExecutablePath))
182192
default:
183193
return nil, fmt.Errorf("unsupported config source %q", configSource)

0 commit comments

Comments
 (0)