Skip to content

Commit d183b01

Browse files
committed
Add structured reporting diff to ComputeNetworkEdgeSecurityService
1 parent 140e11a commit d183b01

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/controller/direct/compute/networkedgesecurityservice_controller.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct"
3636
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct/directbase"
3737
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct/registry"
38+
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/structuredreporting"
3839
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
3940
"k8s.io/apimachinery/pkg/runtime"
4041
"k8s.io/klog/v2"
@@ -197,11 +198,15 @@ func (a *NetworkEdgeSecurityServiceAdapter) Update(ctx context.Context, updateOp
197198
// An up-to-date fingerprint must be provided in order to patch
198199
resource.Fingerprint = a.actual.Fingerprint
199200

201+
report := &structuredreporting.Diff{Object: updateOp.GetUnstructured()}
202+
200203
var paths []string
201204
if !reflect.DeepEqual(resource.SecurityPolicy, a.actual.SecurityPolicy) {
205+
report.AddField("security_policy", a.actual.SecurityPolicy, resource.SecurityPolicy)
202206
paths = append(paths, "security_policy")
203207
}
204208
if !reflect.DeepEqual(resource.Description, a.actual.Description) {
209+
report.AddField("description", a.actual.Description, resource.Description)
205210
paths = append(paths, "description")
206211
}
207212

@@ -215,6 +220,8 @@ func (a *NetworkEdgeSecurityServiceAdapter) Update(ctx context.Context, updateOp
215220
return updateOp.UpdateStatus(ctx, status, nil)
216221
}
217222

223+
structuredreporting.ReportDiff(ctx, report)
224+
218225
// updateMask is a comma-separated list of fully qualified names of fields.
219226
sort.Strings(paths)
220227
updateMask := strings.Join(paths, ",")

0 commit comments

Comments
 (0)