Merge pull request #4525 from afbjorklund/distro

Show info about the minikube linux distribution
pull/4850/head
Anders Björklund 2019-07-23 12:50:00 +02:00 committed by GitHub
commit e22b605e72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 1 deletions

View File

@ -20,6 +20,7 @@ import (
"encoding/json" "encoding/json"
"flag" "flag"
"fmt" "fmt"
"io/ioutil"
"math" "math"
"net" "net"
"os/exec" "os/exec"
@ -29,6 +30,7 @@ import (
"time" "time"
"github.com/docker/machine/libmachine" "github.com/docker/machine/libmachine"
"github.com/docker/machine/libmachine/drivers"
"github.com/docker/machine/libmachine/engine" "github.com/docker/machine/libmachine/engine"
"github.com/docker/machine/libmachine/host" "github.com/docker/machine/libmachine/host"
"github.com/docker/machine/libmachine/mcnerror" "github.com/docker/machine/libmachine/mcnerror"
@ -365,6 +367,40 @@ func getHostInfo() (*hostInfo, error) {
return &info, nil return &info, nil
} }
// showLocalOsRelease shows systemd information about the current linux distribution, on the local host
func showLocalOsRelease() {
osReleaseOut, err := ioutil.ReadFile("/etc/os-release")
if err != nil {
glog.Errorf("ReadFile: %v", err)
return
}
osReleaseInfo, err := provision.NewOsRelease(osReleaseOut)
if err != nil {
glog.Errorf("NewOsRelease: %v", err)
return
}
out.T(out.Provisioner, "OS release is {{.pretty_name}}", out.V{"pretty_name": osReleaseInfo.PrettyName})
}
// showRemoteOsRelease shows systemd information about the current linux distribution, on the remote VM
func showRemoteOsRelease(driver drivers.Driver) {
provisioner, err := provision.DetectProvisioner(driver)
if err != nil {
glog.Errorf("DetectProvisioner: %v", err)
return
}
osReleaseInfo, err := provisioner.GetOsReleaseInfo()
if err != nil {
glog.Errorf("GetOsReleaseInfo: %v", err)
return
}
out.T(out.Provisioner, "Provisioned with {{.pretty_name}}", out.V{"pretty_name": osReleaseInfo.PrettyName})
}
func createHost(api libmachine.API, config cfg.MachineConfig) (*host.Host, error) { func createHost(api libmachine.API, config cfg.MachineConfig) (*host.Host, error) {
if config.VMDriver == constants.DriverVmwareFusion && viper.GetBool(cfg.ShowDriverDeprecationNotification) { if config.VMDriver == constants.DriverVmwareFusion && viper.GetBool(cfg.ShowDriverDeprecationNotification) {
out.WarningT(`The vmwarefusion driver is deprecated and support for it will be removed in a future release. out.WarningT(`The vmwarefusion driver is deprecated and support for it will be removed in a future release.
@ -410,6 +446,12 @@ func createHost(api libmachine.API, config cfg.MachineConfig) (*host.Host, error
return nil, errors.Wrap(err, "create") return nil, errors.Wrap(err, "create")
} }
if !localDriver(config.VMDriver) {
showRemoteOsRelease(h.Driver)
} else {
showLocalOsRelease()
}
if err := api.Save(h); err != nil { if err := api.Save(h); err != nil {
return nil, errors.Wrap(err, "save") return nil, errors.Wrap(err, "save")
} }

View File

@ -87,6 +87,7 @@ var styles = map[StyleEnum]style{
Caching: {Prefix: "🤹 "}, Caching: {Prefix: "🤹 "},
StartingVM: {Prefix: "🔥 "}, StartingVM: {Prefix: "🔥 "},
StartingNone: {Prefix: "🤹 "}, StartingNone: {Prefix: "🤹 "},
Provisioner: {Prefix: " "},
Resetting: {Prefix: "🔄 "}, Resetting: {Prefix: "🔄 "},
DeletingHost: {Prefix: "🔥 "}, DeletingHost: {Prefix: "🔥 "},
Copying: {Prefix: "✨ "}, Copying: {Prefix: "✨ "},

View File

@ -56,6 +56,7 @@ const (
Caching Caching
StartingVM StartingVM
StartingNone StartingNone
Provisioner
Resetting Resetting
DeletingHost DeletingHost
Copying Copying

View File

@ -81,7 +81,7 @@ func (provisioner *MockProvisioner) SetOsReleaseInfo(info *provision.OsRelease)
// GetOsReleaseInfo gets the os-release info // GetOsReleaseInfo gets the os-release info
func (provisioner *MockProvisioner) GetOsReleaseInfo() (*provision.OsRelease, error) { func (provisioner *MockProvisioner) GetOsReleaseInfo() (*provision.OsRelease, error) {
return nil, nil return &provision.OsRelease{}, nil
} }
// AttemptIPContact attempts to contact an IP and port // AttemptIPContact attempts to contact an IP and port