-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mapper.policyToTargetRefObj() helper function (#398)
* - Add resourceMapper.VpcAssociationPolicyToGateway() method - Add vpcAssociationPolicyEventHandler.MapToGateway() method - Make gateway_controller optionally watches the `VpcAssociationPolicy` * address comments * address PR comments --------- Co-authored-by: Zijun Wang <[email protected]>
- Loading branch information
1 parent
2385943
commit 3f89fd8
Showing
7 changed files
with
265 additions
and
59 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
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
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,35 @@ | ||
package eventhandlers | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/aws/aws-application-networking-k8s/pkg/apis/applicationnetworking/v1alpha1" | ||
"github.com/aws/aws-application-networking-k8s/pkg/k8s" | ||
"github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" | ||
|
||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
"sigs.k8s.io/controller-runtime/pkg/handler" | ||
"sigs.k8s.io/controller-runtime/pkg/reconcile" | ||
) | ||
|
||
type vpcAssociationPolicyEventHandler struct { | ||
log gwlog.Logger | ||
client client.Client | ||
mapper *resourceMapper | ||
} | ||
|
||
func NewVpcAssociationPolicyEventHandler(log gwlog.Logger, client client.Client) *vpcAssociationPolicyEventHandler { | ||
return &vpcAssociationPolicyEventHandler{log: log, client: client, | ||
mapper: &resourceMapper{log: log, client: client}} | ||
} | ||
|
||
func (h *vpcAssociationPolicyEventHandler) MapToGateway() handler.EventHandler { | ||
return handler.EnqueueRequestsFromMapFunc(func(obj client.Object) []reconcile.Request { | ||
if vap, ok := obj.(*v1alpha1.VpcAssociationPolicy); ok { | ||
if gw := h.mapper.VpcAssociationPolicyToGateway(context.Background(), vap); gw != nil { | ||
return []reconcile.Request{{NamespacedName: k8s.NamespacedName(gw)}} | ||
} | ||
} | ||
return nil | ||
}) | ||
} |
Oops, something went wrong.