-
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.
[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
- Loading branch information
Thomas Eckert
authored
Nov 28, 2023
1 parent
5107764
commit 419677c
Showing
7 changed files
with
88 additions
and
3 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
29 changes: 29 additions & 0 deletions
29
internal/mesh/internal/controllers/meshconfiguration/controller.go
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,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") | ||
} |
30 changes: 30 additions & 0 deletions
30
internal/mesh/internal/controllers/meshconfiguration/controller_test.go
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,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) | ||
} |
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,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 | ||
}) | ||
} |
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