diff --git a/cmd/minikube/cmd/completion.go b/cmd/minikube/cmd/completion.go index 14b10e74ae..c4588f89a9 100644 --- a/cmd/minikube/cmd/completion.go +++ b/cmd/minikube/cmd/completion.go @@ -103,7 +103,7 @@ func GenerateBashCompletion(w io.Writer, cmd *cobra.Command) error { } func GenerateZshCompletion(out io.Writer, cmd *cobra.Command) error { - zsh_initialization := `#compdef minikube + zshInitialization := `#compdef minikube __minikube_bash_source() { alias shopt=':' @@ -242,7 +242,7 @@ __minikube_convert_bash_to_zsh() { return err } - _, err = out.Write([]byte(zsh_initialization)) + _, err = out.Write([]byte(zshInitialization)) if err != nil { return err } @@ -257,12 +257,12 @@ __minikube_convert_bash_to_zsh() { return err } - zsh_tail := ` + zshTail := ` BASH_COMPLETION_EOF } __minikube_bash_source <(__minikube_convert_bash_to_zsh) ` - _, err = out.Write([]byte(zsh_tail)) + _, err = out.Write([]byte(zshTail)) if err != nil { return err } diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 271e9ead78..17ce2c08a8 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -103,7 +103,7 @@ func init() { startCmd.Flags().Bool(createMount, false, "This will start the mount daemon and automatically mount files into minikube") startCmd.Flags().String(mountString, constants.DefaultMountDir+":"+constants.DefaultMountEndpoint, "The argument to pass the minikube mount command on start") startCmd.Flags().Bool(disableDriverMounts, false, "Disables the filesystem mounts provided by the hypervisors (vboxfs, xhyve-9p)") - startCmd.Flags().String(isoURL, constants.DefaultIsoUrl, "Location of the minikube iso") + startCmd.Flags().String(isoURL, constants.DefaultISOURL, "Location of the minikube iso") startCmd.Flags().String(vmDriver, constants.DefaultVMDriver, fmt.Sprintf("VM driver is one of: %v", constants.SupportedVMDrivers)) startCmd.Flags().Int(memory, constants.DefaultMemory, "Amount of RAM allocated to the minikube VM in MB") startCmd.Flags().Int(cpus, constants.DefaultCPUS, "Number of CPUs allocated to the minikube VM") @@ -163,14 +163,14 @@ func runStart(cmd *cobra.Command, args []string) { if err != nil && !os.IsNotExist(err) { exit.WithCode(exit.Data, "Unable to load config: %v", err) } - kVersion := validateKubernetesVersions(oldConfig) - config, err := generateConfig(cmd, kVersion) + k8sVersion := validateKubernetesVersions(oldConfig) + config, err := generateConfig(cmd, k8sVersion) if err != nil { exit.WithError("Failed to generate config", err) } var cacheGroup errgroup.Group - beginCacheImages(&cacheGroup, kVersion) + beginCacheImages(&cacheGroup, k8sVersion) // Abstraction leakage alert: startHost requires the config to be saved, to satistfy pkg/provision/buildroot. // Hence, saveConfig must be called before startHost, and again afterwards when we know the IP. @@ -233,18 +233,18 @@ func validateConfig() { } // beginCacheImages caches Docker images in the background -func beginCacheImages(g *errgroup.Group, kVersion string) { +func beginCacheImages(g *errgroup.Group, k8sVersion string) { if !viper.GetBool(cacheImages) { return } console.OutStyle("caching", "Caching images in the background ...") g.Go(func() error { - return machine.CacheImagesForBootstrapper(kVersion, viper.GetString(cmdcfg.Bootstrapper)) + return machine.CacheImagesForBootstrapper(k8sVersion, viper.GetString(cmdcfg.Bootstrapper)) }) } // generateConfig generates cfg.Config based on flags and supplied arguments -func generateConfig(cmd *cobra.Command, kVersion string) (cfg.Config, error) { +func generateConfig(cmd *cobra.Command, k8sVersion string) (cfg.Config, error) { r, err := cruntime.New(cruntime.Config{Type: viper.GetString(containerRuntime)}) if err != nil { return cfg.Config{}, err @@ -287,7 +287,7 @@ func generateConfig(cmd *cobra.Command, kVersion string) (cfg.Config, error) { NoVTXCheck: viper.GetBool(noVTXCheck), }, KubernetesConfig: cfg.KubernetesConfig{ - KubernetesVersion: kVersion, + KubernetesVersion: k8sVersion, NodePort: viper.GetInt(apiServerPort), NodeName: constants.DefaultNodeName, APIServerName: viper.GetString(apiServerName), @@ -519,7 +519,7 @@ func bootstrapCluster(bs bootstrapper.Bootstrapper, r cruntime.Manager, runner b // validateCluster validates that the cluster is well-configured and healthy func validateCluster(bs bootstrapper.Bootstrapper, r cruntime.Manager, runner bootstrapper.CommandRunner, ip string) { console.OutStyle("verifying-noline", "Verifying component health ...") - kStat := func() (err error) { + k8sStat := func() (err error) { st, err := bs.GetKubeletStatus() console.Out(".") if err != nil || st != state.Running.String() { @@ -527,12 +527,12 @@ func validateCluster(bs bootstrapper.Bootstrapper, r cruntime.Manager, runner bo } return nil } - err := pkgutil.RetryAfter(20, kStat, 3*time.Second) + err := pkgutil.RetryAfter(20, k8sStat, 3*time.Second) if err != nil { exit.WithProblems("kubelet checks failed", err, logs.FindProblems(r, bs, runner)) } aStat := func() (err error) { - st, err := bs.GetApiServerStatus(net.ParseIP(ip)) + st, err := bs.GetAPIServerStatus(net.ParseIP(ip)) console.Out(".") if err != nil || st != state.Running.String() { return &pkgutil.RetriableError{Err: fmt.Errorf("apiserver status=%s err=%v", st, err)} diff --git a/cmd/minikube/cmd/status.go b/cmd/minikube/cmd/status.go index e6ea1af9d3..34f63da2c7 100644 --- a/cmd/minikube/cmd/status.go +++ b/cmd/minikube/cmd/status.go @@ -39,7 +39,7 @@ var statusFormat string type Status struct { Host string Kubelet string - ApiServer string + APIServer string Kubeconfig string } @@ -91,7 +91,7 @@ var statusCmd = &cobra.Command{ glog.Errorln("Error host driver ip status:", err) } - apiserverSt, err = clusterBootstrapper.GetApiServerStatus(ip) + apiserverSt, err = clusterBootstrapper.GetAPIServerStatus(ip) if err != nil { glog.Errorln("Error apiserver status:", err) } else if apiserverSt != state.Running.String() { @@ -116,7 +116,7 @@ var statusCmd = &cobra.Command{ status := Status{ Host: hostSt, Kubelet: kubeletSt, - ApiServer: apiserverSt, + APIServer: apiserverSt, Kubeconfig: kubeconfigSt, } tmpl, err := template.New("status").Parse(statusFormat) diff --git a/cmd/util/util.go b/cmd/util/util.go index 28105e7272..d0a7b02357 100644 --- a/cmd/util/util.go +++ b/cmd/util/util.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// package util is a hodge-podge of utility functions that should be moved elsewhere. +// Package util is a hodge-podge of utility functions that should be moved elsewhere. package util import ( @@ -28,7 +28,7 @@ import ( "k8s.io/minikube/pkg/minikube/constants" ) -// Ask the kernel for a free open port that is ready to use +// GetPort asks the kernel for a free open port that is ready to use func GetPort() (string, error) { addr, err := net.ResolveTCPAddr("tcp", "localhost:0") if err != nil { diff --git a/deploy/minikube/release_sanity_test.go b/deploy/minikube/release_sanity_test.go index 7aedbabaf7..38cc2f907f 100644 --- a/deploy/minikube/release_sanity_test.go +++ b/deploy/minikube/release_sanity_test.go @@ -31,7 +31,7 @@ import ( "k8s.io/minikube/pkg/util" ) -func getShaFromURL(url string) (string, error) { +func getSHAFromURL(url string) (string, error) { fmt.Println("Downloading: ", url) r, err := http.Get(url) if err != nil { @@ -57,7 +57,7 @@ func TestReleasesJson(t *testing.T) { fmt.Printf("Checking release: %s\n", r.Name) for platform, sha := range r.Checksums { fmt.Printf("Checking SHA for %s.\n", platform) - actualSha, err := getShaFromURL(util.GetBinaryDownloadURL(r.Name, platform)) + actualSha, err := getSHAFromURL(util.GetBinaryDownloadURL(r.Name, platform)) if err != nil { t.Errorf("Error calculating SHA for %s-%s. Error: %v", r.Name, platform, err) continue diff --git a/pkg/drivers/drivers.go b/pkg/drivers/drivers.go index 639d30b436..b299160622 100644 --- a/pkg/drivers/drivers.go +++ b/pkg/drivers/drivers.go @@ -36,12 +36,12 @@ func GetDiskPath(d *drivers.BaseDriver) string { type CommonDriver struct{} -//Not implemented yet +// GetCreateFlags is not implemented yet func (d *CommonDriver) GetCreateFlags() []mcnflag.Flag { return nil } -//Not implemented yet +// SetConfigFromFlags is not implemented yet func (d *CommonDriver) SetConfigFromFlags(flags drivers.DriverOptions) error { return nil } diff --git a/pkg/drivers/kvm/gpu.go b/pkg/drivers/kvm/gpu.go index bdd84e4dd3..4132bb56a2 100644 --- a/pkg/drivers/kvm/gpu.go +++ b/pkg/drivers/kvm/gpu.go @@ -31,7 +31,7 @@ import ( var sysFsPCIDevicesPath = "/sys/bus/pci/devices/" var sysKernelIOMMUGroupsPath = "/sys/kernel/iommu_groups/" -const nvidiaVendorId = "0x10de" +const nvidiaVendorID = "0x10de" const devicesTmpl = ` @@ -127,8 +127,8 @@ func getPassthroughableNVIDIADevices() ([]string, error) { } // Check if this is an NVIDIA device - if strings.EqualFold(strings.TrimSpace(string(content)), nvidiaVendorId) { - log.Infof("Found device %v with NVIDIA's vendorId %v", device.Name(), nvidiaVendorId) + if strings.EqualFold(strings.TrimSpace(string(content)), nvidiaVendorID) { + log.Infof("Found device %v with NVIDIA's vendorId %v", device.Name(), nvidiaVendorID) found = true // Check whether it's unbound. We don't want the device to be bound to nvidia/nouveau etc. @@ -195,14 +195,12 @@ func isUnbound(device string) bool { if os.IsNotExist(err) { log.Infof("%v is not bound to any driver", device) return true - } else { - module := filepath.Base(modulePath) - if module == "pci_stub" || module == "vfio_pci" { - log.Infof("%v is bound to a stub module: %v", device, module) - return true - } else { - log.Infof("%v is bound to a non-stub module: %v", device, module) - return false - } } + module := filepath.Base(modulePath) + if module == "pci_stub" || module == "vfio_pci" { + log.Infof("%v is bound to a stub module: %v", device, module) + return true + } + log.Infof("%v is bound to a non-stub module: %v", device, module) + return false } diff --git a/pkg/drivers/kvm/kvm.go b/pkg/drivers/kvm/kvm.go index 735e6d169b..36191255ea 100644 --- a/pkg/drivers/kvm/kvm.go +++ b/pkg/drivers/kvm/kvm.go @@ -91,7 +91,7 @@ func NewDriver(hostName, storePath string) *Driver { SSHUser: "docker", }, CommonDriver: &pkgdrivers.CommonDriver{}, - Boot2DockerURL: constants.DefaultIsoUrl, + Boot2DockerURL: constants.DefaultISOURL, CPU: constants.DefaultCPUS, DiskSize: util.CalculateDiskSizeInMB(constants.DefaultDiskSize), Memory: constants.DefaultMemory, diff --git a/pkg/drivers/none/none.go b/pkg/drivers/none/none.go index 716a2eb126..0f5f286380 100644 --- a/pkg/drivers/none/none.go +++ b/pkg/drivers/none/none.go @@ -39,7 +39,7 @@ var cleanupPaths = []string{ "/var/lib/minikube", } -// none Driver is a driver designed to run kubeadm w/o VM management, and assumes systemctl. +// Driver is a driver designed to run kubeadm w/o VM management, and assumes systemctl. // https://github.com/kubernetes/minikube/blob/master/docs/vmdriver-none.md type Driver struct { *drivers.BaseDriver diff --git a/pkg/minikube/bootstrapper/bootstrapper.go b/pkg/minikube/bootstrapper/bootstrapper.go index 4140f58548..948808afc8 100644 --- a/pkg/minikube/bootstrapper/bootstrapper.go +++ b/pkg/minikube/bootstrapper/bootstrapper.go @@ -43,7 +43,7 @@ type Bootstrapper interface { LogCommands(LogOptions) map[string]string SetupCerts(cfg config.KubernetesConfig) error GetKubeletStatus() (string, error) - GetApiServerStatus(net.IP) (string, error) + GetAPIServerStatus(net.IP) (string, error) } const ( diff --git a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go index f0cf072739..9e50a3aabc 100644 --- a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go +++ b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go @@ -120,7 +120,7 @@ func (k *KubeadmBootstrapper) GetKubeletStatus() (string, error) { return state.Error.String(), nil } -func (k *KubeadmBootstrapper) GetApiServerStatus(ip net.IP) (string, error) { +func (k *KubeadmBootstrapper) GetAPIServerStatus(ip net.IP) (string, error) { url := fmt.Sprintf("https://%s:%d/healthz", ip, util.APIServerPort) // To avoid: x509: certificate signed by unknown authority tr := &http.Transport{ @@ -543,7 +543,7 @@ func maybeDownloadAndCache(binary, version string) (string, error) { Mkdirs: download.MkdirAll, } - options.Checksum = constants.GetKubernetesReleaseURLSha1(binary, version) + options.Checksum = constants.GetKubernetesReleaseURLSHA1(binary, version) options.ChecksumHash = crypto.SHA1 console.OutStyle("file-download", "Downloading %s %s", binary, version) diff --git a/pkg/minikube/cluster/cluster_test.go b/pkg/minikube/cluster/cluster_test.go index b3ce791294..b9d96274f6 100644 --- a/pkg/minikube/cluster/cluster_test.go +++ b/pkg/minikube/cluster/cluster_test.go @@ -37,7 +37,7 @@ func (d MockDownloader) CacheMinikubeISOFromURL(isoURL string) error { return ni var defaultMachineConfig = config.MachineConfig{ VMDriver: constants.DefaultVMDriver, - MinikubeISO: constants.DefaultIsoUrl, + MinikubeISO: constants.DefaultISOURL, Downloader: MockDownloader{}, } diff --git a/pkg/minikube/cluster/default_drivers.go b/pkg/minikube/cluster/default_drivers.go index e37e385561..e45a101449 100644 --- a/pkg/minikube/cluster/default_drivers.go +++ b/pkg/minikube/cluster/default_drivers.go @@ -17,6 +17,7 @@ limitations under the License. package cluster import ( + // Import all the default drivers _ "k8s.io/minikube/pkg/minikube/drivers/hyperkit" _ "k8s.io/minikube/pkg/minikube/drivers/hyperv" _ "k8s.io/minikube/pkg/minikube/drivers/kvm" diff --git a/pkg/minikube/constants/constants.go b/pkg/minikube/constants/constants.go index 2fa11c50c7..f86b1eafe4 100644 --- a/pkg/minikube/constants/constants.go +++ b/pkg/minikube/constants/constants.go @@ -39,7 +39,7 @@ const ( const MinikubeHome = "MINIKUBE_HOME" -// Minipath is the path to the user's minikube dir +// GetMinipath returns the path to the user's minikube dir func GetMinipath() string { if os.Getenv(MinikubeHome) == "" { return DefaultMinipath @@ -85,10 +85,10 @@ const DefaultMachineName = "minikube" // DefaultNodeName is the default name for the kubeadm node within the VM const DefaultNodeName = "minikube" -// The name of the default storage class provisioner +// DefaultStorageClassProvisioner is the name of the default storage class provisioner const DefaultStorageClassProvisioner = "standard" -// Used to modify the cache field in the config file +// Cache is used to modify the cache field in the config file const Cache = "cache" func TunnelRegistryPath() string { @@ -106,7 +106,7 @@ var MountProcessFileName = ".mount-process" const ( DefaultKeepContext = false - ShaSuffix = ".sha256" + SHASuffix = ".sha256" DefaultMemory = 2048 DefaultCPUS = 2 DefaultDiskSize = "20g" @@ -127,8 +127,8 @@ kubectl: {{.Kubeconfig}} DefaultClusterBootstrapper = "kubeadm" ) -var DefaultIsoUrl = fmt.Sprintf("https://storage.googleapis.com/%s/minikube-%s.iso", minikubeVersion.GetIsoPath(), minikubeVersion.GetIsoVersion()) -var DefaultIsoShaUrl = DefaultIsoUrl + ShaSuffix +var DefaultISOURL = fmt.Sprintf("https://storage.googleapis.com/%s/minikube-%s.iso", minikubeVersion.GetISOPath(), minikubeVersion.GetISOVersion()) +var DefaultISOSHAURL = DefaultISOURL + SHASuffix var DefaultKubernetesVersion = "v1.13.3" @@ -168,7 +168,7 @@ func GetKubernetesReleaseURL(binaryName, version string) string { return fmt.Sprintf("https://storage.googleapis.com/kubernetes-release/release/%s/bin/linux/%s/%s", version, runtime.GOARCH, binaryName) } -func GetKubernetesReleaseURLSha1(binaryName, version string) string { +func GetKubernetesReleaseURLSHA1(binaryName, version string) string { return fmt.Sprintf("%s.sha1", GetKubernetesReleaseURL(binaryName, version)) } @@ -185,7 +185,7 @@ func GetKubeadmCachedImages(kubernetesVersionStr string) []string { "k8s.gcr.io/kube-apiserver-amd64:" + kubernetesVersionStr, } - ge_v1_13 := semver.MustParseRange(">=1.13.0") + v1_13 := semver.MustParseRange(">=1.13.0") v1_12 := semver.MustParseRange(">=1.12.0 <1.13.0") v1_11 := semver.MustParseRange(">=1.11.0 <1.12.0") v1_10 := semver.MustParseRange(">=1.10.0 <1.11.0") @@ -197,7 +197,7 @@ func GetKubeadmCachedImages(kubernetesVersionStr string) []string { glog.Errorln("Error parsing version semver: ", err) } - if ge_v1_13(kubernetesVersion) { + if v1_13(kubernetesVersion) { images = append(images, []string{ "k8s.gcr.io/pause-amd64:3.1", "k8s.gcr.io/pause:3.1", diff --git a/pkg/minikube/logs/logs.go b/pkg/minikube/logs/logs.go index 4f833eaa43..9a23fa110f 100644 --- a/pkg/minikube/logs/logs.go +++ b/pkg/minikube/logs/logs.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// package logs are convenience methods for fetching logs from a minikube cluster +// Package logs are convenience methods for fetching logs from a minikube cluster package logs import ( diff --git a/pkg/minikube/notify/notify.go b/pkg/minikube/notify/notify.go index 1e59916f71..4cd2810c56 100644 --- a/pkg/minikube/notify/notify.go +++ b/pkg/minikube/notify/notify.go @@ -87,7 +87,7 @@ type Release struct { type Releases []Release -func getJson(url string, target *Releases) error { +func getJSON(url string, target *Releases) error { client := &http.Client{} req, err := http.NewRequest("GET", url, nil) @@ -119,7 +119,7 @@ func getLatestVersionFromURL(url string) (semver.Version, error) { func GetAllVersionsFromURL(url string) (Releases, error) { var releases Releases glog.Info("Checking for updates...") - if err := getJson(url, &releases); err != nil { + if err := getJSON(url, &releases); err != nil { return releases, errors.Wrap(err, "Error getting json from minikube version url") } if len(releases) == 0 { diff --git a/pkg/minikube/service/service.go b/pkg/minikube/service/service.go index 12e6d4a028..ff628097c3 100644 --- a/pkg/minikube/service/service.go +++ b/pkg/minikube/service/service.go @@ -95,7 +95,7 @@ type URL struct { type URLs []URL -// Returns all the node port URLs for every service in a particular namespace +// GetServiceURLs returns all the node port URLs for every service in a particular namespace // Accepts a template for formatting func GetServiceURLs(api libmachine.API, namespace string, t *template.Template) (URLs, error) { host, err := cluster.CheckIfHostExistsAndLoad(api, config.GetMachineName()) @@ -132,7 +132,7 @@ func GetServiceURLs(api libmachine.API, namespace string, t *template.Template) return serviceURLs, nil } -// Returns all the node ports for a service in a namespace +// GetServiceURLsForService returns all the node ports for a service in a namespace // with optional formatting func GetServiceURLsForService(api libmachine.API, namespace, service string, t *template.Template) ([]string, error) { host, err := cluster.CheckIfHostExistsAndLoad(api, config.GetMachineName()) diff --git a/pkg/minikube/tests/driver_mock.go b/pkg/minikube/tests/driver_mock.go index 6ffe72bfda..ba3d700628 100644 --- a/pkg/minikube/tests/driver_mock.go +++ b/pkg/minikube/tests/driver_mock.go @@ -66,7 +66,7 @@ func (driver *MockDriver) GetSSHHostname() (string, error) { return "localhost", nil } -// GetSSHHostname returns the hostname for SSH +// GetSSHKeyPath returns the key path for SSH func (driver *MockDriver) GetSSHKeyPath() string { return driver.BaseDriver.SSHKeyPath } diff --git a/pkg/minikube/tests/fake_store.go b/pkg/minikube/tests/fake_store.go index f8226da787..922d4c9848 100644 --- a/pkg/minikube/tests/fake_store.go +++ b/pkg/minikube/tests/fake_store.go @@ -21,7 +21,7 @@ import ( "github.com/docker/machine/libmachine/mcnerror" ) -//implements persist.Store from libmachine +// FakeStore implements persist.Store from libmachine type FakeStore struct { Hosts map[string]*host.Host } diff --git a/pkg/minikube/tests/provision_mock.go b/pkg/minikube/tests/provision_mock.go index 0ba4506d33..c6a6e7b53b 100644 --- a/pkg/minikube/tests/provision_mock.go +++ b/pkg/minikube/tests/provision_mock.go @@ -26,7 +26,7 @@ import ( "github.com/docker/machine/libmachine/swarm" ) -// Provisioner defines distribution specific actions +// MockProvisioner defines distribution specific actions type MockProvisioner struct { Provisioned bool } diff --git a/pkg/minikube/tunnel/registry.go b/pkg/minikube/tunnel/registry.go index e4ccde963b..44122fdce7 100644 --- a/pkg/minikube/tunnel/registry.go +++ b/pkg/minikube/tunnel/registry.go @@ -28,6 +28,7 @@ import ( // There is one tunnel registry per user, shared across multiple vms. // It can register, list and check for existing and running tunnels + type ID struct { //Route is the key Route *Route diff --git a/pkg/minikube/tunnel/types.go b/pkg/minikube/tunnel/types.go index a8540782e8..4e566185f5 100644 --- a/pkg/minikube/tunnel/types.go +++ b/pkg/minikube/tunnel/types.go @@ -82,7 +82,7 @@ type Patch struct { BodyContent string } -// State represents the status of a host +// HostState represents the status of a host type HostState int const ( diff --git a/pkg/storage/storage_provisioner.go b/pkg/storage/storage_provisioner.go index e669377fa0..0f5a900348 100644 --- a/pkg/storage/storage_provisioner.go +++ b/pkg/storage/storage_provisioner.go @@ -110,7 +110,7 @@ func (p *hostPathProvisioner) Delete(volume *v1.PersistentVolume) error { return nil } -// Start storage provisioner server +// StartStorageProvisioner will start storage provisioner server func StartStorageProvisioner() error { glog.Infof("Initializing the Minikube storage provisioner...") config, err := restclient.InClusterConfig() diff --git a/pkg/util/config.go b/pkg/util/config.go index fc62d9d4a4..ea7fbeee7a 100644 --- a/pkg/util/config.go +++ b/pkg/util/config.go @@ -60,7 +60,7 @@ func setElement(e reflect.Value, v string) error { case net.IP: ip := net.ParseIP(v) if ip == nil { - return fmt.Errorf("Error converting input %s to an IP.", v) + return fmt.Errorf("Error converting input %s to an IP", v) } e.Set(reflect.ValueOf(ip)) case net.IPNet: @@ -99,7 +99,7 @@ func setElement(e reflect.Value, v string) error { case reflect.Bool: return convertBool(e, v) default: - return fmt.Errorf("Unable to set type %T.", e.Kind()) + return fmt.Errorf("Unable to set type %T", e.Kind()) } } diff --git a/pkg/util/crypto.go b/pkg/util/crypto.go index 65263efc88..73f863a548 100644 --- a/pkg/util/crypto.go +++ b/pkg/util/crypto.go @@ -60,6 +60,7 @@ func GenerateCACert(certPath, keyPath string, name string) error { // The certificate will be created with file mode 0644. The key will be created with file mode 0600. // If the certificate or key files already exist, they will be overwritten. // Any parent directories of the certPath or keyPath will be created as needed with file mode 0755. + func GenerateSignedCert(certPath, keyPath, cn string, ips []net.IP, alternateDNS []string, signerCertPath, signerKeyPath string) error { signerCertBytes, err := ioutil.ReadFile(signerCertPath) if err != nil { @@ -67,7 +68,7 @@ func GenerateSignedCert(certPath, keyPath, cn string, ips []net.IP, alternateDNS } decodedSignerCert, _ := pem.Decode(signerCertBytes) if decodedSignerCert == nil { - return errors.New("Unable to decode certificate.") + return errors.New("Unable to decode certificate") } signerCert, err := x509.ParseCertificate(decodedSignerCert.Bytes) if err != nil { @@ -79,7 +80,7 @@ func GenerateSignedCert(certPath, keyPath, cn string, ips []net.IP, alternateDNS } decodedSignerKey, _ := pem.Decode(signerKeyBytes) if decodedSignerKey == nil { - return errors.New("Unable to decode key.") + return errors.New("Unable to decode key") } signerKey, err := x509.ParsePKCS1PrivateKey(decodedSignerKey.Bytes) if err != nil { diff --git a/pkg/util/downloader.go b/pkg/util/downloader.go index d6f09e8eb0..2a2e745925 100644 --- a/pkg/util/downloader.go +++ b/pkg/util/downloader.go @@ -67,8 +67,8 @@ func (f DefaultDownloader) CacheMinikubeISOFromURL(isoURL string) error { } // Validate the ISO if it was the default URL, before writing it to disk. - if isoURL == constants.DefaultIsoUrl { - options.Checksum = constants.DefaultIsoShaUrl + if isoURL == constants.DefaultISOURL { + options.Checksum = constants.DefaultISOSHAURL options.ChecksumHash = crypto.SHA256 } diff --git a/pkg/util/utils.go b/pkg/util/utils.go index 10fbc62fb0..7f3b6e60d2 100644 --- a/pkg/util/utils.go +++ b/pkg/util/utils.go @@ -82,8 +82,8 @@ func Pad(str string) string { return fmt.Sprintf("\n%s\n", str) } -// If the file represented by path exists and -// readable, return true otherwise return false. +// CanReadFile returns true if the file represented +// by path exists and is readable, otherwise false. func CanReadFile(path string) bool { f, err := os.Open(path) if err != nil { diff --git a/pkg/util/utils_test.go b/pkg/util/utils_test.go index f1027a7e4c..f7d1c7c372 100644 --- a/pkg/util/utils_test.go +++ b/pkg/util/utils_test.go @@ -34,13 +34,12 @@ func errorGenerator(n int, retryable bool) func() error { errorCount := 0 return func() (err error) { if errorCount < n { - errorCount += 1 - e := errors.New("Error!") + errorCount++ + e := errors.New("Error") if retryable { return &RetriableError{Err: e} - } else { - return e } + return e } diff --git a/pkg/version/version.go b/pkg/version/version.go index c64e8e33df..289ad17613 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -22,12 +22,14 @@ import ( "github.com/blang/semver" ) -// The current version of the minikube -// This is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/version.version=vX.Y.Z" const VersionPrefix = "v" +// The current version of the minikube + +// version is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/version.version=vX.Y.Z" var version = "v0.0.0-unset" +// isoVersion is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/version.isoVersion=vX.Y.Z" var isoVersion = "v0.0.0-unset" var isoPath = "minikube/iso" @@ -36,11 +38,11 @@ func GetVersion() string { return version } -func GetIsoVersion() string { +func GetISOVersion() string { return isoVersion } -func GetIsoPath() string { +func GetISOPath() string { return isoPath }