Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion acceptance/tests/api-gateway/api_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

const (
StaticClientName = "static-client"
gatewayClassControllerName = "hashicorp.com/consul-api-gateway-controller"
gatewayClassControllerName = "consul.hashicorp.com/gateway-controller"
gatewayClassFinalizer = "gateway-exists-finalizer.consul.hashicorp.com"
gatewayFinalizer = "gateway-finalizer.consul.hashicorp.com"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ kind: GatewayClass
metadata:
name: gateway-class
spec:
controllerName: "hashicorp.com/consul-api-gateway-controller"
controllerName: "consul.hashicorp.com/gateway-controller"
parametersRef:
group: consul.hashicorp.com
kind: GatewayClassConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ kind: Gateway
metadata:
name: gateway
spec:
gatewayClassName: consul-api-gateway
gatewayClassName: consul
listeners:
- protocol: HTTPS
port: 8080
Expand All @@ -17,4 +17,4 @@ spec:
namespace: "default"
allowedRoutes:
namespaces:
from: "All"
from: "All"
2 changes: 1 addition & 1 deletion charts/consul/templates/gateway-cleanup-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ spec:
- consul-k8s-control-plane
args:
- gateway-cleanup
- -gateway-class-name=consul-api-gateway
- -gateway-class-name=consul
- -gateway-class-config-name=consul-api-gateway
resources:
requests:
Expand Down
4 changes: 2 additions & 2 deletions charts/consul/templates/gateway-resources-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ spec:
- consul-k8s-control-plane
args:
- gateway-resources
- -gateway-class-name=consul-api-gateway
- -gateway-class-name=consul
- -gateway-class-config-name=consul-api-gateway
- -controller-name=hashicorp.com/consul-api-gateway-controller
- -controller-name=consul.hashicorp.com/gateway-controller
- -app={{template "consul.name" .}}
- -chart={{template "consul.chart" .}}
- -heritage={{ .Release.Service }}
Expand Down
2 changes: 2 additions & 0 deletions control-plane/api-gateway/common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
package common

const (
GatewayClassControllerName = "consul.hashicorp.com/gateway-controller"

AnnotationGatewayClassConfig = "consul.hashicorp.com/gateway-class-config"
)
13 changes: 7 additions & 6 deletions control-plane/api-gateway/controllers/gateway_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ type GatewayControllerConfig struct {
// GatewayController reconciles a Gateway object.
// The Gateway is responsible for defining the behavior of API gateways.
type GatewayController struct {
HelmConfig common.HelmConfig
Log logr.Logger
Translator common.ResourceTranslator
HelmConfig common.HelmConfig
Log logr.Logger
Translator common.ResourceTranslator

cache *cache.Cache
gatewayCache *cache.GatewayCache
allowK8sNamespacesSet mapset.Set
Expand Down Expand Up @@ -174,7 +175,7 @@ func (r *GatewayController) Reconcile(ctx context.Context, req ctrl.Request) (ct
binder := binding.NewBinder(binding.BinderConfig{
Logger: log,
Translator: r.Translator,
ControllerName: GatewayClassControllerName,
ControllerName: common.GatewayClassControllerName,
Namespaces: namespaces,
GatewayClassConfig: gatewayClassConfig,
GatewayClass: gatewayClass,
Expand Down Expand Up @@ -786,7 +787,7 @@ func (c *GatewayController) getConfigForGatewayClass(ctx context.Context, gatewa
if ref := gatewayClassConfig.Spec.ParametersRef; ref != nil {
if string(ref.Group) != v1alpha1.GroupVersion.Group ||
ref.Kind != v1alpha1.GatewayClassConfigKind ||
gatewayClassConfig.Spec.ControllerName != GatewayClassControllerName {
gatewayClassConfig.Spec.ControllerName != common.GatewayClassControllerName {
// we don't have supported params, so return nil
return nil, nil
}
Expand All @@ -813,7 +814,7 @@ func (c *GatewayController) fetchControlledGateways(ctx context.Context, resourc

list := gwv1beta1.GatewayClassList{}
if err := c.Client.List(ctx, &list, &client.ListOptions{
FieldSelector: fields.OneTermEqualSelector(GatewayClass_ControllerNameIndex, GatewayClassControllerName),
FieldSelector: fields.OneTermEqualSelector(GatewayClass_ControllerNameIndex, common.GatewayClassControllerName),
}); err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (
)

const (
GatewayClassControllerName = "hashicorp.com/consul-api-gateway-controller"

gatewayClassFinalizer = "gateway-exists-finalizer.consul.hashicorp.com"

// GatewayClass status fields.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"sigs.k8s.io/gateway-api/apis/v1beta1"
gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"

"github.com/hashicorp/consul-k8s/control-plane/api-gateway/common"
"github.com/hashicorp/consul-k8s/control-plane/api/v1alpha1"
)

Expand Down Expand Up @@ -57,7 +58,7 @@ func TestGatewayClassReconciler(t *testing.T) {
Finalizers: []string{gatewayClassFinalizer},
},
Spec: gwv1beta1.GatewayClassSpec{
ControllerName: GatewayClassControllerName,
ControllerName: common.GatewayClassControllerName,
},
},
expectedResult: ctrl.Result{},
Expand All @@ -81,7 +82,7 @@ func TestGatewayClassReconciler(t *testing.T) {
Finalizers: []string{},
},
Spec: gwv1beta1.GatewayClassSpec{
ControllerName: GatewayClassControllerName,
ControllerName: common.GatewayClassControllerName,
},
},
expectedResult: ctrl.Result{},
Expand Down Expand Up @@ -127,7 +128,7 @@ func TestGatewayClassReconciler(t *testing.T) {
Finalizers: []string{gatewayClassFinalizer},
},
Spec: gwv1beta1.GatewayClassSpec{
ControllerName: GatewayClassControllerName,
ControllerName: common.GatewayClassControllerName,
ParametersRef: &gwv1beta1.ParametersReference{
Kind: "some-nonsense",
},
Expand All @@ -153,7 +154,7 @@ func TestGatewayClassReconciler(t *testing.T) {
Finalizers: []string{gatewayClassFinalizer},
},
Spec: gwv1beta1.GatewayClassSpec{
ControllerName: GatewayClassControllerName,
ControllerName: common.GatewayClassControllerName,
ParametersRef: &gwv1beta1.ParametersReference{
Kind: v1alpha1.GatewayClassConfigKind,
Name: "does-not-exist",
Expand Down Expand Up @@ -189,7 +190,7 @@ func TestGatewayClassReconciler(t *testing.T) {
DeletionTimestamp: &deletionTimestamp,
},
Spec: gwv1beta1.GatewayClassSpec{
ControllerName: GatewayClassControllerName,
ControllerName: common.GatewayClassControllerName,
},
},
expectedResult: ctrl.Result{},
Expand All @@ -208,7 +209,7 @@ func TestGatewayClassReconciler(t *testing.T) {
DeletionTimestamp: &deletionTimestamp,
},
Spec: gwv1beta1.GatewayClassSpec{
ControllerName: GatewayClassControllerName,
ControllerName: common.GatewayClassControllerName,
},
},
k8sObjects: []runtime.Object{
Expand Down Expand Up @@ -246,7 +247,7 @@ func TestGatewayClassReconciler(t *testing.T) {

r := &GatewayClassController{
Client: fakeClient,
ControllerName: GatewayClassControllerName,
ControllerName: common.GatewayClassControllerName,
Log: logrtest.New(t),
}
result, err := r.Reconcile(context.Background(), req)
Expand Down
2 changes: 1 addition & 1 deletion control-plane/subcommand/inject-connect/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ func (c *Command) Run(args []string) int {
}

if err := (&gatewaycontrollers.GatewayClassController{
ControllerName: gatewaycontrollers.GatewayClassControllerName,
ControllerName: gatewaycommon.GatewayClassControllerName,
Comment thread
t-eckert marked this conversation as resolved.
Client: mgr.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("GatewayClass"),
}).SetupWithManager(ctx, mgr); err != nil {
Expand Down