fix golint failures in cmd/kubeadm/app/util/system

k3s-v1.15.3
SataQiu 2019-03-29 12:03:25 +08:00
parent b1829dff0b
commit a41c85ea07
7 changed files with 16 additions and 6 deletions

View File

@ -26,10 +26,12 @@ import (
var _ Validator = &CgroupsValidator{}
// CgroupsValidator validates cgroup configuration.
type CgroupsValidator struct {
Reporter Reporter
}
// Name is part of the system.Validator interface.
func (c *CgroupsValidator) Name() string {
return "cgroups"
}
@ -38,6 +40,7 @@ const (
cgroupsConfigPrefix = "CGROUPS_"
)
// Validate is part of the system.Validator interface.
func (c *CgroupsValidator) Validate(spec SysSpec) (error, error) {
subsystems, err := c.getCgroupSubsystems()
if err != nil {

View File

@ -32,6 +32,7 @@ type DockerValidator struct {
Reporter Reporter
}
// Name is part of the system.Validator interface.
func (d *DockerValidator) Name() string {
return "docker"
}
@ -41,6 +42,7 @@ const (
latestValidatedDockerVersion = "18.09"
)
// Validate is part of the system.Validator interface.
// TODO(random-liu): Add more validating items.
func (d *DockerValidator) Validate(spec SysSpec) (error, error) {
if spec.RuntimeSpec.DockerSpec == nil {

View File

@ -44,6 +44,7 @@ type KernelValidator struct {
Reporter Reporter
}
// Name is part of the system.Validator interface.
func (k *KernelValidator) Name() string {
return "kernel"
}
@ -58,10 +59,11 @@ const (
// validKConfigRegex is the regex matching kernel configuration line.
validKConfigRegex = "^CONFIG_[A-Z0-9_]+=[myn]"
// kConfigPrefix is the prefix of kernel configuration.
kConfigPrefix = "CONFIG_"
// kernelConfigPrefix is the prefix of kernel configuration.
kernelConfigPrefix = "CONFIG_"
)
// Validate is part of the system.Validator interface.
func (k *KernelValidator) Validate(spec SysSpec) (error, error) {
helper := KernelValidatorHelperImpl{}
release, err := helper.GetKernelReleaseVersion()
@ -135,7 +137,7 @@ func (k *KernelValidator) validateCachedKernelConfig(allConfig map[string]kConfi
var opt kConfigOption
var ok bool
for _, name = range append([]string{config.Name}, config.Aliases...) {
name = kConfigPrefix + name
name = kernelConfigPrefix + name
if opt, ok = allConfig[name]; ok {
break
}

View File

@ -173,7 +173,7 @@ func TestValidateCachedKernelConfig(t *testing.T) {
// Add kernel config prefix.
for k, v := range test.config {
delete(test.config, k)
test.config[kConfigPrefix+k] = v
test.config[kernelConfigPrefix+k] = v
}
err := v.validateCachedKernelConfig(test.config, testKernelSpec)
if !test.err {

View File

@ -25,14 +25,17 @@ import (
var _ Validator = &OSValidator{}
// OSValidator validates OS.
type OSValidator struct {
Reporter Reporter
}
// Name is part of the system.Validator interface.
func (o *OSValidator) Name() string {
return "os"
}
// Validate is part of the system.Validator interface.
func (o *OSValidator) Validate(spec SysSpec) (error, error) {
os, err := exec.Command("uname").CombinedOutput()
if err != nil {

View File

@ -47,12 +47,13 @@ func colorize(s string, c color) string {
return fmt.Sprintf("\033[0;%dm%s\033[0m", c, s)
}
// The default reporter for the system verification test
// StreamReporter is the default reporter for the system verification test.
type StreamReporter struct {
// The stream that this reporter is writing to
WriteStream io.Writer
}
// Report reports validation result in different color depending on the result type.
func (dr *StreamReporter) Report(key, value string, resultType ValidationResultType) error {
var c color
switch resultType {

View File

@ -3,7 +3,6 @@ cmd/kube-apiserver/app
cmd/kube-controller-manager/app
cmd/kube-proxy/app
cmd/kubeadm/app/apis/kubeadm/v1beta1
cmd/kubeadm/app/util/system
pkg/apis/abac/latest
pkg/apis/admission
pkg/apis/admissionregistration