Skip to content

Commit ce7cea3

Browse files
committed
Remove Set from engine config API
Signed-off-by: Evan Lezar <[email protected]>
1 parent 1bc9548 commit ce7cea3

File tree

4 files changed

+7
-23
lines changed

4 files changed

+7
-23
lines changed

pkg/config/engine/api.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ type Interface interface {
2424
GetRuntimeConfig(string) (RuntimeConfig, error)
2525
RemoveRuntime(string) error
2626
Save(string) (int64, error)
27-
Set(string, interface{})
2827
String() string
2928
}
3029

pkg/config/engine/containerd/config.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,6 @@ func (c *Config) getRuntimeAnnotations(path []string) ([]string, error) {
9696
return annotations, nil
9797
}
9898

99-
// Set sets the specified containerd option.
100-
func (c *Config) Set(key string, value interface{}) {
101-
config := *c.Tree
102-
config.SetPath([]string{"plugins", c.CRIRuntimePluginName, key}, value)
103-
*c.Tree = config
104-
}
105-
10699
// DefaultRuntime returns the default runtime for the cri-o config
107100
func (c Config) DefaultRuntime() string {
108101
if runtime, ok := c.GetPath([]string{"plugins", c.CRIRuntimePluginName, "containerd", "default_runtime_name"}).(string); ok {
@@ -113,7 +106,9 @@ func (c Config) DefaultRuntime() string {
113106

114107
// EnableCDI sets the enable_cdi field in the Containerd config to true.
115108
func (c *Config) EnableCDI() {
116-
c.Set("enable_cdi", true)
109+
config := *c.Tree
110+
config.SetPath([]string{"plugins", c.CRIRuntimePluginName, "enable_cdi"}, true)
111+
*c.Tree = config
117112
}
118113

119114
// RemoveRuntime removes a runtime from the docker config

pkg/config/engine/containerd/config_v1.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,6 @@ func (c *ConfigV1) RemoveRuntime(name string) error {
143143
return nil
144144
}
145145

146-
// Set sets the specified containerd option.
147-
func (c *ConfigV1) Set(key string, value interface{}) {
148-
config := *c.Tree
149-
config.SetPath([]string{"plugins", "cri", "containerd", key}, value)
150-
*c.Tree = config
151-
}
152-
153146
// Save writes the config to a file
154147
func (c ConfigV1) Save(path string) (int64, error) {
155148
return (Config)(c).Save(path)
@@ -167,5 +160,7 @@ func (c *ConfigV1) GetRuntimeConfig(name string) (engine.RuntimeConfig, error) {
167160
}
168161

169162
func (c *ConfigV1) EnableCDI() {
170-
c.Set("enable_cdi", true)
163+
config := *c.Tree
164+
config.SetPath([]string{"plugins", "cri", "containerd", "enable_cdi"}, true)
165+
*c.Tree = config
171166
}

pkg/config/engine/docker/docker.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func (c Config) DefaultRuntime() string {
105105

106106
// EnableCDI sets features.cdi to true in the docker config.
107107
func (c *Config) EnableCDI() {
108-
c.Set("features", map[string]bool{"cdi": true})
108+
(*c)["features"] = map[string]bool{"cdi": true}
109109
}
110110

111111
// RemoveRuntime removes a runtime from the docker config
@@ -137,11 +137,6 @@ func (c *Config) RemoveRuntime(name string) error {
137137
return nil
138138
}
139139

140-
// Set sets the specified docker option
141-
func (c *Config) Set(key string, value interface{}) {
142-
(*c)[key] = value
143-
}
144-
145140
// Save writes the config to the specified path
146141
func (c Config) Save(path string) (int64, error) {
147142
output, err := json.MarshalIndent(c, "", " ")

0 commit comments

Comments
 (0)