list.go 943 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package dns
  2. import (
  3. "fmt"
  4. "github.com/gravitl/netmaker/cli/functions"
  5. "github.com/spf13/cobra"
  6. )
  7. var dnsListCmd = &cobra.Command{
  8. Use: "list",
  9. Args: cobra.NoArgs,
  10. Short: "List DNS entries",
  11. Long: `List DNS entries`,
  12. Run: func(cmd *cobra.Command, args []string) {
  13. if networkName != "" {
  14. switch dnsType {
  15. case "node":
  16. functions.PrettyPrint(functions.GetNodeDNS(networkName))
  17. case "custom":
  18. functions.PrettyPrint(functions.GetCustomDNS(networkName))
  19. case "network", "":
  20. functions.PrettyPrint(functions.GetNetworkDNS(networkName))
  21. default:
  22. fmt.Println("Invalid DNS type provided ", dnsType)
  23. }
  24. } else {
  25. functions.PrettyPrint(functions.GetDNS())
  26. }
  27. },
  28. }
  29. func init() {
  30. dnsListCmd.Flags().StringVar(&networkName, "network", "", "Network name")
  31. dnsListCmd.Flags().StringVar(&dnsType, "type", "", "Type of DNS records to fetch ENUM(node, custom, network)")
  32. rootCmd.AddCommand(dnsListCmd)
  33. }