Add helper for checking the generic driver name

pull/10099/head
Anders F Björklund 2020-11-14 09:36:49 +01:00
parent a0d2c1a0c5
commit a3b3b55ac0
7 changed files with 13 additions and 8 deletions

View File

@ -309,7 +309,7 @@ func deleteProfile(profile *config.Profile) error {
return DeletionError{Err: delErr, Errtype: MissingProfile}
}
if err == nil && (driver.BareMetal(cc.Driver) || cc.Driver == driver.Generic) {
if err == nil && (driver.BareMetal(cc.Driver) || driver.IsGeneric(cc.Driver)) {
if err := uninstallKubernetes(api, *cc, cc.Nodes[0], viper.GetString(cmdcfg.Bootstrapper)); err != nil {
deletionError, ok := err.(DeletionError)
if ok {

View File

@ -306,7 +306,7 @@ func provisionWithDriver(cmd *cobra.Command, ds registry.DriverState, existing *
os.Exit(0)
}
if driver.IsVM(driverName) && driverName != driver.Generic {
if driver.IsVM(driverName) && !driver.IsGeneric(driverName) {
url, err := download.ISO(viper.GetStringSlice(isoURL), cmd.Flags().Changed(isoURL))
if err != nil {
return node.Starter{}, errors.Wrap(err, "Failed to cache ISO")

View File

@ -99,7 +99,7 @@ func MachineType(name string) string {
return "container"
}
if name == Generic {
if IsGeneric(name) {
return "bare metal machine"
}
@ -150,6 +150,11 @@ func BareMetal(name string) bool {
return name == None || name == Mock
}
// IsGeneric checks if the driver is generic
func IsGeneric(name string) bool {
return name == Generic
}
// NeedsPortForward returns true if driver is unable provide direct IP connectivity
func NeedsPortForward(name string) bool {
if !IsKIC(name) {

View File

@ -129,7 +129,7 @@ func recreateIfNeeded(api libmachine.API, cc *config.ClusterConfig, n *config.No
}
}
if h.Driver.DriverName() == driver.Generic {
if driver.IsGeneric(h.Driver.DriverName()) {
if s == state.Running {
out.Step(style.Running, `Using the {{.driver_name}} "{{.cluster}}" {{.machine_type}} ...`, out.V{"driver_name": cc.Driver, "cluster": cc.Name, "machine_type": machineType})
} else {

View File

@ -104,7 +104,7 @@ func fastDetectProvisioner(h *host.Host) (libprovision.Provisioner, error) {
switch {
case driver.IsKIC(d):
return provision.NewUbuntuProvisioner(h.Driver), nil
case driver.BareMetal(d), d == driver.Generic:
case driver.BareMetal(d), driver.IsGeneric(d):
return libprovision.DetectProvisioner(h.Driver)
default:
return provision.NewBuildrootProvisioner(h.Driver), nil

View File

@ -168,7 +168,7 @@ func createHost(api libmachine.API, cfg *config.ClusterConfig, n *config.Node) (
return h, errors.Wrap(err, "post-start")
}
if h.Driver.DriverName() == driver.Generic {
if driver.IsGeneric(h.Driver.DriverName()) {
if _, err := h.RunSSHCommand(fmt.Sprintf("sudo usermod -aG docker %s", h.Driver.GetSSHUsername())); err != nil {
return h, errors.Wrap(err, "usermod")
}
@ -289,7 +289,7 @@ func postStartSetup(h *host.Host, mc config.ClusterConfig) error {
if driver.BareMetal(mc.Driver) {
showLocalOsRelease()
}
if driver.IsVM(mc.Driver) || driver.IsKIC(mc.Driver) || mc.Driver == driver.Generic {
if driver.IsVM(mc.Driver) || driver.IsKIC(mc.Driver) || driver.IsGeneric(mc.Driver) {
logRemoteOsRelease(r)
}
return syncLocalAssets(r)

View File

@ -55,7 +55,7 @@ func stop(h *host.Host) error {
}
}
if h.DriverName == driver.Generic {
if driver.IsGeneric(h.DriverName) {
return nil
}