Add nvidia-ctk cdi transform root command

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar
2023-03-28 12:18:32 +02:00
committed by Christopher Desiniotis
parent 7f5c9abc1e
commit 6a83e2ebe5
4 changed files with 248 additions and 1 deletions

View File

@@ -41,6 +41,13 @@ func newBuilder(opts ...Option) *builder {
for _, opt := range opts {
opt(s)
}
if s.raw != nil {
s.noSimplify = true
vendor, class := cdi.ParseQualifier(s.raw.Kind)
s.vendor = vendor
s.class = class
}
if s.version == "" {
s.version = DetectMinimumVersion
}
@@ -60,7 +67,6 @@ func newBuilder(opts ...Option) *builder {
// Build builds a CDI spec form the spec builder.
func (o *builder) Build() (*spec, error) {
raw := o.raw
if raw == nil {
raw = &specs.Spec{
Version: o.version,
@@ -144,3 +150,10 @@ func WithNoSimplify(noSimplify bool) Option {
o.noSimplify = noSimplify
}
}
// WithRawSpec sets the raw spec for the spec builder
func WithRawSpec(raw *specs.Spec) Option {
return func(o *builder) {
o.raw = raw
}
}