diff options
| author | KubeEdge Bot <48982446+kubeedge-bot@users.noreply.github.com> | 2024-01-04 16:51:16 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-04 16:51:16 +0800 |
| commit | b0e5de868853515274eb2ace8592e99dd633f412 (patch) | |
| tree | 71071f9d75ef7c646d3ccb1652df5aff269605c1 | |
| parent | Merge pull request #5295 from Shelley-BaoYue/automated-cherry-pick-of-#5270-u... (diff) | |
| parent | fix device status problem (diff) | |
| download | kubeedge-b0e5de868853515274eb2ace8592e99dd633f412.tar.gz | |
Merge pull request #5336 from wbc6080/automated-cherry-pick-of-#5328-upstream-release-1.15
Automated cherry pick of #5328: fix device status problem
| -rw-r--r-- | cloud/pkg/devicecontroller/controller/upstream.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/cloud/pkg/devicecontroller/controller/upstream.go b/cloud/pkg/devicecontroller/controller/upstream.go index d1bcc3836..66de580aa 100644 --- a/cloud/pkg/devicecontroller/controller/upstream.go +++ b/cloud/pkg/devicecontroller/controller/upstream.go @@ -135,7 +135,7 @@ func (uc *UpstreamController) updateDeviceStatus() { } deviceStatus := &DeviceStatus{Status: cacheDevice.Status} for twinName, twin := range msgTwin.Twin { - deviceTwin := findTwinByName(twinName, &deviceStatus.Status.Twins) + deviceTwin := findTwinByName(twinName, deviceStatus.Status.Twins) if deviceTwin != nil { if twin.Actual != nil && twin.Actual.Value != nil { reported := v1beta1.TwinProperty{} @@ -226,10 +226,10 @@ func NewUpstreamController(dc *DownstreamController) (*UpstreamController, error return uc, nil } -func findTwinByName(twinName string, twins *[]v1beta1.Twin) *v1beta1.Twin { - for _, twin := range *twins { - if twinName == twin.PropertyName { - return &twin +func findTwinByName(twinName string, twins []v1beta1.Twin) *v1beta1.Twin { + for i := range twins { + if twinName == twins[i].PropertyName { + return &twins[i] } } return nil |
