Skip to content

Commit

Permalink
Add EnableCDI() method to engine.Interface
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Desiniotis <[email protected]>
  • Loading branch information
cdesiniotis committed Dec 18, 2024
1 parent aac0a62 commit 94ef5f6
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/config/engine/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Interface interface {
RemoveRuntime(string) error
Save(string) (int64, error)
GetRuntimeConfig(string) (RuntimeConfig, error)
EnableCDI()
}

// RuntimeConfig defines the interface to query container runtime handler configuration
Expand Down
4 changes: 4 additions & 0 deletions pkg/config/engine/containerd/config_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,7 @@ func (c *ConfigV1) GetRuntimeConfig(name string) (engine.RuntimeConfig, error) {
tree: runtimeData,
}, nil
}

func (c *ConfigV1) EnableCDI() {
c.Set("enable_cdi", true)
}
4 changes: 4 additions & 0 deletions pkg/config/engine/containerd/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ func (c *Config) GetRuntimeConfig(name string) (engine.RuntimeConfig, error) {
}, nil
}

func (c *Config) EnableCDI() {
c.Set("enable_cdi", true)
}

// CommandLineSource returns the CLI-based containerd config loader
func CommandLineSource(hostRoot string) toml.Loader {
return toml.FromCommandLine(chrootIfRequired(hostRoot, "containerd", "config", "dump")...)
Expand Down
5 changes: 5 additions & 0 deletions pkg/config/engine/crio/crio.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ func (c *Config) GetRuntimeConfig(name string) (engine.RuntimeConfig, error) {
}, nil
}

func (c *Config) EnableCDI() {
// no-op since CDI is always enabled in versions where CDI is supported
return
}

// CommandLineSource returns the CLI-based crio config loader
func CommandLineSource(hostRoot string) toml.Loader {
return toml.LoadFirst(
Expand Down
4 changes: 4 additions & 0 deletions pkg/config/engine/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,7 @@ func (c *Config) GetRuntimeConfig(name string) (engine.RuntimeConfig, error) {
}
return &dockerRuntime{}, nil
}

func (c *Config) EnableCDI() {
c.Set("features", map[string]bool{"cdi": true})
}

0 comments on commit 94ef5f6

Please sign in to comment.