mirror of https://github.com/status-im/consul.git
[NET-6420] Add MeshConfiguration Controller stub (#19745)
* Add meshconfiguration/controller * Add MeshConfiguration Registration function * Fix the TODOs on the RegisterMeshGateway function * Call RegisterMeshConfiguration * Add comment to MeshConfigurationRegistration * Add a test for Reconcile and some comments
This commit is contained in:
parent
5107764115
commit
419677cc9e
|
@ -34,6 +34,7 @@ flowchart TD
|
|||
mesh/v2beta1/destinations
|
||||
mesh/v2beta1/grpcroute
|
||||
mesh/v2beta1/httproute
|
||||
mesh/v2beta1/meshconfiguration
|
||||
mesh/v2beta1/meshgateway
|
||||
mesh/v2beta1/proxyconfiguration
|
||||
mesh/v2beta1/proxystatetemplate --> auth/v2beta1/computedtrafficpermissions
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
package meshconfiguration
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/hashicorp/consul/internal/controller"
|
||||
pbmesh "github.com/hashicorp/consul/proto-public/pbmesh/v2beta1"
|
||||
)
|
||||
|
||||
// Controller instantiates a new Controller for managing MeshConfiguration resources.
|
||||
func Controller() controller.Controller {
|
||||
r := &reconciler{}
|
||||
|
||||
return controller.ForType(pbmesh.MeshConfigurationType).WithReconciler(r)
|
||||
}
|
||||
|
||||
// reconciler implements the Reconciler interface to modify runtime state based
|
||||
// on requests passed into it.
|
||||
type reconciler struct{}
|
||||
|
||||
// Reconcile takes in the current controller request and updates the runtime state based on
|
||||
// the request received.
|
||||
func (r *reconciler) Reconcile(ctx context.Context, rt controller.Runtime, req controller.Request) error {
|
||||
return errors.New("not implemented")
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
package meshconfiguration
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/hashicorp/consul/internal/controller"
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestReconciliation ensures that the Reconcile method for the Controller
|
||||
// correctly updates the runtime state based on the given request.
|
||||
func TestReconcile(t *testing.T) {
|
||||
// This test should be continually updated as we build out the MeshConfiguration controller.
|
||||
// At time of writing, it simply returns a not-implemented error.
|
||||
|
||||
ctx := context.Background()
|
||||
rt := controller.Runtime{
|
||||
Client: nil,
|
||||
Logger: nil,
|
||||
}
|
||||
req := controller.Request{}
|
||||
|
||||
rec := reconciler{}
|
||||
|
||||
err := rec.Reconcile(ctx, rt, req)
|
||||
require.Error(t, err)
|
||||
}
|
|
@ -5,6 +5,7 @@ package controllers
|
|||
|
||||
import (
|
||||
"context"
|
||||
"github.com/hashicorp/consul/internal/mesh/internal/controllers/meshconfiguration"
|
||||
|
||||
"github.com/hashicorp/consul/agent/leafcert"
|
||||
"github.com/hashicorp/consul/internal/controller"
|
||||
|
@ -51,4 +52,5 @@ func Register(mgr *controller.Manager, deps Dependencies) {
|
|||
mgr.Register(explicitdestinations.Controller(mapper.New()))
|
||||
|
||||
mgr.Register(meshgateways.Controller())
|
||||
mgr.Register(meshconfiguration.Controller())
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
package types
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/consul/internal/resource"
|
||||
pbmesh "github.com/hashicorp/consul/proto-public/pbmesh/v2beta1"
|
||||
)
|
||||
|
||||
// RegisterMeshConfiguration takes the resource registry and registers
|
||||
// the MeshConfiguration resource to it.
|
||||
func RegisterMeshConfiguration(r resource.Registry) {
|
||||
r.Register(resource.Registration{
|
||||
Type: pbmesh.MeshConfigurationType,
|
||||
Proto: &pbmesh.MeshConfiguration{},
|
||||
Scope: resource.ScopePartition,
|
||||
ACLs: nil, // TODO NET-6423
|
||||
Mutate: nil, // TODO NET-6425
|
||||
Validate: nil, // TODO NET-6424
|
||||
})
|
||||
}
|
|
@ -13,8 +13,8 @@ func RegisterMeshGateway(r resource.Registry) {
|
|||
Type: pbmesh.MeshGatewayType,
|
||||
Proto: &pbmesh.MeshGateway{},
|
||||
Scope: resource.ScopePartition,
|
||||
ACLs: nil, // TODO NET-6423
|
||||
Mutate: nil, // TODO NET-6425
|
||||
Validate: nil, // TODO NET-6424
|
||||
ACLs: nil, // TODO NET-6416
|
||||
Mutate: nil, // TODO NET-6418
|
||||
Validate: nil, // TODO NET-6417
|
||||
})
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ func Register(r resource.Registry) {
|
|||
RegisterDestinationPolicy(r)
|
||||
RegisterComputedRoutes(r)
|
||||
RegisterMeshGateway(r)
|
||||
RegisterMeshConfiguration(r)
|
||||
// todo (v2): uncomment once we implement it.
|
||||
//RegisterDestinationsConfiguration(r)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue