| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package cmd
- import (
- "github.com/spf13/cobra"
- )
- var zonesCmd = &cobra.Command{
- Use: "zones",
- Short: "List the zones the account can see",
- Long: `List every DNS zone the account has access to, with the name server that
- serves it.
- This is also the quickest way to check that credentials, context and network
- path are all working: it is read-only and touches nothing.
- The name server shown is the value the gateway requires when changing
- records, so this is what the write commands rely on.`,
- Example: ` # every zone
- schlundtech-dns zones
- # one zone per line, for scripting
- schlundtech-dns zones --output json`,
- Args: cobra.NoArgs,
- RunE: func(cmd *cobra.Command, _ []string) error {
- f, err := parseFormat(flagOutput)
- if err != nil {
- return err
- }
- c, err := client()
- if err != nil {
- return err
- }
- zones, err := c.Zones(cmd.Context())
- if err != nil {
- return err
- }
- rows := make([][]string, 0, len(zones))
- for _, z := range zones {
- rows = append(rows, []string{z.Name, z.SystemNS})
- }
- return writeOutput(cmd.OutOrStdout(), f, []string{"ZONE", "NAMESERVER"}, rows, zones)
- },
- }
- func init() {
- rootCmd.AddCommand(zonesCmd)
- }
|