-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for containerd v3 configs #805
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,18 +70,20 @@ func (c *ConfigV1) AddRuntime(name string, path string, setAsDefault bool) error | |
config.SetPath([]string{"plugins", "cri", "containerd", "runtimes", name, "options", "BinaryName"}, path) | ||
config.SetPath([]string{"plugins", "cri", "containerd", "runtimes", name, "options", "Runtime"}, path) | ||
|
||
if setAsDefault && c.UseDefaultRuntimeName { | ||
config.SetPath([]string{"plugins", "cri", "containerd", "default_runtime_name"}, name) | ||
} else if setAsDefault { | ||
// Note: This is deprecated in containerd 1.4.0 and will be removed in 1.5.0 | ||
if config.GetPath([]string{"plugins", "cri", "containerd", "default_runtime"}) == nil { | ||
config.SetPath([]string{"plugins", "cri", "containerd", "default_runtime", "runtime_type"}, c.RuntimeType) | ||
config.SetPath([]string{"plugins", "cri", "containerd", "default_runtime", "runtime_root"}, "") | ||
config.SetPath([]string{"plugins", "cri", "containerd", "default_runtime", "runtime_engine"}, "") | ||
config.SetPath([]string{"plugins", "cri", "containerd", "default_runtime", "privileged_without_host_devices"}, false) | ||
if setAsDefault { | ||
if !c.UseLegacyConfig { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we invert the if-else block here? It would look more readable if we avoid the NOT statement when possible There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. inverted it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tariq1890 I kept the ordering of the blocks the same to reduce the diff against |
||
config.SetPath([]string{"plugins", "cri", "containerd", "default_runtime_name"}, name) | ||
} else { | ||
// Note: This is deprecated in containerd 1.4.0 and will be removed in 1.5.0 | ||
if config.GetPath([]string{"plugins", "cri", "containerd", "default_runtime"}) == nil { | ||
config.SetPath([]string{"plugins", "cri", "containerd", "default_runtime", "runtime_type"}, c.RuntimeType) | ||
config.SetPath([]string{"plugins", "cri", "containerd", "default_runtime", "runtime_root"}, "") | ||
config.SetPath([]string{"plugins", "cri", "containerd", "default_runtime", "runtime_engine"}, "") | ||
config.SetPath([]string{"plugins", "cri", "containerd", "default_runtime", "privileged_without_host_devices"}, false) | ||
} | ||
config.SetPath([]string{"plugins", "cri", "containerd", "default_runtime", "options", "BinaryName"}, path) | ||
config.SetPath([]string{"plugins", "cri", "containerd", "default_runtime", "options", "Runtime"}, path) | ||
} | ||
config.SetPath([]string{"plugins", "cri", "containerd", "default_runtime", "options", "BinaryName"}, path) | ||
config.SetPath([]string{"plugins", "cri", "containerd", "default_runtime", "options", "Runtime"}, path) | ||
} | ||
|
||
*c.Tree = config | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that we are only using this in unit tests, do we really need to add a new interface method for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry @tariq1890, I missed this. I will have a look again and see if we can clean up the interface as a follow-up.
The issue is that the
New
function that we call in tests returns an interface type and adding aString()
function was simpler than adding type casts. Let me see what the latter looks like.