Skip to content

Commit 8afbb32

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 <elezar@nvidia.com>
1 parent 9aca232 commit 8afbb32

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"
@@ -178,10 +179,19 @@ func getRuntimeConfig(o *container.Options, co *Options) (engine.Interface, erro
178179

179180
var loaders []toml.Loader
180181
for _, configSource := range o.ConfigSources {
181-
switch configSource {
182+
parts := strings.SplitN(configSource, "=", 2)
183+
source := parts[0]
184+
switch source {
182185
case "file":
183-
loaders = append(loaders, toml.FromFile(o.TopLevelConfigPath))
186+
fileSourcePath := o.TopLevelConfigPath
187+
if len(parts) > 1 {
188+
fileSourcePath = parts[1]
189+
}
190+
loaders = append(loaders, toml.FromFile(fileSourcePath))
184191
case "command":
192+
if len(parts) > 1 {
193+
log.Warnf("Ignoring additional command argument %q", parts[1])
194+
}
185195
loaders = append(loaders, containerd.CommandLineSource(o.HostRootMount, o.ExecutablePath))
186196
default:
187197
return nil, fmt.Errorf("unsupported config source %q", configSource)

0 commit comments

Comments
 (0)