upup/pkg/fi-fix staticcheck

This commit is contained in:
Aresforchina 2020-01-06 13:57:44 +08:00
parent addc321db4
commit f312f7c974
7 changed files with 26 additions and 35 deletions

View File

@ -1,5 +1,2 @@
node-authorizer/pkg/server
upup/pkg/fi
upup/pkg/fi/cloudup
upup/pkg/fi/cloudup/awstasks
upup/pkg/kutil

View File

@ -299,14 +299,14 @@ func (c *ApplyClusterCmd) Run() error {
if warn {
fmt.Println("")
fmt.Println(starline)
fmt.Printf("%s\n", starline)
fmt.Println("")
fmt.Println("Kubelet anonymousAuth is currently turned on. This allows RBAC escalation and remote code execution possibilities.")
fmt.Println("It is highly recommended you turn it off by setting 'spec.kubelet.anonymousAuth' to 'false' via 'kops edit cluster'")
fmt.Println("")
fmt.Println("See https://kops.sigs.k8s.io/security/#kubelet-api")
fmt.Println("")
fmt.Println(starline)
fmt.Printf("%s\n", starline)
fmt.Println("")
}
}
@ -1001,20 +1001,20 @@ func (c *ApplyClusterCmd) validateKopsVersion() error {
}
if recommended != nil && !required {
fmt.Println("")
fmt.Println(starline)
fmt.Println("")
fmt.Printf("\n")
fmt.Printf("%s\n", starline)
fmt.Printf("\n")
fmt.Printf("A new kops version is available: %s", recommended)
fmt.Println("")
fmt.Println("upgrading is recommended")
fmt.Printf("\n")
fmt.Printf("Upgrading is recommended\n")
fmt.Printf("More information: %s\n", buildPermalink("upgrade_kops", recommended.String()))
fmt.Println("")
fmt.Println(starline)
fmt.Println("")
fmt.Printf("\n")
fmt.Printf("%s\n", starline)
fmt.Printf("\n")
} else if required {
fmt.Println("")
fmt.Println(starline)
fmt.Println("")
fmt.Printf("\n")
fmt.Printf("%s\n", starline)
fmt.Printf("\n")
if recommended != nil {
fmt.Printf("a new kops version is available: %s\n", recommended)
}
@ -1023,9 +1023,9 @@ func (c *ApplyClusterCmd) validateKopsVersion() error {
fmt.Printf("(you can bypass this check by exporting KOPS_RUN_OBSOLETE_VERSION)\n")
fmt.Println("")
fmt.Printf("More information: %s\n", buildPermalink("upgrade_kops", recommended.String()))
fmt.Println("")
fmt.Printf(starline)
fmt.Println("")
fmt.Printf("\n")
fmt.Printf("%s\n", starline)
fmt.Printf("\n")
}
if required {
@ -1048,14 +1048,14 @@ func (c *ApplyClusterCmd) validateKubernetesVersion() error {
if !util.IsKubernetesGTE(OldestSupportedKubernetesVersion, *parsed) {
fmt.Printf("\n")
fmt.Printf(starline)
fmt.Printf("%s\n", starline)
fmt.Printf("\n")
fmt.Printf("Kops support for this Kubernetes version is deprecated and will be removed in a future release.\n")
fmt.Printf("\n")
fmt.Printf("Upgrading is recommended\n")
fmt.Printf("More information: %s\n", buildPermalink("upgrade_k8s", ""))
fmt.Printf("\n")
fmt.Printf(starline)
fmt.Printf("%s\n", starline)
fmt.Printf("\n")
}
@ -1082,18 +1082,18 @@ func (c *ApplyClusterCmd) validateKubernetesVersion() error {
if recommended != nil && !required {
fmt.Printf("\n")
fmt.Printf(starline)
fmt.Printf("%s\n", starline)
fmt.Printf("\n")
fmt.Printf("A new kubernetes version is available: %s\n", recommended)
fmt.Printf("Upgrading is recommended (try kops upgrade cluster)\n")
fmt.Printf("\n")
fmt.Printf("More information: %s\n", buildPermalink("upgrade_k8s", recommended.String()))
fmt.Printf("\n")
fmt.Printf(starline)
fmt.Printf("%s\n", starline)
fmt.Printf("\n")
} else if required {
fmt.Printf("\n")
fmt.Printf(starline)
fmt.Printf("%s\n", starline)
fmt.Printf("\n")
if recommended != nil {
fmt.Printf("A new kubernetes version is available: %s\n", recommended)
@ -1104,7 +1104,7 @@ func (c *ApplyClusterCmd) validateKubernetesVersion() error {
fmt.Printf("\n")
fmt.Printf("More information: %s\n", buildPermalink("upgrade_k8s", recommended.String()))
fmt.Printf("\n")
fmt.Printf(starline)
fmt.Printf("%s\n", starline)
fmt.Printf("\n")
}

View File

@ -208,12 +208,12 @@ func (_ *SSHKey) RenderCloudformation(t *cloudformation.CloudformationTarget, a,
klog.Warningf("Cloudformation does not manage SSH keys; pre-creating SSH key")
a, err := e.find(cloud)
keypair, err := e.find(cloud)
if err != nil {
return err
}
if a == nil {
if keypair == nil {
err := e.createKeypair(cloud)
if err != nil {
return err

View File

@ -330,7 +330,7 @@ func (b *BootstrapChannelBuilder) buildAddons() *channelsapi.Addons {
enableRBACAddon = false
}
if b.cluster.Spec.KubeAPIServer != nil {
if b.cluster.Spec.KubeAPIServer.EnableBootstrapAuthToken != nil && *b.cluster.Spec.KubeAPIServer.EnableBootstrapAuthToken == true {
if b.cluster.Spec.KubeAPIServer.EnableBootstrapAuthToken != nil && *b.cluster.Spec.KubeAPIServer.EnableBootstrapAuthToken {
enableRBACAddon = false
}
}

View File

@ -55,8 +55,6 @@ type Loader struct {
typeMap map[string]reflect.Type
templates []*template.Template
Resources map[string]fi.Resource
Builders []fi.ModelBuilder

View File

@ -222,9 +222,7 @@ func (c *populateClusterSpec) run(clientset simple.Clientset) error {
// Normalize k8s version
versionWithoutV := strings.TrimSpace(cluster.Spec.KubernetesVersion)
if strings.HasPrefix(versionWithoutV, "v") {
versionWithoutV = versionWithoutV[1:]
}
versionWithoutV = strings.TrimPrefix(versionWithoutV, "v")
if cluster.Spec.KubernetesVersion != versionWithoutV {
klog.V(2).Infof("Normalizing kubernetes version: %q -> %q", cluster.Spec.KubernetesVersion, versionWithoutV)
cluster.Spec.KubernetesVersion = versionWithoutV

View File

@ -159,8 +159,6 @@ func (e *executor) RunTasks(taskMap map[string]Task) error {
return nil
}
type runnable func() error
func (e *executor) forkJoin(tasks []*taskState) []error {
if len(tasks) == 0 {
return nil