Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ActivateCmd = &cobra.Command{ Use: "activate [record-name]", Short: "active DNSRecord", Aliases: []string{"enable", "on", "en"}, Args: cobra.ExactArgs(1), SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { r, err := get(args[0]) if err != nil { return err } if r.Spec.Active == nil || *r.Spec.Active { return nil } active := true r.Spec.Active = &active if err := client.Update(context.Background(), r); err != nil { return err } return nil }, } )
View Source
var ( DeactivateCmd = &cobra.Command{ Use: "deactivate [record-name]", Short: "de-activate DNSRecord", Aliases: []string{"disable", "off", "dis"}, SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { r, err := get(args[0]) if err != nil { return err } if r.Spec.Active != nil && !*r.Spec.Active { return nil } active := false r.Spec.Active = &active if err := client.Update(context.Background(), r); err != nil { return err } return nil }, } )
View Source
var ( ImportCmd = &cobra.Command{ Use: "import [file]", Short: "import dns bind file zone and print the DNSRecordList to stdout", Example: ` kubectl dns import example.org | kubectl apply -f -`, Aliases: []string{"convert"}, Args: cobra.ExactArgs(1), SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { i, err := os.Stat(args[0]) if err != nil { return err } if i.IsDir() { return errors.New("input: expected a file, not a directory") } rrs, err := parse(args[0]) if err != nil { return err } b, err := yaml.Marshal(rrs) if err != nil { return err } if _, err := os.Stdout.Write(b); err != nil { return err } return nil }, } )
View Source
var ( ListCmd = &cobra.Command{ Use: "list", Short: "list DNSRecords", Aliases: []string{"ls", "l"}, SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { var l v1alpha1.DNSRecordList var opts []client2.ListOption if a, _ := cmd.Flags().GetBool("all-namespaces"); !a { opts = append(opts, client2.InNamespace(ns)) } if err := client.List(context.Background(), &l, opts...); err != nil { return err } if len(l.Items) == 0 { fmt.Printf("No resources found in %s namespace.\n", ns) return nil } if quiet { for _, v := range l.Items { fmt.Printf("%s/%s\n", v.Namespace, v.Name) } return nil } output := []string{ "NAME | NAMESPACE | ACTIVE | RECORD | TTL | | TYPE | VALUE", } for _, v := range l.Items { parts := strings.Split(v.Status.Record, "\t") parts = append(append([]string{v.Name, ns, strconv.FormatBool(ptr.ToBool(v.Status.Active))}, parts...)) output = append(output, strings.Join(parts, " | ")) } result := columnize.SimpleFormat(output) fmt.Println(result) return nil }, } )
View Source
var ( NewCmd = &cobra.Command{ Use: "create [record]", Short: "create a DNSRecord from bind record format and print it to stdout", Example: ` kubectl dns create 'dns.google.com. IN A 8.8.8.8' | kubectl apply -f -`, Aliases: []string{"new", "add"}, Args: cobra.ExactArgs(1), SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { rr, err := dns.NewRR(args[0]) if err != nil { return fmt.Errorf("invalid record: '%s': %v", args[0], err) } if rr == nil { return fmt.Errorf("invalid record: '%s'", args[0]) } r := record.FromRR(rr) r.Namespace = ns b, err := yaml.Marshal(r) if err != nil { return err } _, err = os.Stdout.Write(b) return err }, } )
View Source
var ( RootCmd = cobra.Command{ Use: "dns", Short: "dns root command", SilenceUsage: true, PersistentPreRunE: func(cmd *cobra.Command, args []string) error { ns, _, _ = configFlags.ToRawKubeConfigLoader().Namespace() if ns == "" { ns = "default" } conf, err := configFlags.ToRESTConfig() if err != nil { return err } client, err = client2.New(conf, client2.Options{}) if err != nil { return err } return nil }, } )
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.