Esempio n. 1
0
func (c *DNSDeleteCNameCommand) Execute(args []string) error {
	if err := InitDNSProvider(c.Provider, c.ZoneID, c.TTL); err != nil {
		return Output(nil, nil, err)
	}
	cname := dns.CName{
		Name:     c.Prefix + "." + suffix,
		Original: c.Original,
	}
	recordID := cname.ID()
	err, errChan := dns.Provider.DeleteRecords("cli", c.Comment, recordID)
	if err != nil {
		return Output(nil, nil, err)
	}
	err = <-errChan
	if err == nil {
		Log("-> deleted: ", recordID)
	}
	return Output(map[string]interface{}{"id": recordID}, recordID, err)
}
Esempio n. 2
0
func (c *DNSCreateCNameCommand) Execute(args []string) error {
	if err := InitDNSProvider(c.Provider, c.ZoneID, c.TTL); err != nil {
		return Output(nil, nil, err)
	}
	cname := dns.CName{
		Name:     c.Prefix + "." + suffix,
		Original: c.Original,
		Failover: c.Failover,
		Weight:   c.Weight,
	}
	err := dns.Provider.CreateRecords("cli", c.Comment, []dns.Record{&cname})
	if err != nil {
		return Output(nil, nil, err)
	}
	Log("-> created %s", cname.ID())
	return Output(map[string]interface{}{"id": cname.ID()}, cname.ID(), err)
}