Refactor Toml config handling

This change refactors the toml config file handlig for runtimes
such as containerd or crio. A toml.Loader is introduced that
encapsulates loading the required file.

This can be extended to allow other mechanisms for loading
loading the current config.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar
2024-08-08 16:27:07 +02:00
parent 6c5f4eea63
commit bf2bdfd35e
20 changed files with 428 additions and 229 deletions

View File

@@ -21,6 +21,7 @@ import (
"fmt"
"github.com/NVIDIA/nvidia-container-toolkit/internal/logger"
"github.com/NVIDIA/nvidia-container-toolkit/pkg/config"
"github.com/NVIDIA/nvidia-container-toolkit/pkg/config/engine"
)
@@ -128,6 +129,6 @@ func (c Config) Save(path string) (int64, error) {
return 0, fmt.Errorf("unable to convert to JSON: %v", err)
}
n, err := engine.Config(path).Write(output)
n, err := config.Raw(path).Write(output)
return int64(n), err
}