mostly whitespace changes

This commit is contained in:
Adora Laura Kalb 2023-03-16 20:57:21 +01:00
parent 9f8c8f7e29
commit 2db0e27223
5 changed files with 33 additions and 33 deletions

View file

@ -15,8 +15,8 @@ var exportCmd = &cobra.Command{
Use: "export", Use: "export",
Short: "Export current ipam configuration (not implemented)", Short: "Export current ipam configuration (not implemented)",
Long: `Export current ipam contents to importable data format. Long: `Export current ipam contents to importable data format.
Not implemented yet.`, Not implemented yet.`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Not implemented") fmt.Println("Not implemented")
}, },

View file

@ -15,8 +15,8 @@ var importCmd = &cobra.Command{
Use: "import", Use: "import",
Short: "Import ipam configuration (not implemented)", Short: "Import ipam configuration (not implemented)",
Long: `Import ips and subnets to ipam. Long: `Import ips and subnets to ipam.
Not implemented yet.`, Not implemented yet.`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Not implemented") fmt.Println("Not implemented")
}, },

View file

@ -63,7 +63,7 @@ func initConfig() {
viper.SetConfigType("yaml") viper.SetConfigType("yaml")
viper.SetDefault("DataPath", ipamdir+"data/") viper.SetDefault("DataPath", ipamdir+"data/")
viper.SetDefault("EnablePowerDNS", false) viper.SetDefault("PowerDNSEnabled", false)
viper.SetDefault("PowerDNSEndpoint", "") viper.SetDefault("PowerDNSEndpoint", "")
viper.SetDefault("PowerDNSApiKey", "") viper.SetDefault("PowerDNSApiKey", "")

View file

@ -22,7 +22,7 @@ var subnetlistCmd = &cobra.Command{
Args: cobra.ExactArgs(0), Args: cobra.ExactArgs(0),
Example: "cmdb subnet list", Example: "cmdb subnet list",
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
verbose, _ := cmd.Flags().GetBool("verbose") //verbose, _ := cmd.Flags().GetBool("verbose")
subnetlist := ListSubnets() subnetlist := ListSubnets()
var subnets []Subnet var subnets []Subnet
@ -40,21 +40,21 @@ var subnetlistCmd = &cobra.Command{
}) })
for _, subnet := range subnets { for _, subnet := range subnets {
if verbose { //if verbose {
var numip, freeip int var numip, freeip int
if subnet.Subnet.Addr().Is4() { if subnet.Subnet.Addr().Is4() {
hostbits := float64(32 - subnet.Subnet.Bits()) hostbits := float64(32 - subnet.Subnet.Bits())
numip = int(math.Pow(2, hostbits)) - 2 numip = int(math.Pow(2, hostbits)) - 2
freeip = numip - len(subnet.Addresses) freeip = numip - len(subnet.Addresses)
fmt.Printf("%v:\t%v\t(vl: %v)\tfree: %v\n", subnet.Subnet, subnet.Name, subnet.Vlan, freeip) fmt.Printf("%v:\t%v\t(vl: %v)\tfree: %v\n", subnet.Subnet, subnet.Name, subnet.Vlan, freeip)
} else {
fmt.Printf("%v:\t%v\t(vl: %v)\n", subnet.Subnet, subnet.Name, subnet.Vlan)
}
} else { } else {
fmt.Printf("%v:\t%v\t(vl: %v)\n", subnet.Subnet, subnet.Name, subnet.Vlan) fmt.Printf("%v:\t%v\t(vl: %v)\n", subnet.Subnet, subnet.Name, subnet.Vlan)
} }
//} else {
// fmt.Printf("%v:\t%v\t(vl: %v)\n", subnet.Subnet, subnet.Name, subnet.Vlan)
//}
} }
}, },
@ -71,5 +71,5 @@ func init() {
// Cobra supports local flags which will only run when this command // Cobra supports local flags which will only run when this command
// is called directly, e.g.: // is called directly, e.g.:
subnetlistCmd.Flags().BoolP("verbose", "v", false, "Show verbose output like free IPs") // subnetlistCmd.Flags().BoolP("verbose", "v", false, "Show verbose output like free IPs")
} }

32
go.mod
View file

@ -5,20 +5,20 @@ go 1.20
require github.com/spf13/cobra v1.6.1 require github.com/spf13/cobra v1.6.1
require ( require (
github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/spf13/afero v1.9.3 // indirect github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/cast v1.5.0 // indirect github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.15.0 // indirect github.com/spf13/viper v1.15.0 // indirect
github.com/subosito/gotenv v1.4.2 // indirect github.com/subosito/gotenv v1.4.2 // indirect
golang.org/x/sys v0.3.0 // indirect golang.org/x/sys v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect golang.org/x/text v0.5.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )