func cloneImage(e *ec2.EC2, args ...string) { if len(args) == 0 { fmt.Fprintf(os.Stderr, "clone: need a instance id and options\n") os.Exit(1) } options := &ec2.CreateImage{} options.InstanceId = args[0] for _, v := range args[1:] { s := strings.SplitN(v, "=", 2) if len(s) != 2 { fmt.Fprintf(os.Stderr, "images: bad key=value pair \"%s\", skipping\n", v) continue } switch s[0] { case "name", "Name": options.Name = s[1] case "description", "Description": options.Description = s[1] case "NoReboot", "Noreboot": switch s[1] { case "true", "True", "TRUE", "t", "T": options.NoReboot = true case "false", "False", "FALSE", "f", "F": default: fmt.Fprintf(os.Stderr, "createimage: expected option for NoReboot true/false, found %s", s[1]) return } default: fmt.Fprintf(os.Stderr, "createimage: unknown key/value pair: %s (expected name=n, description=d, noreboot=t|f. skipping...", s[1]) } } resp, err := e.CreateImage(options) if err != nil { fmt.Fprintf(os.Stderr, "createimage error: %s\n", err) os.Exit(1) } fmt.Printf("%s\n", resp.Id) }