func main() { if help { flag.PrintDefaults() } else { target := flag.Arg(0) if keys.Len() == 0 { fmt.Fprintln(os.Stderr, "WARNING: No signing keys specified, upload *DISABLED*") } if target != "" { strkeys := keys.GetAll() digest, manifest, err := processTarget(target, strkeys) if err != nil { fmt.Printf("Error processing target: %s\n", err) os.Exit(1) } if verbose { fmt.Println(manifest) } fmt.Printf("Done! Referencing digest: %s\n", digest) } } os.Exit(0) }
// doFlags defines the cmdline Usage string and parses flag options. func doFlags() { flag.Usage = func() { fmt.Fprintf(os.Stderr, " Usage: %s [OPTIONS] REGISTRY REPO [REPO...]\n", os.Args[0]) fmt.Fprintf(os.Stderr, "\n REGISTRY:\n") fmt.Fprintf(os.Stderr, "\tURL of your Docker registry; use index.docker.io for Docker Hub, use local.host to collect images from local Docker host\n") fmt.Fprintf(os.Stderr, "\n REPO:\n") fmt.Fprintf(os.Stderr, "\tOne or more repos to gather info about; if no repo is specified Collector will gather info on *all* repos in the Registry\n") fmt.Fprintf(os.Stderr, "\n Environment variables:\n") fmt.Fprintf(os.Stderr, "\tCOLLECTOR_DIR: (Required) Directory that contains the \"data\" folder with Collector default scripts, e.g., $GOPATH/src/github.com/banyanops/collector\n") fmt.Fprintf(os.Stderr, "\tCOLLECTOR_ID: ID provided by Banyan web interface to register Collector with the Banyan service\n") fmt.Fprintf(os.Stderr, "\tBANYAN_HOST_DIR: Host directory mounted into Collector/Target containers where results are stored (default: $HOME/.banyan)\n") fmt.Fprintf(os.Stderr, "\tBANYAN_DIR: (Specify only in Dockerfile) Directory in the Collector container where host directory BANYAN_HOST_DIR is mounted\n") fmt.Fprintf(os.Stderr, "\tDOCKER_{HOST,CERT_PATH,TLS_VERIFY}: If set, e.g., by docker-machine, then they take precedence over --dockerProto and --dockerAddr\n") printExampleUsage() fmt.Fprintf(os.Stderr, " Options:\n") flag.PrintDefaults() } flag.Parse() if config.COLLECTORDIR() == "" { flag.Usage() os.Exit(except.ErrorExitStatus) } if len(flag.Args()) < 1 { flag.Usage() os.Exit(except.ErrorExitStatus) } if *dockerProto != "unix" && *dockerProto != "tcp" { flag.Usage() os.Exit(except.ErrorExitStatus) } requiredDirs := []string{config.BANYANDIR(), filepath.Dir(*imageList), filepath.Dir(*repoList), *config.BanyanOutDir, collector.DefaultScriptsDir, collector.UserScriptsDir, collector.BinDir} for _, dir := range requiredDirs { blog.Debug("Creating directory: " + dir) err := fsutil.CreateDirIfNotExist(dir) if err != nil { except.Fail(err, ": Error in creating a required directory: ", dir) } } collector.RegistrySpec = flag.Arg(0) // EqualFold: case insensitive comparison if strings.EqualFold(flag.Arg(0), "local.host") { collector.LocalHost = true } //nextMaxImages = *maxImages }
func main() { if help { flag.PrintDefaults() } else { target := flag.Arg(0) if target != "" { //fmt.Printf("outputting manifest for: %q with key: %q\n", target, key) outputManifestFor(target) } } }