Skip to content

Commit a8623f8

Browse files
committed
code cleanup and add few more checks
1 parent 45051cc commit a8623f8

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

.vscode/launch.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7+
78
{
89
"name": "get cisco-dhcp",
910
"type": "go",

internal/cli/get.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ func getIPAddressesBelongsToSubnets(client api_client.Authenticator, cfg *config
5555

5656
addresses := IPAddresses{}
5757

58+
if len(cfg.Ipam_subnets) == 0 {
59+
return addresses, fmt.Errorf("no subnets defined in config file")
60+
}
61+
5862
for _, subnet := range cfg.Ipam_subnets {
5963

6064
subnet_id, err := getSubnetID(client, config_reader.Cfg, subnet)
@@ -196,6 +200,10 @@ func getCiscoDHCPOutputBySubnet(addresses IPAddresses, subnet string) (string, e
196200
func getCiscoDHCPOutput(client api_client.Authenticator, cfg *config_reader.Config) (string, error) {
197201
output := ""
198202

203+
if len(cfg.Ipam_subnets) == 0 {
204+
return "", fmt.Errorf("no subnets defined in config file")
205+
}
206+
199207
for _, subnet := range cfg.Ipam_subnets {
200208

201209
subnet_id, err := getSubnetID(client, config_reader.Cfg, subnet)

0 commit comments

Comments
 (0)