Address all lint except undocumented and stutter

These two lint warnings still remain, after the cleanup:
"exported ... should have comment or be unexported"

"type name will be used as foo.FooBar by other packages,
 and that stutters; consider calling this Bar"
pull/3839/head
Anders F Björklund 2019-03-02 22:02:56 +01:00
parent c71864484c
commit 46640cef68
29 changed files with 79 additions and 77 deletions

View File

@ -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
}

View File

@ -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)}

View File

@ -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)

View File

@ -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 {

View File

@ -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

View File

@ -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
}

View File

@ -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 = `
<graphics type='spice' autoport='yes'>
@ -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
}

View File

@ -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,

View File

@ -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

View File

@ -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 (

View File

@ -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)

View File

@ -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{},
}

View File

@ -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"

View File

@ -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",

View File

@ -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 (

View File

@ -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 {

View File

@ -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())

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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

View File

@ -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 (

View File

@ -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()

View File

@ -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())
}
}

View File

@ -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 {

View File

@ -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
}

View File

@ -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 {

View File

@ -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
}

View File

@ -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
}