diff --git a/cmd/ip-delete.go b/cmd/ip-delete.go index e9cf5b8..02af04f 100644 --- a/cmd/ip-delete.go +++ b/cmd/ip-delete.go @@ -41,7 +41,7 @@ var ipdeleteCmd = &cobra.Command{ os.Exit(1) } - writeerr := WriteSubnet(subnet) + writeerr := subnet.WriteSubnet() if writeerr != nil { fmt.Println("[ERROR]", writeerr) os.Exit(1) diff --git a/cmd/powerdns.go b/cmd/powerdns.go index 661cc93..365a754 100644 --- a/cmd/powerdns.go +++ b/cmd/powerdns.go @@ -260,7 +260,8 @@ func GetBestDNSZone(fqdn string) (DNSZone, error) { } // 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 func AddDNSFqdn(fqdn string, addr netip.Addr) error { @@ -358,7 +359,7 @@ func DeleteDNSFqdn(fqdn string, addr netip.Addr) error { fzone, fzoneerr := GetBestDNSZone(fqdn) 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 { _, frecordexists := fzone.GetRecord(fqdn, recordtype, addr.String()) diff --git a/cmd/subnet-delete.go b/cmd/subnet-delete.go index 20d397f..17fb64c 100644 --- a/cmd/subnet-delete.go +++ b/cmd/subnet-delete.go @@ -38,11 +38,15 @@ var subnetdeleteCmd = &cobra.Command{ } var confirmation string - 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) - confirmation = "y" + skipinteractive, _ := cmd.Flags().GetBool("yes") + if skipinteractive { + confirmation = "y" + } else { + 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") { for _, address := range subnetobj.Addresses { diff --git a/cmd/subnet-show.go b/cmd/subnet-show.go index 7b340e4..dcc7a25 100644 --- a/cmd/subnet-show.go +++ b/cmd/subnet-show.go @@ -7,6 +7,7 @@ import ( "fmt" "net/netip" "os" + "time" "github.com/spf13/cobra" ) @@ -38,9 +39,12 @@ aswell as a list of containing IP addresses`, fmt.Println("[ERROR]", subneterr) os.Exit(1) } - fmt.Printf("\nName: %v\n", subnet.Name) - fmt.Printf("Vlan: %v\n", subnet.Vlan) - fmt.Printf("Prefix: %v\n\n", subnet.Subnet) + fmt.Printf("\n") + fmt.Printf("Name: %v\n", subnet.Name) + 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) for _, element := range subnet.Addresses {