Skip to content

Commit e2389be

Browse files
committed
MEDIUM: API consolidation- add PUT on index based lists and remove index in objects
This MR adds a PUT on all index based lists in order to allow to replace all elements at once. It also removes the index that were in objects definition and adds the index to the URL. This will change for POST one element that was before POST /acls and is now POST /acls/{index}. The list based have now: - POST /list_based with the body having a list of objects. They will be inserted in the same order as sent in the list. Also: MINOR: remove log_message in tcp_check and use only check_comment
1 parent 25676bc commit e2389be

File tree

300 files changed

+18666
-2190
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

300 files changed

+18666
-2190
lines changed

configure_data_plane.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,104 +415,119 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler { //nolint:cyclop,m
415415
api.HTTPCheckCreateHTTPCheckHandler = &handlers.CreateHTTPCheckHandlerImpl{Client: client, ReloadAgent: ra}
416416
api.HTTPCheckReplaceHTTPCheckHandler = &handlers.ReplaceHTTPCheckHandlerImpl{Client: client, ReloadAgent: ra}
417417
api.HTTPCheckDeleteHTTPCheckHandler = &handlers.DeleteHTTPCheckHandlerImpl{Client: client, ReloadAgent: ra}
418+
api.HTTPCheckReplaceHTTPChecksHandler = &handlers.ReplaceHTTPChecksHandlerImpl{Client: client, ReloadAgent: ra}
418419

419420
// setup http request rule handlers
420421
api.HTTPRequestRuleCreateHTTPRequestRuleHandler = &handlers.CreateHTTPRequestRuleHandlerImpl{Client: client, ReloadAgent: ra}
421422
api.HTTPRequestRuleDeleteHTTPRequestRuleHandler = &handlers.DeleteHTTPRequestRuleHandlerImpl{Client: client, ReloadAgent: ra}
422423
api.HTTPRequestRuleGetHTTPRequestRuleHandler = &handlers.GetHTTPRequestRuleHandlerImpl{Client: client}
423424
api.HTTPRequestRuleGetHTTPRequestRulesHandler = &handlers.GetHTTPRequestRulesHandlerImpl{Client: client}
424425
api.HTTPRequestRuleReplaceHTTPRequestRuleHandler = &handlers.ReplaceHTTPRequestRuleHandlerImpl{Client: client, ReloadAgent: ra}
426+
api.HTTPRequestRuleReplaceHTTPRequestRulesHandler = &handlers.ReplaceHTTPRequestRulesHandlerImpl{Client: client, ReloadAgent: ra}
425427

426428
// setup http after response rule handlers
427429
api.HTTPAfterResponseRuleCreateHTTPAfterResponseRuleHandler = &handlers.CreateHTTPAfterResponseRuleHandlerImpl{Client: client, ReloadAgent: ra}
428430
api.HTTPAfterResponseRuleDeleteHTTPAfterResponseRuleHandler = &handlers.DeleteHTTPAfterResponseRuleHandlerImpl{Client: client, ReloadAgent: ra}
429431
api.HTTPAfterResponseRuleGetHTTPAfterResponseRuleHandler = &handlers.GetHTTPAfterResponseRuleHandlerImpl{Client: client}
430432
api.HTTPAfterResponseRuleGetHTTPAfterResponseRulesHandler = &handlers.GetHTTPAfterResponseRulesHandlerImpl{Client: client}
431433
api.HTTPAfterResponseRuleReplaceHTTPAfterResponseRuleHandler = &handlers.ReplaceHTTPAfterResponseRuleHandlerImpl{Client: client, ReloadAgent: ra}
434+
api.HTTPAfterResponseRuleReplaceHTTPAfterResponseRulesHandler = &handlers.ReplaceHTTPAfterResponseRulesHandlerImpl{Client: client, ReloadAgent: ra}
432435

433436
// setup http response rule handlers
434437
api.HTTPResponseRuleCreateHTTPResponseRuleHandler = &handlers.CreateHTTPResponseRuleHandlerImpl{Client: client, ReloadAgent: ra}
435438
api.HTTPResponseRuleDeleteHTTPResponseRuleHandler = &handlers.DeleteHTTPResponseRuleHandlerImpl{Client: client, ReloadAgent: ra}
436439
api.HTTPResponseRuleGetHTTPResponseRuleHandler = &handlers.GetHTTPResponseRuleHandlerImpl{Client: client}
437440
api.HTTPResponseRuleGetHTTPResponseRulesHandler = &handlers.GetHTTPResponseRulesHandlerImpl{Client: client}
438441
api.HTTPResponseRuleReplaceHTTPResponseRuleHandler = &handlers.ReplaceHTTPResponseRuleHandlerImpl{Client: client, ReloadAgent: ra}
442+
api.HTTPResponseRuleReplaceHTTPResponseRulesHandler = &handlers.ReplaceHTTPResponseRulesHandlerImpl{Client: client, ReloadAgent: ra}
439443

440444
// setup http error rule handlers
441445
api.HTTPErrorRuleCreateHTTPErrorRuleHandler = &handlers.CreateHTTPErrorRuleHandlerImpl{Client: client, ReloadAgent: ra}
442446
api.HTTPErrorRuleDeleteHTTPErrorRuleHandler = &handlers.DeleteHTTPErrorRuleHandlerImpl{Client: client, ReloadAgent: ra}
443447
api.HTTPErrorRuleGetHTTPErrorRuleHandler = &handlers.GetHTTPErrorRuleHandlerImpl{Client: client}
444448
api.HTTPErrorRuleGetHTTPErrorRulesHandler = &handlers.GetHTTPErrorRulesHandlerImpl{Client: client}
445449
api.HTTPErrorRuleReplaceHTTPErrorRuleHandler = &handlers.ReplaceHTTPErrorRuleHandlerImpl{Client: client, ReloadAgent: ra}
450+
api.HTTPErrorRuleReplaceHTTPErrorRulesHandler = &handlers.ReplaceHTTPErrorRulesHandlerImpl{Client: client, ReloadAgent: ra}
446451

447452
// setup tcp content rule handlers
448453
api.TCPRequestRuleCreateTCPRequestRuleHandler = &handlers.CreateTCPRequestRuleHandlerImpl{Client: client, ReloadAgent: ra}
449454
api.TCPRequestRuleDeleteTCPRequestRuleHandler = &handlers.DeleteTCPRequestRuleHandlerImpl{Client: client, ReloadAgent: ra}
450455
api.TCPRequestRuleGetTCPRequestRuleHandler = &handlers.GetTCPRequestRuleHandlerImpl{Client: client}
451456
api.TCPRequestRuleGetTCPRequestRulesHandler = &handlers.GetTCPRequestRulesHandlerImpl{Client: client}
452457
api.TCPRequestRuleReplaceTCPRequestRuleHandler = &handlers.ReplaceTCPRequestRuleHandlerImpl{Client: client, ReloadAgent: ra}
458+
api.TCPRequestRuleReplaceTCPRequestRulesHandler = &handlers.ReplaceTCPRequestRulesHandlerImpl{Client: client, ReloadAgent: ra}
453459

454460
// setup tcp connection rule handlers
455461
api.TCPResponseRuleCreateTCPResponseRuleHandler = &handlers.CreateTCPResponseRuleHandlerImpl{Client: client, ReloadAgent: ra}
456462
api.TCPResponseRuleDeleteTCPResponseRuleHandler = &handlers.DeleteTCPResponseRuleHandlerImpl{Client: client, ReloadAgent: ra}
457463
api.TCPResponseRuleGetTCPResponseRuleHandler = &handlers.GetTCPResponseRuleHandlerImpl{Client: client}
458464
api.TCPResponseRuleGetTCPResponseRulesHandler = &handlers.GetTCPResponseRulesHandlerImpl{Client: client}
459465
api.TCPResponseRuleReplaceTCPResponseRuleHandler = &handlers.ReplaceTCPResponseRuleHandlerImpl{Client: client, ReloadAgent: ra}
466+
api.TCPResponseRuleReplaceTCPResponseRulesHandler = &handlers.ReplaceTCPResponseRulesHandlerImpl{Client: client, ReloadAgent: ra}
460467

461468
// setup tcp check handlers
462469
api.TCPCheckCreateTCPCheckHandler = &handlers.CreateTCPCheckHandlerImpl{Client: client, ReloadAgent: ra}
463470
api.TCPCheckDeleteTCPCheckHandler = &handlers.DeleteTCPCheckHandlerImpl{Client: client, ReloadAgent: ra}
464471
api.TCPCheckGetTCPCheckHandler = &handlers.GetTCPCheckHandlerImpl{Client: client}
465472
api.TCPCheckGetTCPChecksHandler = &handlers.GetTCPChecksHandlerImpl{Client: client}
466473
api.TCPCheckReplaceTCPCheckHandler = &handlers.ReplaceTCPCheckHandlerImpl{Client: client, ReloadAgent: ra}
474+
api.TCPCheckReplaceTCPChecksHandler = &handlers.ReplaceTCPChecksHandlerImpl{Client: client, ReloadAgent: ra}
467475

468476
// setup declare capture handlers
469477
api.DeclareCaptureCreateDeclareCaptureHandler = &handlers.CreateDeclareCaptureHandlerImpl{Client: client, ReloadAgent: ra}
470478
api.DeclareCaptureDeleteDeclareCaptureHandler = &handlers.DeleteDeclareCaptureHandlerImpl{Client: client, ReloadAgent: ra}
471479
api.DeclareCaptureGetDeclareCaptureHandler = &handlers.GetDeclareCaptureHandlerImpl{Client: client}
472480
api.DeclareCaptureGetDeclareCapturesHandler = &handlers.GetDeclareCapturesHandlerImpl{Client: client}
473481
api.DeclareCaptureReplaceDeclareCaptureHandler = &handlers.ReplaceDeclareCaptureHandlerImpl{Client: client, ReloadAgent: ra}
482+
api.DeclareCaptureReplaceDeclareCapturesHandler = &handlers.ReplaceDeclareCapturesHandlerImpl{Client: client, ReloadAgent: ra}
474483

475484
// setup backend switching rule handlers
476485
api.BackendSwitchingRuleCreateBackendSwitchingRuleHandler = &handlers.CreateBackendSwitchingRuleHandlerImpl{Client: client, ReloadAgent: ra}
477486
api.BackendSwitchingRuleDeleteBackendSwitchingRuleHandler = &handlers.DeleteBackendSwitchingRuleHandlerImpl{Client: client, ReloadAgent: ra}
478487
api.BackendSwitchingRuleGetBackendSwitchingRuleHandler = &handlers.GetBackendSwitchingRuleHandlerImpl{Client: client}
479488
api.BackendSwitchingRuleGetBackendSwitchingRulesHandler = &handlers.GetBackendSwitchingRulesHandlerImpl{Client: client}
480489
api.BackendSwitchingRuleReplaceBackendSwitchingRuleHandler = &handlers.ReplaceBackendSwitchingRuleHandlerImpl{Client: client, ReloadAgent: ra}
490+
api.BackendSwitchingRuleReplaceBackendSwitchingRulesHandler = &handlers.ReplaceBackendSwitchingRulesHandlerImpl{Client: client, ReloadAgent: ra}
481491

482492
// setup server switching rule handlers
483493
api.ServerSwitchingRuleCreateServerSwitchingRuleHandler = &handlers.CreateServerSwitchingRuleHandlerImpl{Client: client, ReloadAgent: ra}
484494
api.ServerSwitchingRuleDeleteServerSwitchingRuleHandler = &handlers.DeleteServerSwitchingRuleHandlerImpl{Client: client, ReloadAgent: ra}
485495
api.ServerSwitchingRuleGetServerSwitchingRuleHandler = &handlers.GetServerSwitchingRuleHandlerImpl{Client: client}
486496
api.ServerSwitchingRuleGetServerSwitchingRulesHandler = &handlers.GetServerSwitchingRulesHandlerImpl{Client: client}
487497
api.ServerSwitchingRuleReplaceServerSwitchingRuleHandler = &handlers.ReplaceServerSwitchingRuleHandlerImpl{Client: client, ReloadAgent: ra}
498+
api.ServerSwitchingRuleReplaceServerSwitchingRulesHandler = &handlers.ReplaceServerSwitchingRulesHandlerImpl{Client: client, ReloadAgent: ra}
488499

489500
// setup filter handlers
490501
api.FilterCreateFilterHandler = &handlers.CreateFilterHandlerImpl{Client: client, ReloadAgent: ra}
491502
api.FilterDeleteFilterHandler = &handlers.DeleteFilterHandlerImpl{Client: client, ReloadAgent: ra}
492503
api.FilterGetFilterHandler = &handlers.GetFilterHandlerImpl{Client: client}
493504
api.FilterGetFiltersHandler = &handlers.GetFiltersHandlerImpl{Client: client}
494505
api.FilterReplaceFilterHandler = &handlers.ReplaceFilterHandlerImpl{Client: client, ReloadAgent: ra}
506+
api.FilterReplaceFiltersHandler = &handlers.ReplaceFiltersHandlerImpl{Client: client, ReloadAgent: ra}
495507

496508
// setup stick rule handlers
497509
api.StickRuleCreateStickRuleHandler = &handlers.CreateStickRuleHandlerImpl{Client: client, ReloadAgent: ra}
498510
api.StickRuleDeleteStickRuleHandler = &handlers.DeleteStickRuleHandlerImpl{Client: client, ReloadAgent: ra}
499511
api.StickRuleGetStickRuleHandler = &handlers.GetStickRuleHandlerImpl{Client: client}
500512
api.StickRuleGetStickRulesHandler = &handlers.GetStickRulesHandlerImpl{Client: client}
501513
api.StickRuleReplaceStickRuleHandler = &handlers.ReplaceStickRuleHandlerImpl{Client: client, ReloadAgent: ra}
514+
api.StickRuleReplaceStickRulesHandler = &handlers.ReplaceStickRulesHandlerImpl{Client: client, ReloadAgent: ra}
502515

503516
// setup log target handlers
504517
api.LogTargetCreateLogTargetHandler = &handlers.CreateLogTargetHandlerImpl{Client: client, ReloadAgent: ra}
505518
api.LogTargetDeleteLogTargetHandler = &handlers.DeleteLogTargetHandlerImpl{Client: client, ReloadAgent: ra}
506519
api.LogTargetGetLogTargetHandler = &handlers.GetLogTargetHandlerImpl{Client: client}
507520
api.LogTargetGetLogTargetsHandler = &handlers.GetLogTargetsHandlerImpl{Client: client}
508521
api.LogTargetReplaceLogTargetHandler = &handlers.ReplaceLogTargetHandlerImpl{Client: client, ReloadAgent: ra}
522+
api.LogTargetReplaceLogTargetsHandler = &handlers.ReplaceLogTargetsHandlerImpl{Client: client, ReloadAgent: ra}
509523

510524
// setup acl rule handlers
511525
api.ACLCreateACLHandler = &handlers.CreateACLHandlerImpl{Client: client, ReloadAgent: ra}
512526
api.ACLDeleteACLHandler = &handlers.DeleteACLHandlerImpl{Client: client, ReloadAgent: ra}
513527
api.ACLGetACLHandler = &handlers.GetACLHandlerImpl{Client: client}
514528
api.ACLGetAclsHandler = &handlers.GetAclsHandlerImpl{Client: client}
515529
api.ACLReplaceACLHandler = &handlers.ReplaceACLHandlerImpl{Client: client, ReloadAgent: ra}
530+
api.ACLReplaceAclsHandler = &handlers.ReplaceAclsHandlerImpl{Client: client, ReloadAgent: ra}
516531

517532
// setup resolvers handlers
518533
api.ResolverCreateResolverHandler = &handlers.CreateResolverHandlerImpl{Client: client, ReloadAgent: ra}

e2e/fixtures/haproxy.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ global
99
group haproxy
1010
stats socket /var/lib/haproxy/stats level admin
1111

12-
defaults
12+
defaults mydefaults
1313
mode http
1414
log global
1515
option httplog

e2e/tests/acl_files/data/haproxy.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# _version=1
2-
defaults
2+
defaults mydefaults
33
mode http
44
log global
55
option httplog

e2e/tests/acls/add.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ load '../../libs/resource_client'
2424
load 'utils/_helpers'
2525

2626
@test "acls: Add a new ACL" {
27-
resource_post "$_ACL_BASE_PATH" "data/post.json" "parent_name=fe_acl&parent_type=frontend"
27+
resource_post "$_ACL_BASE_PATH"/2 "data/post.json" "index=2&parent_name=fe_acl&parent_type=frontend"
2828
assert_equal "$SC" 202
2929
#
3030
# verify that ACL is actually added

e2e/tests/acls/data/haproxy.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# _version=60
2-
defaults
2+
defaults mydefaults
33
mode http
44
log global
55
option httplog

e2e/tests/acls/data/post.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"acl_name": "new_acl",
33
"criterion": "src_port",
4-
"index": 2,
54
"value": "0:1048"
65
}

e2e/tests/acls/data/put.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"acl_name": "put_acl",
33
"criterion": "src_port",
4-
"index": 2,
54
"value": "0:1122"
65
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[
2+
{
3+
"acl_name": "replace_0",
4+
"criterion": "src_port",
5+
"value": "0:1110"
6+
},
7+
{
8+
"acl_name": "replace_1",
9+
"criterion": "src_port",
10+
"value": "0:1111"
11+
},
12+
{
13+
"acl_name": "replace_2",
14+
"criterion": "src_port",
15+
"value": "0:1112"
16+
}
17+
]

e2e/tests/acls/get.bats

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ load 'utils/_helpers'
2929

3030
assert_equal "$(get_json_path "$BODY" " .acl_name")" "local_dst"
3131
assert_equal "$(get_json_path "$BODY" " .criterion")" "hdr(host)"
32-
assert_equal "$(get_json_path "$BODY" " .index")" "2"
3332
assert_equal "$(get_json_path "$BODY" " .value")" "-i localhost"
3433
}
3534

e2e/tests/acls/list.bats

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ load 'utils/_helpers'
2828

2929
assert_equal "$(get_json_path "$BODY" " . | .[2].acl_name" )" "local_dst"
3030
assert_equal "$(get_json_path "$BODY" " . | .[2].criterion" )" "hdr(host)"
31-
assert_equal "$(get_json_path "$BODY" " . | .[2].index" )" "2"
3231
assert_equal "$(get_json_path "$BODY" " . | .[2].value" )" "-i localhost"
3332
}
3433

@@ -38,6 +37,5 @@ load 'utils/_helpers'
3837

3938
assert_equal "$(get_json_path "$BODY" " . | .[1].acl_name" )" "invalid_src"
4039
assert_equal "$(get_json_path "$BODY" " . | .[1].criterion" )" "src_port"
41-
assert_equal "$(get_json_path "$BODY" " . | .[1].index" )" "1"
4240
assert_equal "$(get_json_path "$BODY" " . | .[1].value" )" "0:1023"
4341
}

0 commit comments

Comments
 (0)