mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2025-02-04 03:56:23 +00:00
95bda3ad72
This change adds support for containerd configs with version=3. From the perspective of the runtime configuration the contents of the config are the same. This means that we just have to load the new version and ensure that this is propagated to the generated config. Note that v3 config also requires a switch to the 'io.containerd.cri.v1.runtime' CRI runtime plugin. See: https://github.com/containerd/containerd/blob/v2.0.0/docs/PLUGINS.md https://github.com/containerd/containerd/issues/10132 Note that we still use a default config of version=2 since we need to ensure compatibility with older containerd versions (1.6.x and 1.7.x). Signed-off-by: Sam Lockart <sam.lockart@zendesk.com> Signed-off-by: Evan Lezar <elezar@nvidia.com> Signed-off-by: Christopher Desiniotis <cdesiniotis@nvidia.com>
85 lines
2.3 KiB
Go
85 lines
2.3 KiB
Go
/**
|
|
# Copyright (c) NVIDIA CORPORATION. All rights reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
**/
|
|
|
|
package containerd
|
|
|
|
import (
|
|
"github.com/NVIDIA/nvidia-container-toolkit/internal/logger"
|
|
"github.com/NVIDIA/nvidia-container-toolkit/pkg/config/toml"
|
|
)
|
|
|
|
type builder struct {
|
|
logger logger.Interface
|
|
configSource toml.Loader
|
|
configVersion int
|
|
useLegacyConfig bool
|
|
path string
|
|
runtimeType string
|
|
containerAnnotations []string
|
|
}
|
|
|
|
// Option defines a function that can be used to configure the config builder
|
|
type Option func(*builder)
|
|
|
|
// WithLogger sets the logger for the config builder
|
|
func WithLogger(logger logger.Interface) Option {
|
|
return func(b *builder) {
|
|
b.logger = logger
|
|
}
|
|
}
|
|
|
|
// WithPath sets the path for the config builder
|
|
func WithPath(path string) Option {
|
|
return func(b *builder) {
|
|
b.path = path
|
|
}
|
|
}
|
|
|
|
// WithConfigSource sets the source for the config.
|
|
func WithConfigSource(configSource toml.Loader) Option {
|
|
return func(b *builder) {
|
|
b.configSource = configSource
|
|
}
|
|
}
|
|
|
|
// WithRuntimeType sets the runtime type for the config builder
|
|
func WithRuntimeType(runtimeType string) Option {
|
|
return func(b *builder) {
|
|
b.runtimeType = runtimeType
|
|
}
|
|
}
|
|
|
|
// WithUseLegacyConfig sets the useLegacyConfig flag for the config builder.
|
|
func WithUseLegacyConfig(useLegacyConfig bool) Option {
|
|
return func(b *builder) {
|
|
b.useLegacyConfig = useLegacyConfig
|
|
}
|
|
}
|
|
|
|
// WithConfigVersion sets the config version for the config builder
|
|
func WithConfigVersion(configVersion int) Option {
|
|
return func(b *builder) {
|
|
b.configVersion = configVersion
|
|
}
|
|
}
|
|
|
|
// WithContainerAnnotations sets the container annotations for the config builder
|
|
func WithContainerAnnotations(containerAnnotations ...string) Option {
|
|
return func(b *builder) {
|
|
b.containerAnnotations = containerAnnotations
|
|
}
|
|
}
|