Skip to content

Commit 91937a0

Browse files
committed
Add structured reporting diff to WorkstationCluster
1 parent 140e11a commit 91937a0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/controller/direct/workstations/cluster_controller.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct/directbase"
2727
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct/registry"
2828
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/fuzztesting"
29+
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/structuredreporting"
2930

3031
gcp "cloud.google.com/go/workstations/apiv1"
3132
pb "cloud.google.com/go/workstations/apiv1/workstationspb"
@@ -251,18 +252,24 @@ func (a *Adapter) Update(ctx context.Context, updateOp *directbase.UpdateOperati
251252
}
252253
resource.Name = a.id.FullyQualifiedName()
253254

255+
report := &structuredreporting.Diff{Object: updateOp.GetUnstructured()}
256+
254257
updateMask := &fieldmaskpb.FieldMask{}
255258
if !reflect.DeepEqual(resource.Annotations, a.actual.Annotations) {
259+
report.AddField("annotations", a.actual.Annotations, resource.Annotations)
256260
updateMask.Paths = append(updateMask.Paths, "annotations")
257261
}
258262
if !reflect.DeepEqual(resource.Labels, a.actual.Labels) {
263+
report.AddField("labels", a.actual.Labels, resource.Labels)
259264
updateMask.Paths = append(updateMask.Paths, "labels")
260265
}
261266

262267
if len(updateMask.Paths) == 0 {
263268
return nil
264269
}
265270

271+
structuredreporting.ReportDiff(ctx, report)
272+
266273
req := &pb.UpdateWorkstationClusterRequest{
267274
UpdateMask: updateMask,
268275
WorkstationCluster: resource,

0 commit comments

Comments
 (0)