2023-02-23 20:01:24 +00:00
|
|
|
/**
|
|
|
|
# Copyright (c) 2022, 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 (
|
2023-12-01 01:10:10 +00:00
|
|
|
"github.com/pelletier/go-toml"
|
|
|
|
|
2023-05-26 08:15:27 +00:00
|
|
|
"github.com/NVIDIA/nvidia-container-toolkit/internal/logger"
|
2023-04-24 11:58:03 +00:00
|
|
|
"github.com/NVIDIA/nvidia-container-toolkit/pkg/config/engine"
|
2023-02-23 20:01:24 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Config represents the containerd config
|
|
|
|
type Config struct {
|
|
|
|
*toml.Tree
|
2024-07-02 08:26:41 +00:00
|
|
|
Logger logger.Interface
|
2023-02-23 20:01:24 +00:00
|
|
|
RuntimeType string
|
|
|
|
UseDefaultRuntimeName bool
|
2023-03-23 19:12:23 +00:00
|
|
|
ContainerAnnotations []string
|
2023-02-23 20:01:24 +00:00
|
|
|
}
|
|
|
|
|
2023-12-01 23:59:34 +00:00
|
|
|
var _ engine.Interface = (*Config)(nil)
|
|
|
|
|
2023-02-23 20:01:24 +00:00
|
|
|
// New creates a containerd config with the specified options
|
|
|
|
func New(opts ...Option) (engine.Interface, error) {
|
|
|
|
b := &builder{}
|
|
|
|
for _, opt := range opts {
|
|
|
|
opt(b)
|
|
|
|
}
|
|
|
|
|
2023-05-26 08:15:27 +00:00
|
|
|
if b.logger == nil {
|
|
|
|
b.logger = logger.New()
|
|
|
|
}
|
|
|
|
|
2023-02-23 20:01:24 +00:00
|
|
|
return b.build()
|
|
|
|
}
|