small changes

This commit is contained in:
Adora Laura Kalb 2023-03-24 16:32:19 +01:00
parent 9918cf040c
commit cf3ff366c3
4 changed files with 20 additions and 11 deletions

View file

@ -41,7 +41,7 @@ var ipdeleteCmd = &cobra.Command{
os.Exit(1) os.Exit(1)
} }
writeerr := WriteSubnet(subnet) writeerr := subnet.WriteSubnet()
if writeerr != nil { if writeerr != nil {
fmt.Println("[ERROR]", writeerr) fmt.Println("[ERROR]", writeerr)
os.Exit(1) os.Exit(1)

View file

@ -260,7 +260,8 @@ func GetBestDNSZone(fqdn string) (DNSZone, error) {
} }
// AddDNSfqdn tries to create forward and reverse lookup records // AddDNSfqdn tries to create forward and reverse lookup records
// for given fqdn with netip.Addr addr. // for given fqdn with netip.Addr addr, IF PowerDNS integration
// is enabled.
// //
// Returns nil on success, error otherwise // Returns nil on success, error otherwise
func AddDNSFqdn(fqdn string, addr netip.Addr) error { func AddDNSFqdn(fqdn string, addr netip.Addr) error {
@ -358,7 +359,7 @@ func DeleteDNSFqdn(fqdn string, addr netip.Addr) error {
fzone, fzoneerr := GetBestDNSZone(fqdn) fzone, fzoneerr := GetBestDNSZone(fqdn)
if fzoneerr != nil { if fzoneerr != nil {
fmt.Printf("[DNS] No suitable zone found for %v, skipping DNS deletion op\n", fqdn) fmt.Printf("[DNS] No suitable zone found for %v, skipping DNS delete op\n", fqdn)
} else { } else {
_, frecordexists := fzone.GetRecord(fqdn, recordtype, addr.String()) _, frecordexists := fzone.GetRecord(fqdn, recordtype, addr.String())

View file

@ -38,11 +38,15 @@ var subnetdeleteCmd = &cobra.Command{
} }
var confirmation string var confirmation string
fmt.Printf("[WARNING] Do you really want to delete subnet %v?\n", subnet.String()) skipinteractive, _ := cmd.Flags().GetBool("yes")
fmt.Printf("[WARNING] This will also delete all DNS records if PowerDNS integration is enabled!\n") if skipinteractive {
fmt.Printf("[WARNING] Continue? [y/N] ") confirmation = "y"
//fmt.Scan(&confirmation) } else {
confirmation = "y" fmt.Printf("[WARNING] Do you really want to delete subnet %v?\n", subnet.String())
fmt.Printf("[WARNING] This will also delete all DNS records if PowerDNS integration is enabled!\n")
fmt.Printf("[WARNING] Continue? [y/N] ")
fmt.Scan(&confirmation)
}
if (confirmation == "y") || (confirmation == "Y") { if (confirmation == "y") || (confirmation == "Y") {
for _, address := range subnetobj.Addresses { for _, address := range subnetobj.Addresses {

View file

@ -7,6 +7,7 @@ import (
"fmt" "fmt"
"net/netip" "net/netip"
"os" "os"
"time"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -38,9 +39,12 @@ aswell as a list of containing IP addresses`,
fmt.Println("[ERROR]", subneterr) fmt.Println("[ERROR]", subneterr)
os.Exit(1) os.Exit(1)
} }
fmt.Printf("\nName: %v\n", subnet.Name) fmt.Printf("\n")
fmt.Printf("Vlan: %v\n", subnet.Vlan) fmt.Printf("Name: %v\n", subnet.Name)
fmt.Printf("Prefix: %v\n\n", subnet.Subnet) fmt.Printf("Vlan: %v\n", subnet.Vlan)
fmt.Printf("Prefix: %v\n", subnet.Subnet)
fmt.Printf("Modified at: %v\n", subnet.ChangedAt.Format(time.RFC1123))
fmt.Printf("Modified by: %v\n\n", subnet.ChangedBy)
fmt.Printf("%v:\n", subnet.Subnet) fmt.Printf("%v:\n", subnet.Subnet)
for _, element := range subnet.Addresses { for _, element := range subnet.Addresses {