mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-15 05:11:42 +08:00
add delete and push dns subcommands
This commit is contained in:
20
cli/cmd/dns/delete.go
Normal file
20
cli/cmd/dns/delete.go
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package dns
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gravitl/netmaker/cli/functions"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var dnsDeleteCmd = &cobra.Command{
|
||||||
|
Use: "delete [NETWORK NAME] [DOMAIN NAME]",
|
||||||
|
Args: cobra.ExactArgs(2),
|
||||||
|
Short: "Delete a DNS entry",
|
||||||
|
Long: `Delete a DNS entry`,
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
functions.PrettyPrint(functions.DeleteDNS(args[0], args[1]))
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
rootCmd.AddCommand(dnsDeleteCmd)
|
||||||
|
}
|
22
cli/cmd/dns/push.go
Normal file
22
cli/cmd/dns/push.go
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
package dns
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/gravitl/netmaker/cli/functions"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var dnsPushCmd = &cobra.Command{
|
||||||
|
Use: "push",
|
||||||
|
Args: cobra.NoArgs,
|
||||||
|
Short: "Push latest DNS entries",
|
||||||
|
Long: `Push latest DNS entries`,
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
fmt.Println(*functions.PushDNS())
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
rootCmd.AddCommand(dnsPushCmd)
|
||||||
|
}
|
@@ -26,3 +26,11 @@ func GetNetworkDNS(networkName string) *[]models.DNSEntry {
|
|||||||
func CreateDNS(networkName string, payload *models.DNSEntry) *models.DNSEntry {
|
func CreateDNS(networkName string, payload *models.DNSEntry) *models.DNSEntry {
|
||||||
return request[models.DNSEntry](http.MethodPost, "/api/dns/"+networkName, payload)
|
return request[models.DNSEntry](http.MethodPost, "/api/dns/"+networkName, payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func PushDNS() *string {
|
||||||
|
return request[string](http.MethodPost, "/api/dns/adm/pushdns", nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeleteDNS(networkName, domainName string) *string {
|
||||||
|
return request[string](http.MethodDelete, fmt.Sprintf("/api/dns/%s/%s", networkName, domainName), nil)
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user