-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
control-plane/controllers/resources/api-gateway-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,43 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package resources | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/go-logr/logr" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/types" | ||
ctrl "sigs.k8s.io/controller-runtime" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
|
||
meshv2beta1 "github.com/hashicorp/consul-k8s/control-plane/api/mesh/v2beta1" | ||
) | ||
|
||
// APIGatewayController reconciles a APIGateway object. | ||
type APIGatewayController struct { | ||
client.Client | ||
Log logr.Logger | ||
Scheme *runtime.Scheme | ||
Controller *ConsulResourceController | ||
} | ||
|
||
// +kubebuilder:rbac:groups=mesh.consul.hashicorp.com,resources=tcproute,verbs=get;list;watch;create;update;patch;delete | ||
// +kubebuilder:rbac:groups=mesh.consul.hashicorp.com,resources=tcproute/status,verbs=get;update;patch | ||
|
||
func (r *APIGatewayController) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
return r.Controller.ReconcileResource(ctx, r, req, &meshv2beta1.APIGateway{}) | ||
} | ||
|
||
func (r *APIGatewayController) Logger(name types.NamespacedName) logr.Logger { | ||
return r.Log.WithValues("request", name) | ||
} | ||
|
||
func (r *APIGatewayController) UpdateStatus(ctx context.Context, obj client.Object, opts ...client.SubResourceUpdateOption) error { | ||
return r.Status().Update(ctx, obj, opts...) | ||
} | ||
|
||
func (r *APIGatewayController) SetupWithManager(mgr ctrl.Manager) error { | ||
return setupWithManager(mgr, &meshv2beta1.APIGateway{}, r) | ||
} |