Skip to content

Commit fae4f69

Browse files
committed
fix: empty access-lists, prefix-lists and route-maps
1 parent 1fa625a commit fae4f69

File tree

4 files changed

+34
-28
lines changed

4 files changed

+34
-28
lines changed

checks/frr.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ pkgs.testers.nixosTest {
9999
machine.wait_for_unit("frr.service")
100100
print(machine.succeed("vtysh -c 'show run'"))
101101
# TODO validate
102-
machine.succeed("vtysh -c 'show ipv6 prefix-list own-6 json' | ${lib.getExe pkgs.jq}")
103-
machine.succeed("vtysh -c 'show route-map import json' | ${lib.getExe pkgs.jq}")
104-
machine.succeed("vtysh -c 'show route-map export json' | ${lib.getExe pkgs.jq}")
102+
print(machine.succeed("vtysh -c 'show ipv6 prefix-list own-6 json' | ${lib.getExe pkgs.jq}"))
103+
print(machine.succeed("vtysh -c 'show route-map import json' | ${lib.getExe pkgs.jq}"))
104+
print(machine.succeed("vtysh -c 'show route-map export json' | ${lib.getExe pkgs.jq}"))
105105
'';
106106
}

modules/access-list.nix

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,22 @@ let
5959
in
6060
{
6161
options.services.frr.settings.access-list = mkOption {
62-
type = types.submodule ({
63-
options = {
64-
ip = alOption "ipv4";
65-
ipv6 = alOption "ipv6";
66-
bgp_as-path = alOption "bgp as-path";
67-
};
68-
});
62+
type = types.nullOr (
63+
types.submodule ({
64+
options = {
65+
ip = alOption "ipv4";
66+
ipv6 = alOption "ipv6";
67+
bgp_as-path = alOption "bgp as-path";
68+
};
69+
})
70+
);
6971
default = null;
7072
description = ''
7173
[docs.frrouting.org/en/latest/filter.html#ip-access-list](https://docs.frrouting.org/en/latest/filter.html#ip-access-list).
7274
'';
7375
};
7476

75-
config = {
77+
config = lib.mkIf (cfg != null) {
7678
assertions =
7779
let
7880
names = (getAttrsKeyWithoutNullValues cfg.ip) ++ (getAttrsKeyWithoutNullValues cfg.ipv6);

modules/prefix-list.nix

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,14 @@ let
7474
in
7575
{
7676
options.services.frr.settings.prefix-list = mkOption {
77-
type = types.submodule ({
78-
options = {
79-
ip = plOption;
80-
ipv6 = plOption;
81-
};
82-
});
77+
type = types.nullOr (
78+
types.submodule ({
79+
options = {
80+
ip = plOption;
81+
ipv6 = plOption;
82+
};
83+
})
84+
);
8385
default = null;
8486
description = ''
8587
ip prefix-list provides the most powerful prefix based filtering mechanism. In addition to access-list
@@ -90,7 +92,7 @@ in
9092
'';
9193
};
9294

93-
config = {
95+
config = lib.mkIf (cfg != null) {
9496
assertions =
9597
let
9698
names = (getAttrsKeyWithoutNullValues cfg.ip) ++ (getAttrsKeyWithoutNullValues cfg.ipv6);

modules/route-maps.nix

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,17 @@ let
9898
in
9999
{
100100
options.services.frr.settings.route-maps = mkOption {
101-
type = attrsWith' "name" (
102-
with types;
103-
nullOr (submodule {
104-
options = {
105-
permit = rmOption;
106-
optimization = rmOption;
107-
deny = rmOption;
108-
};
109-
})
101+
type = types.nullOr (
102+
attrsWith' "name" (
103+
with types;
104+
nullOr (submodule {
105+
options = {
106+
permit = rmOption;
107+
optimization = rmOption;
108+
deny = rmOption;
109+
};
110+
})
111+
)
110112
);
111113
default = null;
112114
description = ''
@@ -115,7 +117,7 @@ in
115117
'';
116118
};
117119

118-
config = {
120+
config = lib.mkIf (cfg != null) {
119121
assertions =
120122
let
121123
names = builtins.attrNames cfg;

0 commit comments

Comments
 (0)