From 3273e55c0dd2f6627482d0d4397ea70327e7186d Mon Sep 17 00:00:00 2001 From: zehuaiWANG <874697675@qq.com> Date: Tue, 17 Dec 2019 13:30:43 +0800 Subject: [PATCH] kops-change-main --- cmd/nodeup/main.go | 16 +++++----------- pkg/apis/kops/model/utils.go | 6 +++--- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/cmd/nodeup/main.go b/cmd/nodeup/main.go index 3b0d29c67b..a3b2e6402e 100644 --- a/cmd/nodeup/main.go +++ b/cmd/nodeup/main.go @@ -37,27 +37,21 @@ const ( func main() { klog.InitFlags(nil) - gitVersion := "" + var flagConf, flagCacheDir, flagRootFS, gitVersion string + var flagRetries int + var dryrun, installSystemdUnit bool + target := "direct" + if kops.GitVersion != "" { gitVersion = fmt.Sprintf(" (git-%s)", kops.GitVersion) } fmt.Printf("nodeup version %s%s\n", kops.Version, gitVersion) - - var flagConf string flag.StringVar(&flagConf, "conf", "node.yaml", "configuration location") - var flagCacheDir string flag.StringVar(&flagCacheDir, "cache", "/var/cache/nodeup", "the location for the local asset cache") - var flagRootFS string flag.StringVar(&flagRootFS, "rootfs", "/", "the location of the machine root (for running in a container)") - var flagRetries int flag.IntVar(&flagRetries, "retries", -1, "maximum number of retries on failure: -1 means retry forever") - - dryrun := false flag.BoolVar(&dryrun, "dryrun", false, "Don't create cloud resources; just show what would be done") - target := "direct" flag.StringVar(&target, "target", target, "Target - direct, cloudinit") - - installSystemdUnit := false flag.BoolVar(&installSystemdUnit, "install-systemd-unit", installSystemdUnit, "If true, will install a systemd unit instead of running directly") if dryrun { diff --git a/pkg/apis/kops/model/utils.go b/pkg/apis/kops/model/utils.go index fa688f30f8..24b6bc36de 100644 --- a/pkg/apis/kops/model/utils.go +++ b/pkg/apis/kops/model/utils.go @@ -25,9 +25,9 @@ import ( // FindSubnet returns the subnet with the specified name, or returns nil func FindSubnet(c *kops.Cluster, subnetName string) *kops.ClusterSubnetSpec { - for i := range c.Spec.Subnets { - if c.Spec.Subnets[i].Name == subnetName { - return &c.Spec.Subnets[i] + for _, subnet := range c.Spec.Subnets { + if subnet.Name == subnetName { + return &subnet } } return nil