提交 73dd0068 编写于 作者: A Anders F Björklund

Replace string comparison with class method

上级 78806674
......@@ -209,7 +209,8 @@ func runStart(cmd *cobra.Command, args []string) {
selectedEnableDefaultCNI := viper.GetBool(enableDefaultCNI)
// default network plugin (cni)
if selectedContainerRuntime != "" {
r, err := cruntime.New(cruntime.Config{Type: selectedContainerRuntime})
if err == nil && r.DefaultCNI() {
if !cmd.Flags().Changed(networkPlugin) {
selectedNetworkPlugin = "cni"
if !cmd.Flags().Changed(enableDefaultCNI) {
......
......@@ -41,6 +41,11 @@ func (r *Containerd) SocketPath() string {
return "/run/containerd/containerd.sock"
}
// DefaultCNI returns whether to use CNI networking by default
func (r *Containerd) DefaultCNI() bool {
return true
}
// Active returns if containerd is active on the host
func (r *Containerd) Active() bool {
err := r.Runner.Run("systemctl is-active --quiet service containerd")
......
......@@ -41,6 +41,11 @@ func (r *CRIO) SocketPath() string {
return "/var/run/crio/crio.sock"
}
// DefaultCNI returns whether to use CNI networking by default
func (r *CRIO) DefaultCNI() bool {
return true
}
// Available returns an error if it is not possible to use this runtime on a host
func (r *CRIO) Available() error {
return r.Runner.Run("command -v crio")
......
......@@ -49,6 +49,8 @@ type Manager interface {
KubeletOptions() map[string]string
// SocketPath returns the path to the socket file for a given runtime
SocketPath() string
// DefaultCNI returns whether to use CNI networking by default
DefaultCNI() bool
// Load an image idempotently into the runtime on a host
LoadImage(string) error
......
......@@ -40,6 +40,11 @@ func (r *Docker) SocketPath() string {
return r.Socket
}
// DefaultCNI returns whether to use CNI networking by default
func (r *Docker) DefaultCNI() bool {
return false
}
// Available returns an error if it is not possible to use this runtime on a host
func (r *Docker) Available() error {
_, err := exec.LookPath("docker")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册