@@ -30,40 +30,40 @@ func (c *Config) AddRuntime(name string, path string, setAsDefault bool) error {
3030 }
3131 config := * c .Tree
3232
33- config .Set ("version" , int64 ( 2 ) )
33+ config .Set ("version" , c . Version )
3434
3535 runtimeNamesForConfig := engine .GetLowLevelRuntimes (c )
3636 for _ , r := range runtimeNamesForConfig {
37- options := config .GetSubtreeByPath ([]string {"plugins" , "io.containerd.grpc.v1.cri" , "containerd" , "runtimes" , r })
37+ options := config .GetSubtreeByPath ([]string {"plugins" , c . CRIRuntimePluginName , "containerd" , "runtimes" , r })
3838 if options == nil {
3939 continue
4040 }
4141 c .Logger .Debugf ("using options from runtime %v: %v" , r , options )
42- config .SetPath ([]string {"plugins" , "io.containerd.grpc.v1.cri" , "containerd" , "runtimes" , name }, options .Copy ())
42+ config .SetPath ([]string {"plugins" , c . CRIRuntimePluginName , "containerd" , "runtimes" , name }, options .Copy ())
4343 break
4444 }
4545
46- if config .GetPath ([]string {"plugins" , "io.containerd.grpc.v1.cri" , "containerd" , "runtimes" , name }) == nil {
46+ if config .GetPath ([]string {"plugins" , c . CRIRuntimePluginName , "containerd" , "runtimes" , name }) == nil {
4747 c .Logger .Warningf ("could not infer options from runtimes %v; using defaults" , runtimeNamesForConfig )
48- config .SetPath ([]string {"plugins" , "io.containerd.grpc.v1.cri" , "containerd" , "runtimes" , name , "runtime_type" }, c .RuntimeType )
49- config .SetPath ([]string {"plugins" , "io.containerd.grpc.v1.cri" , "containerd" , "runtimes" , name , "runtime_root" }, "" )
50- config .SetPath ([]string {"plugins" , "io.containerd.grpc.v1.cri" , "containerd" , "runtimes" , name , "runtime_engine" }, "" )
51- config .SetPath ([]string {"plugins" , "io.containerd.grpc.v1.cri" , "containerd" , "runtimes" , name , "privileged_without_host_devices" }, false )
48+ config .SetPath ([]string {"plugins" , c . CRIRuntimePluginName , "containerd" , "runtimes" , name , "runtime_type" }, c .RuntimeType )
49+ config .SetPath ([]string {"plugins" , c . CRIRuntimePluginName , "containerd" , "runtimes" , name , "runtime_root" }, "" )
50+ config .SetPath ([]string {"plugins" , c . CRIRuntimePluginName , "containerd" , "runtimes" , name , "runtime_engine" }, "" )
51+ config .SetPath ([]string {"plugins" , c . CRIRuntimePluginName , "containerd" , "runtimes" , name , "privileged_without_host_devices" }, false )
5252 }
5353
5454 if len (c .ContainerAnnotations ) > 0 {
55- annotations , err := c .getRuntimeAnnotations ([]string {"plugins" , "io.containerd.grpc.v1.cri" , "containerd" , "runtimes" , name , "container_annotations" })
55+ annotations , err := c .getRuntimeAnnotations ([]string {"plugins" , c . CRIRuntimePluginName , "containerd" , "runtimes" , name , "container_annotations" })
5656 if err != nil {
5757 return err
5858 }
5959 annotations = append (c .ContainerAnnotations , annotations ... )
60- config .SetPath ([]string {"plugins" , "io.containerd.grpc.v1.cri" , "containerd" , "runtimes" , name , "container_annotations" }, annotations )
60+ config .SetPath ([]string {"plugins" , c . CRIRuntimePluginName , "containerd" , "runtimes" , name , "container_annotations" }, annotations )
6161 }
6262
63- config .SetPath ([]string {"plugins" , "io.containerd.grpc.v1.cri" , "containerd" , "runtimes" , name , "options" , "BinaryName" }, path )
63+ config .SetPath ([]string {"plugins" , c . CRIRuntimePluginName , "containerd" , "runtimes" , name , "options" , "BinaryName" }, path )
6464
6565 if setAsDefault {
66- config .SetPath ([]string {"plugins" , "io.containerd.grpc.v1.cri" , "containerd" , "default_runtime_name" }, name )
66+ config .SetPath ([]string {"plugins" , c . CRIRuntimePluginName , "containerd" , "default_runtime_name" }, name )
6767 }
6868
6969 * c .Tree = config
@@ -99,13 +99,13 @@ func (c *Config) getRuntimeAnnotations(path []string) ([]string, error) {
9999// Set sets the specified containerd option.
100100func (c * Config ) Set (key string , value interface {}) {
101101 config := * c .Tree
102- config .SetPath ([]string {"plugins" , "io.containerd.grpc.v1.cri" , key }, value )
102+ config .SetPath ([]string {"plugins" , c . CRIRuntimePluginName , key }, value )
103103 * c .Tree = config
104104}
105105
106106// DefaultRuntime returns the default runtime for the cri-o config
107107func (c Config ) DefaultRuntime () string {
108- if runtime , ok := c .GetPath ([]string {"plugins" , "io.containerd.grpc.v1.cri" , "containerd" , "default_runtime_name" }).(string ); ok {
108+ if runtime , ok := c .GetPath ([]string {"plugins" , c . CRIRuntimePluginName , "containerd" , "default_runtime_name" }).(string ); ok {
109109 return runtime
110110 }
111111 return ""
@@ -119,14 +119,14 @@ func (c *Config) RemoveRuntime(name string) error {
119119
120120 config := * c .Tree
121121
122- config .DeletePath ([]string {"plugins" , "io.containerd.grpc.v1.cri" , "containerd" , "runtimes" , name })
123- if runtime , ok := config .GetPath ([]string {"plugins" , "io.containerd.grpc.v1.cri" , "containerd" , "default_runtime_name" }).(string ); ok {
122+ config .DeletePath ([]string {"plugins" , c . CRIRuntimePluginName , "containerd" , "runtimes" , name })
123+ if runtime , ok := config .GetPath ([]string {"plugins" , c . CRIRuntimePluginName , "containerd" , "default_runtime_name" }).(string ); ok {
124124 if runtime == name {
125- config .DeletePath ([]string {"plugins" , "io.containerd.grpc.v1.cri" , "containerd" , "default_runtime_name" })
125+ config .DeletePath ([]string {"plugins" , c . CRIRuntimePluginName , "containerd" , "default_runtime_name" })
126126 }
127127 }
128128
129- runtimePath := []string {"plugins" , "io.containerd.grpc.v1.cri" , "containerd" , "runtimes" , name }
129+ runtimePath := []string {"plugins" , c . CRIRuntimePluginName , "containerd" , "runtimes" , name }
130130 for i := 0 ; i < len (runtimePath ); i ++ {
131131 if runtimes , ok := config .GetPath (runtimePath [:len (runtimePath )- i ]).(* toml.Tree ); ok {
132132 if len (runtimes .Keys ()) == 0 {
0 commit comments