kops-change-main

This commit is contained in:
zehuaiWANG 2019-12-17 13:30:43 +08:00
parent ebb111d23a
commit 3273e55c0d
2 changed files with 8 additions and 14 deletions

View File

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

View File

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