-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Native API Gateway Config Entries (#15897)
* Stub Config Entries for Consul Native API Gateway (#15644) * Add empty InlineCertificate struct and protobuf * apigateway stubs * Stub HTTPRoute in api pkg * Stub HTTPRoute in structs pkg * Simplify api.APIGatewayConfigEntry to be consistent w/ other entries * Update makeConfigEntry switch, add docstring for HTTPRouteConfigEntry * Add TCPRoute to MakeConfigEntry, return unique Kind * Stub BoundAPIGatewayConfigEntry in agent * Add RaftIndex to APIGatewayConfigEntry stub * Add new config entry kinds to validation allow-list * Add RaftIndex to other added config entry stubs * Update usage metrics assertions to include new cfg entries * Add Meta and acl.EnterpriseMeta to all new ConfigEntry types * Remove unnecessary Services field from added config entry types * Implement GetMeta(), GetEnterpriseMeta() for added config entry types * Add meta field to proto, name consistently w/ existing config entries * Format config_entry.proto * Add initial implementation of CanRead + CanWrite for new config entry types * Add unit tests for decoding of new config entry types * Add unit tests for parsing of new config entry types * Add unit tests for API Gateway config entry ACLs * Return typed PermissionDeniedError on BoundAPIGateway CanWrite * Add unit tests for added config entry ACLs * Add BoundAPIGateway type to AllConfigEntryKinds * Return proper kind from BoundAPIGateway * Add docstrings for new config entry types * Add missing config entry kinds to proto def * Update usagemetrics_oss_test.go * Use utility func for returning PermissionDeniedError * EventPublisher subscriptions for Consul Native API Gateway (#15757) * Create new event topics in subscribe proto * Add tests for PBSubscribe func * Make configs singular, add all configs to PBToStreamSubscribeRequest * Add snapshot methods * Add config_entry_events tests * Add config entry kind to topic for new configs * Add unit tests for snapshot methods * Start adding integration test * Test using the new controller code * Update agent/consul/state/config_entry_events.go * Check value of error * Add controller stubs for API Gateway (#15837) * update initial stub implementation * move files, clean up mutex references * Remove embed, use idiomatic names for constructors * Remove stray file introduced in merge * Add APIGateway validation (#15847) * Add APIGateway validation * Add additional validations * Add cert ref validation * Add protobuf definitions * Fix up field types * Add API structs * Move struct fields around a bit * APIGateway InlineCertificate validation (#15856) * Add APIGateway validation * Add additional validations * Add protobuf definitions * Tabs to spaces * Add API structs * Move struct fields around a bit * Add validation for InlineCertificate * Fix ACL test * APIGateway BoundAPIGateway validation (#15858) * Add APIGateway validation * Add additional validations * Add cert ref validation * Add protobuf definitions * Fix up field types * Add API structs * Move struct fields around a bit * Add validation for BoundAPIGateway * APIGateway TCPRoute validation (#15855) * Add APIGateway validation * Add additional validations * Add cert ref validation * Add protobuf definitions * Fix up field types * Add API structs * Add TCPRoute normalization and validation * Add forgotten Status * Add some more field docs in api package * Fix test * Format imports * Rename snapshot test variable names * Add plumbing for Native API GW Subscriptions (#16003) Co-authored-by: Sarah Alsmiller <[email protected]> Co-authored-by: Nathan Coleman <[email protected]> Co-authored-by: sarahalsmiller <[email protected]> Co-authored-by: Andrew Stucki <[email protected]>
- Loading branch information
1 parent
4e15414
commit 13da1a5
Showing
37 changed files
with
5,711 additions
and
452 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package gateways | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hashicorp/go-hclog" | ||
|
||
"github.com/hashicorp/consul/agent/consul/controller" | ||
"github.com/hashicorp/consul/agent/consul/fsm" | ||
"github.com/hashicorp/consul/agent/consul/state" | ||
"github.com/hashicorp/consul/agent/consul/stream" | ||
) | ||
|
||
type apiGatewayReconciler struct { | ||
fsm *fsm.FSM | ||
logger hclog.Logger | ||
} | ||
|
||
func (r apiGatewayReconciler) Reconcile(ctx context.Context, req controller.Request) error { | ||
return nil | ||
} | ||
|
||
func NewAPIGatewayController(fsm *fsm.FSM, publisher state.EventPublisher, logger hclog.Logger) controller.Controller { | ||
reconciler := apiGatewayReconciler{ | ||
fsm: fsm, | ||
logger: logger, | ||
} | ||
return controller.New(publisher, reconciler).Subscribe( | ||
&stream.SubscribeRequest{ | ||
Topic: state.EventTopicAPIGateway, | ||
Subject: stream.SubjectWildcard, | ||
}, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package gateways | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hashicorp/go-hclog" | ||
|
||
"github.com/hashicorp/consul/agent/consul/controller" | ||
"github.com/hashicorp/consul/agent/consul/fsm" | ||
"github.com/hashicorp/consul/agent/consul/state" | ||
"github.com/hashicorp/consul/agent/consul/stream" | ||
) | ||
|
||
type tcpRouteReconciler struct { | ||
fsm *fsm.FSM | ||
logger hclog.Logger | ||
} | ||
|
||
func (r tcpRouteReconciler) Reconcile(ctx context.Context, req controller.Request) error { | ||
return nil | ||
} | ||
|
||
func NewTCPRouteController(fsm *fsm.FSM, publisher state.EventPublisher, logger hclog.Logger) controller.Controller { | ||
reconciler := tcpRouteReconciler{ | ||
fsm: fsm, | ||
logger: logger, | ||
} | ||
return controller.New(publisher, reconciler).Subscribe( | ||
&stream.SubscribeRequest{ | ||
Topic: state.EventTopicTCPRoute, | ||
Subject: stream.SubjectWildcard, | ||
}, | ||
) | ||
} | ||
|
||
type httpRouteReconciler struct { | ||
fsm *fsm.FSM | ||
logger hclog.Logger | ||
} | ||
|
||
func (r httpRouteReconciler) Reconcile(ctx context.Context, req controller.Request) error { | ||
return nil | ||
} | ||
|
||
func NewHTTPRouteController(fsm *fsm.FSM, publisher state.EventPublisher, logger hclog.Logger) controller.Controller { | ||
reconciler := httpRouteReconciler{ | ||
fsm: fsm, | ||
logger: logger, | ||
} | ||
return controller.New(publisher, reconciler).Subscribe( | ||
&stream.SubscribeRequest{ | ||
Topic: state.EventTopicHTTPRoute, | ||
Subject: stream.SubjectWildcard, | ||
}, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.