Skip to content

Commit

Permalink
Replace string comparison with class method
Browse files Browse the repository at this point in the history
  • Loading branch information
afbjorklund committed Feb 9, 2019
1 parent 7880667 commit 7ca4ad8
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions pkg/minikube/cruntime/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
5 changes: 5 additions & 0 deletions pkg/minikube/cruntime/crio.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions pkg/minikube/cruntime/cruntime.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions pkg/minikube/cruntime/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 7ca4ad8

Please sign in to comment.