Skip to content

Commit c46b5e7

Browse files
gorangalinecmjuraga
authored andcommitted
BUG/MEDIUM: maps: return an empty list instead of nil for an empty maps file
1 parent 2c5c6c5 commit c46b5e7

File tree

6 files changed

+17
-6
lines changed

6 files changed

+17
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# this is an empty map file

e2e/tests/runtime_maps_entries/data/haproxy.cfg

+4
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@ frontend fe_map
2525
frontend fe_map2
2626
bind *:2358
2727
use_backend %[str(example.com),map(/tmp/maps/mapfile2.map)]
28+
29+
frontend fe_map_empty
30+
bind *:5678
31+
use_backend %[str(example.com),map(/tmp/maps/empty.map)]

e2e/tests/runtime_maps_entries/get_entries.bats

+6
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,9 @@ load 'utils/_helpers'
3838
resource_get "$_RUNTIME_MAP_ENTRIES_BASE_PATH" "map=not-exists.map"
3939
assert_equal "$SC" 404
4040
}
41+
42+
@test "runtime_maps_entries: https://github.com/haproxytech/dataplaneapi/issues/234" {
43+
resource_get "$_RUNTIME_MAP_ENTRIES_BASE_PATH" "map=empty.map"
44+
assert_equal "$SC" 200
45+
assert_equal "$($BODY)" ""
46+
}

e2e/tests/storage_maps/data/haproxy.cfg

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ defaults
2727
timeout check 10s
2828
maxconn 3000
2929

30+
frontend test_empty_storage_map
31+
use_backend %[str(active),map(/etc/haproxy/maps/mapfile_empty.map)]
32+
3033
frontend test_storage_maps
3134
bind *:1337 crt
3235
#use_backend %[str(active),map(/etc/haproxy/maps/mapfile_example2.map)]
@@ -36,4 +39,3 @@ frontend test_storage_maps
3639

3740
backend test_storage_maps
3841
server appx 127.0.0.1:8080 check disabled
39-

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ require (
2222
github.com/go-openapi/validate v0.19.8
2323
github.com/google/renameio v1.0.1
2424
github.com/google/uuid v1.2.0
25-
github.com/haproxytech/client-native/v3 v3.0.1-0.20220222090357-2740eb3ce4af
25+
github.com/haproxytech/client-native/v3 v3.0.1-0.20220224080929-9b9f1db2e019
2626
github.com/haproxytech/config-parser/v4 v4.0.0-rc2.0.20220215134434-54d66ef01d26
2727
github.com/hashicorp/consul/api v1.6.0
2828
github.com/hashicorp/hcl v1.0.0

go.sum

+2-4
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,8 @@ github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
174174
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
175175
github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs=
176176
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
177-
github.com/haproxytech/client-native/v3 v3.0.0 h1:D3bx4ylnkKfRqDVFk15ZLcMyKVTgdgNN25NKAjb6LYo=
178-
github.com/haproxytech/client-native/v3 v3.0.0/go.mod h1:5qDnA7M1HmgJ/CTy6ByUomvnfgAgpH6R8NYZMdcMQ9k=
179-
github.com/haproxytech/client-native/v3 v3.0.1-0.20220222090357-2740eb3ce4af h1:qauLnPmqH9RBY9iTsdLYQ2NUdsIH7DbTLvZEW+diWXE=
180-
github.com/haproxytech/client-native/v3 v3.0.1-0.20220222090357-2740eb3ce4af/go.mod h1:5qDnA7M1HmgJ/CTy6ByUomvnfgAgpH6R8NYZMdcMQ9k=
177+
github.com/haproxytech/client-native/v3 v3.0.1-0.20220224080929-9b9f1db2e019 h1:vZOIEJEA+NOA9W63T0jvRACbzoOE8wwar4nvWHsenQk=
178+
github.com/haproxytech/client-native/v3 v3.0.1-0.20220224080929-9b9f1db2e019/go.mod h1:5qDnA7M1HmgJ/CTy6ByUomvnfgAgpH6R8NYZMdcMQ9k=
181179
github.com/haproxytech/config-parser/v4 v4.0.0-rc2.0.20220215134434-54d66ef01d26 h1:IWU3pWA4MzYzi0N5NDUgMf06V6bmXCsHok0hBMM1Zik=
182180
github.com/haproxytech/config-parser/v4 v4.0.0-rc2.0.20220215134434-54d66ef01d26/go.mod h1:pEuHx+aFhn0lIdvAg1OaawQfeRkpq1I8HzjtZN4/PLI=
183181
github.com/haproxytech/go-logger v1.0.1-0.20211022075555-178f1cdf4d84 h1:rSLHjJ4VGvMZcGAGQ9GaXuhvdswu1iLVXTThLX6OKN8=

0 commit comments

Comments
 (0)