-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: seperate event logger and topology reconciler into own files Signed-off-by: KevFan <chfan@redhat.com> * stow: placeholders for main workflow Signed-off-by: KevFan <chfan@redhat.com> * refactor: align with conventions for group kind and resource naming Signed-off-by: KevFan <chfan@redhat.com> * sotw: more placeholders and convention adjustments Signed-off-by: KevFan <chfan@redhat.com> --------- Signed-off-by: KevFan <chfan@redhat.com>
- Loading branch information
Showing
16 changed files
with
312 additions
and
144 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package controllers | ||
|
||
import "github.com/kuadrant/policy-machinery/controller" | ||
|
||
func NewAuthWorkflow() *controller.Workflow { | ||
return &controller.Workflow{} | ||
} |
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,7 @@ | ||
package controllers | ||
|
||
import "github.com/kuadrant/policy-machinery/controller" | ||
|
||
func NewDNSWorkflow() *controller.Workflow { | ||
return &controller.Workflow{} | ||
} |
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,18 @@ | ||
package controllers | ||
|
||
import ( | ||
"github.com/kuadrant/policy-machinery/controller" | ||
"k8s.io/client-go/dynamic" | ||
) | ||
|
||
type EnvoyGatewayJanitor struct { | ||
Client *dynamic.DynamicClient | ||
} | ||
|
||
func NewEnvoyGatewayJanitor(client *dynamic.DynamicClient) *EnvoyGatewayJanitor { | ||
return &EnvoyGatewayJanitor{Client: client} | ||
} | ||
|
||
func (r *EnvoyGatewayJanitor) Subscription() *controller.Subscription { | ||
return &controller.Subscription{} | ||
} |
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,42 @@ | ||
package controllers | ||
|
||
import ( | ||
"context" | ||
"sync" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
"github.com/kuadrant/policy-machinery/controller" | ||
"github.com/kuadrant/policy-machinery/machinery" | ||
) | ||
|
||
type EventLogger struct{} | ||
|
||
func NewEventLogger() *EventLogger { | ||
return &EventLogger{} | ||
} | ||
|
||
func (e *EventLogger) Log(ctx context.Context, resourceEvents []controller.ResourceEvent, _ *machinery.Topology, err error, _ *sync.Map) error { | ||
logger := controller.LoggerFromContext(ctx).WithName("event logger") | ||
for _, event := range resourceEvents { | ||
// log the event | ||
obj := event.OldObject | ||
if obj == nil { | ||
obj = event.NewObject | ||
} | ||
values := []any{ | ||
"type", event.EventType.String(), | ||
"kind", obj.GetObjectKind().GroupVersionKind().Kind, | ||
"namespace", obj.GetNamespace(), | ||
"name", obj.GetName(), | ||
} | ||
if event.EventType == controller.UpdateEvent && logger.V(1).Enabled() { | ||
values = append(values, "diff", cmp.Diff(event.OldObject, event.NewObject)) | ||
} | ||
logger.Info("new event", values...) | ||
if err != nil { | ||
logger.Error(err, "error passed to reconcile") | ||
} | ||
} | ||
|
||
return nil | ||
} |
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,18 @@ | ||
package controllers | ||
|
||
import ( | ||
"github.com/kuadrant/policy-machinery/controller" | ||
"k8s.io/client-go/dynamic" | ||
) | ||
|
||
type GatewayPolicyDiscoverabilityReconciler struct { | ||
Client *dynamic.DynamicClient | ||
} | ||
|
||
func NewGatewayPolicyDiscoverabilityReconciler(client *dynamic.DynamicClient) *GatewayPolicyDiscoverabilityReconciler { | ||
return &GatewayPolicyDiscoverabilityReconciler{Client: client} | ||
} | ||
|
||
func (r *GatewayPolicyDiscoverabilityReconciler) Subscription() *controller.Subscription { | ||
return &controller.Subscription{} | ||
} |
18 changes: 18 additions & 0 deletions
18
controllers/httproute_policy_discoverability_reconciler.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,18 @@ | ||
package controllers | ||
|
||
import ( | ||
"github.com/kuadrant/policy-machinery/controller" | ||
"k8s.io/client-go/dynamic" | ||
) | ||
|
||
type HTTPRoutePolicyDiscoverabilityReconciler struct { | ||
Client *dynamic.DynamicClient | ||
} | ||
|
||
func NewHTTPRoutePolicyDiscoverabilityReconciler(client *dynamic.DynamicClient) *HTTPRoutePolicyDiscoverabilityReconciler { | ||
return &HTTPRoutePolicyDiscoverabilityReconciler{Client: client} | ||
} | ||
|
||
func (r *HTTPRoutePolicyDiscoverabilityReconciler) Subscription() *controller.Subscription { | ||
return &controller.Subscription{} | ||
} |
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,18 @@ | ||
package controllers | ||
|
||
import ( | ||
"github.com/kuadrant/policy-machinery/controller" | ||
"k8s.io/client-go/dynamic" | ||
) | ||
|
||
type IstioExtensionsJanitor struct { | ||
Client *dynamic.DynamicClient | ||
} | ||
|
||
func NewIstioExtensionsJanitor(client *dynamic.DynamicClient) *IstioExtensionsJanitor { | ||
return &IstioExtensionsJanitor{Client: client} | ||
} | ||
|
||
func (r *IstioExtensionsJanitor) Subscription() *controller.Subscription { | ||
return &controller.Subscription{} | ||
} |
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,18 @@ | ||
package controllers | ||
|
||
import ( | ||
"github.com/kuadrant/policy-machinery/controller" | ||
"k8s.io/client-go/dynamic" | ||
) | ||
|
||
type LimitadorReconciler struct { | ||
Client *dynamic.DynamicClient | ||
} | ||
|
||
func NewLimitadorReconciler(client *dynamic.DynamicClient) *LimitadorReconciler { | ||
return &LimitadorReconciler{Client: client} | ||
} | ||
|
||
func (r *LimitadorReconciler) Subscription() *controller.Subscription { | ||
return &controller.Subscription{} | ||
} |
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,7 @@ | ||
package controllers | ||
|
||
import "github.com/kuadrant/policy-machinery/controller" | ||
|
||
func NewRateLimitWorkflow() *controller.Workflow { | ||
return &controller.Workflow{} | ||
} |
Oops, something went wrong.