Skip to content

Commit

Permalink
Allow targetgroup policy attached to serviceExport (#622)
Browse files Browse the repository at this point in the history
  • Loading branch information
liwenwu-amazon authored Apr 19, 2024
1 parent 70c9054 commit 086bcb0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pkg/k8s/policyhelper/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"

anv1alpha1 "github.com/aws/aws-application-networking-k8s/pkg/apis/applicationnetworking/v1alpha1"
)

type GroupKind struct {
Expand All @@ -20,6 +22,8 @@ func ObjToGroupKind(obj client.Object) GroupKind {
return GroupKind{gwv1beta1.GroupName, "HTTPRoute"}
case *gwv1alpha2.GRPCRoute:
return GroupKind{gwv1alpha2.GroupName, "GRPCRoute"}
case *anv1alpha1.ServiceExport:
return GroupKind{anv1alpha1.GroupName, "ServiceExport"}
case *corev1.Service:
return GroupKind{corev1.GroupName, "Service"}
default:
Expand All @@ -44,6 +48,8 @@ func GroupKindToObj(gk GroupKind) (client.Object, bool) {
return &gwv1alpha2.GRPCRoute{}, true
case GroupKind{corev1.GroupName, "Service"}:
return &corev1.Service{}, true
case GroupKind{anv1alpha1.GroupName, "ServiceExport"}:
return &anv1alpha1.ServiceExport{}, true
default:
return nil, false
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/k8s/policyhelper/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func NewTargetGroupPolicyHandler(log gwlog.Logger, c k8sclient.Client) *PolicyHa
phcfg := PolicyHandlerConfig{
Log: log,
Client: c,
TargetRefKinds: NewGroupKindSet(&corev1.Service{}),
TargetRefKinds: NewGroupKindSet(&corev1.Service{}, &anv1alpha1.ServiceExport{}),
}
return NewPolicyHandler[TGP, TGPL](phcfg)
}
Expand Down

0 comments on commit 086bcb0

Please sign in to comment.