Skip to content

Commit

Permalink
Merge pull request #15 from IvanKuchin/development
Browse files Browse the repository at this point in the history
code cleanup and add few more checks
  • Loading branch information
IvanKuchin authored Mar 9, 2024
2 parents 45051cc + a8623f8 commit fbd1422
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"name": "get cisco-dhcp",
"type": "go",
Expand Down
8 changes: 8 additions & 0 deletions internal/cli/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ func getIPAddressesBelongsToSubnets(client api_client.Authenticator, cfg *config

addresses := IPAddresses{}

if len(cfg.Ipam_subnets) == 0 {
return addresses, fmt.Errorf("no subnets defined in config file")
}

for _, subnet := range cfg.Ipam_subnets {

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

if len(cfg.Ipam_subnets) == 0 {
return "", fmt.Errorf("no subnets defined in config file")
}

for _, subnet := range cfg.Ipam_subnets {

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

0 comments on commit fbd1422

Please sign in to comment.