Skip to content

Commit

Permalink
test: add cluster to logger to co-relate requests to clusters in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chrischdi committed Mar 7, 2025
1 parent 3a8728f commit d32b49b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test/extension/handlers/lifecycle/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func NewExtensionHandlers(client client.Client) *ExtensionHandlers {
// control the hook behaviour during a test.
// NOTE: custom RuntimeExtension, must implement the body of this func according to the specific use case.
func (m *ExtensionHandlers) DoBeforeClusterCreate(ctx context.Context, request *runtimehooksv1.BeforeClusterCreateRequest, response *runtimehooksv1.BeforeClusterCreateResponse) {
log := ctrl.LoggerFrom(ctx)
log := ctrl.LoggerFrom(ctx).WithValues("Cluster", klog.KObj(&request.Cluster))
log.Info("BeforeClusterCreate is called")

if err := m.readResponseFromConfigMap(ctx, &request.Cluster, runtimehooksv1.BeforeClusterCreate, request.GetSettings(), response); err != nil {
Expand All @@ -80,7 +80,7 @@ func (m *ExtensionHandlers) DoBeforeClusterCreate(ctx context.Context, request *
// control the hook behaviour during a test.
// NOTE: custom RuntimeExtension, must implement the body of this func according to the specific use case.
func (m *ExtensionHandlers) DoBeforeClusterUpgrade(ctx context.Context, request *runtimehooksv1.BeforeClusterUpgradeRequest, response *runtimehooksv1.BeforeClusterUpgradeResponse) {
log := ctrl.LoggerFrom(ctx)
log := ctrl.LoggerFrom(ctx).WithValues("Cluster", klog.KObj(&request.Cluster))
log.Info("BeforeClusterUpgrade is called")

if err := m.readResponseFromConfigMap(ctx, &request.Cluster, runtimehooksv1.BeforeClusterUpgrade, request.GetSettings(), response); err != nil {
Expand All @@ -100,7 +100,7 @@ func (m *ExtensionHandlers) DoBeforeClusterUpgrade(ctx context.Context, request
// control the hook behaviour during a test.
// NOTE: custom RuntimeExtension, must implement the body of this func according to the specific use case.
func (m *ExtensionHandlers) DoAfterControlPlaneInitialized(ctx context.Context, request *runtimehooksv1.AfterControlPlaneInitializedRequest, response *runtimehooksv1.AfterControlPlaneInitializedResponse) {
log := ctrl.LoggerFrom(ctx)
log := ctrl.LoggerFrom(ctx).WithValues("Cluster", klog.KObj(&request.Cluster))
log.Info("AfterControlPlaneInitialized is called")

if err := m.readResponseFromConfigMap(ctx, &request.Cluster, runtimehooksv1.AfterControlPlaneInitialized, request.GetSettings(), response); err != nil {
Expand All @@ -120,7 +120,7 @@ func (m *ExtensionHandlers) DoAfterControlPlaneInitialized(ctx context.Context,
// control the hook behaviour during a test.
// NOTE: custom RuntimeExtension, must implement the body of this func according to the specific use case.
func (m *ExtensionHandlers) DoAfterControlPlaneUpgrade(ctx context.Context, request *runtimehooksv1.AfterControlPlaneUpgradeRequest, response *runtimehooksv1.AfterControlPlaneUpgradeResponse) {
log := ctrl.LoggerFrom(ctx)
log := ctrl.LoggerFrom(ctx).WithValues("Cluster", klog.KObj(&request.Cluster))
log.Info("AfterControlPlaneUpgrade is called")

if err := m.readResponseFromConfigMap(ctx, &request.Cluster, runtimehooksv1.AfterControlPlaneUpgrade, request.GetSettings(), response); err != nil {
Expand All @@ -140,7 +140,7 @@ func (m *ExtensionHandlers) DoAfterControlPlaneUpgrade(ctx context.Context, requ
// control the hook behaviour during a test.
// NOTE: custom RuntimeExtension, must implement the body of this func according to the specific use case.
func (m *ExtensionHandlers) DoAfterClusterUpgrade(ctx context.Context, request *runtimehooksv1.AfterClusterUpgradeRequest, response *runtimehooksv1.AfterClusterUpgradeResponse) {
log := ctrl.LoggerFrom(ctx)
log := ctrl.LoggerFrom(ctx).WithValues("Cluster", klog.KObj(&request.Cluster))
log.Info("AfterClusterUpgrade is called")

if err := m.readResponseFromConfigMap(ctx, &request.Cluster, runtimehooksv1.AfterClusterUpgrade, request.GetSettings(), response); err != nil {
Expand All @@ -160,7 +160,7 @@ func (m *ExtensionHandlers) DoAfterClusterUpgrade(ctx context.Context, request *
// control the hook behaviour during a test.
// NOTE: custom RuntimeExtension, must implement the body of this func according to the specific use case.
func (m *ExtensionHandlers) DoBeforeClusterDelete(ctx context.Context, request *runtimehooksv1.BeforeClusterDeleteRequest, response *runtimehooksv1.BeforeClusterDeleteResponse) {
log := ctrl.LoggerFrom(ctx)
log := ctrl.LoggerFrom(ctx).WithValues("Cluster", klog.KObj(&request.Cluster))
log.Info("BeforeClusterDelete is called")

if err := m.readResponseFromConfigMap(ctx, &request.Cluster, runtimehooksv1.BeforeClusterDelete, request.GetSettings(), response); err != nil {
Expand Down

0 comments on commit d32b49b

Please sign in to comment.