Tim Windelschmidt | 886c386 | 2023-05-23 16:47:41 +0200 | [diff] [blame^] | 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "flag" |
| 5 | |
| 6 | "github.com/spf13/cobra" |
| 7 | |
| 8 | "k8s.io/klog" |
| 9 | |
| 10 | "source.monogon.dev/cloud/shepherd/equinix/wrapngo" |
| 11 | ) |
| 12 | |
| 13 | // rootCmd represents the base command when called without any subcommands |
| 14 | var rootCmd = &cobra.Command{ |
| 15 | PersistentPreRunE: func(cmd *cobra.Command, args []string) error { |
| 16 | if c.APIKey == "" || c.User == "" { |
| 17 | klog.Exitf("-equinix_api_username and -equinix_api_key must be set") |
| 18 | } |
| 19 | return nil |
| 20 | }, |
| 21 | } |
| 22 | |
| 23 | var c wrapngo.Opts |
| 24 | |
| 25 | func init() { |
| 26 | c.RegisterFlags() |
| 27 | rootCmd.PersistentFlags().AddGoFlagSet(flag.CommandLine) |
| 28 | } |
| 29 | |
| 30 | func main() { |
| 31 | cobra.CheckErr(rootCmd.Execute()) |
| 32 | } |