Skip to content

Commit 7ca4ad8

Browse files
committed
Replace string comparison with class method
1 parent 7880667 commit 7ca4ad8

File tree

5 files changed

+19
-1
lines changed

5 files changed

+19
-1
lines changed

Diff for: cmd/minikube/cmd/start.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ func runStart(cmd *cobra.Command, args []string) {
209209
selectedEnableDefaultCNI := viper.GetBool(enableDefaultCNI)
210210

211211
// default network plugin (cni)
212-
if selectedContainerRuntime != "" {
212+
r, err := cruntime.New(cruntime.Config{Type: selectedContainerRuntime})
213+
if err == nil && r.DefaultCNI() {
213214
if !cmd.Flags().Changed(networkPlugin) {
214215
selectedNetworkPlugin = "cni"
215216
if !cmd.Flags().Changed(enableDefaultCNI) {

Diff for: pkg/minikube/cruntime/containerd.go

+5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ func (r *Containerd) SocketPath() string {
4141
return "/run/containerd/containerd.sock"
4242
}
4343

44+
// DefaultCNI returns whether to use CNI networking by default
45+
func (r *Containerd) DefaultCNI() bool {
46+
return true
47+
}
48+
4449
// Active returns if containerd is active on the host
4550
func (r *Containerd) Active() bool {
4651
err := r.Runner.Run("systemctl is-active --quiet service containerd")

Diff for: pkg/minikube/cruntime/crio.go

+5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ func (r *CRIO) SocketPath() string {
4141
return "/var/run/crio/crio.sock"
4242
}
4343

44+
// DefaultCNI returns whether to use CNI networking by default
45+
func (r *CRIO) DefaultCNI() bool {
46+
return true
47+
}
48+
4449
// Available returns an error if it is not possible to use this runtime on a host
4550
func (r *CRIO) Available() error {
4651
return r.Runner.Run("command -v crio")

Diff for: pkg/minikube/cruntime/cruntime.go

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ type Manager interface {
4949
KubeletOptions() map[string]string
5050
// SocketPath returns the path to the socket file for a given runtime
5151
SocketPath() string
52+
// DefaultCNI returns whether to use CNI networking by default
53+
DefaultCNI() bool
5254

5355
// Load an image idempotently into the runtime on a host
5456
LoadImage(string) error

Diff for: pkg/minikube/cruntime/docker.go

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ func (r *Docker) SocketPath() string {
4040
return r.Socket
4141
}
4242

43+
// DefaultCNI returns whether to use CNI networking by default
44+
func (r *Docker) DefaultCNI() bool {
45+
return false
46+
}
47+
4348
// Available returns an error if it is not possible to use this runtime on a host
4449
func (r *Docker) Available() error {
4550
_, err := exec.LookPath("docker")

0 commit comments

Comments
 (0)