create.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package ext_client
  2. import (
  3. "fmt"
  4. "github.com/gravitl/netmaker/cli/functions"
  5. "github.com/gravitl/netmaker/models"
  6. "github.com/spf13/cobra"
  7. )
  8. var (
  9. extClientID string
  10. publicKey string
  11. dns string
  12. allowedips []string
  13. )
  14. var extClientCreateCmd = &cobra.Command{
  15. Use: "create [NETWORK NAME] [NODE ID]",
  16. Args: cobra.ExactArgs(2),
  17. Short: "Create an External Client",
  18. Long: `Create an External Client`,
  19. Run: func(cmd *cobra.Command, args []string) {
  20. extClient := models.CustomExtClient{
  21. ClientID: extClientID,
  22. PublicKey: publicKey,
  23. DNS: dns,
  24. ExtraAllowedIPs: allowedips,
  25. }
  26. functions.CreateExtClient(args[0], args[1], extClient)
  27. fmt.Println("Success")
  28. },
  29. }
  30. func init() {
  31. extClientCreateCmd.Flags().StringVar(&extClientID, "id", "", "ID of the external client")
  32. extClientCreateCmd.Flags().StringVar(&publicKey, "public_key", "", "updated public key of the external client")
  33. extClientCreateCmd.Flags().StringVar(&dns, "dns", "", "updated DNS of the external client")
  34. extClientCreateCmd.Flags().StringSliceVar(&allowedips, "allowedips", []string{}, "updated extra allowed IPs of the external client")
  35. rootCmd.AddCommand(extClientCreateCmd)
  36. }