bundlerMain is the main CLI of bundler functionality.
(args []string, c cli.Config)
| 27 | |
| 28 | // bundlerMain is the main CLI of bundler functionality. |
| 29 | func bundlerMain(args []string, c cli.Config) (err error) { |
| 30 | bundler.IntermediateStash = c.IntDir |
| 31 | ubiquity.LoadPlatforms(c.Metadata) |
| 32 | flavor := bundler.BundleFlavor(c.Flavor) |
| 33 | var b *bundler.Bundler |
| 34 | // If it is a force bundle, don't require ca bundle and intermediate bundle |
| 35 | // Otherwise, initialize a bundler with CA bundle and intermediate bundle. |
| 36 | if flavor == bundler.Force { |
| 37 | b = &bundler.Bundler{} |
| 38 | } else { |
| 39 | b, err = bundler.NewBundler(c.CABundleFile, c.IntBundleFile) |
| 40 | if err != nil { |
| 41 | return |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | var bundle *bundler.Bundle |
| 46 | if c.CertFile != "" { |
| 47 | if c.CertFile == "-" { |
| 48 | var certPEM, keyPEM []byte |
| 49 | certPEM, err = cli.ReadStdin(c.CertFile) |
| 50 | if err != nil { |
| 51 | return |
| 52 | } |
| 53 | if c.KeyFile != "" { |
| 54 | keyPEM, err = cli.ReadStdin(c.KeyFile) |
| 55 | if err != nil { |
| 56 | return |
| 57 | } |
| 58 | } |
| 59 | bundle, err = b.BundleFromPEMorDER(certPEM, keyPEM, flavor, "") |
| 60 | if err != nil { |
| 61 | return |
| 62 | } |
| 63 | } else { |
| 64 | // Bundle the client cert |
| 65 | bundle, err = b.BundleFromFile(c.CertFile, c.KeyFile, flavor, c.Password) |
| 66 | if err != nil { |
| 67 | return |
| 68 | } |
| 69 | } |
| 70 | } else if c.Domain != "" { |
| 71 | bundle, err = b.BundleFromRemote(c.Domain, c.IP, flavor) |
| 72 | if err != nil { |
| 73 | return |
| 74 | } |
| 75 | } else { |
| 76 | return errors.New("Must specify bundle target through -cert or -domain") |
| 77 | } |
| 78 | |
| 79 | marshaled, err := bundle.MarshalJSON() |
| 80 | if err != nil { |
| 81 | return |
| 82 | } |
| 83 | fmt.Printf("%s", marshaled) |
| 84 | return |
| 85 | } |
| 86 |
nothing calls this directly
no test coverage detected
searching dependent graphs…