-
Notifications
You must be signed in to change notification settings - Fork 479
/
device.go
30 lines (24 loc) · 915 Bytes
/
device.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//
// Copyright (C) 2020 IOTech Ltd
//
// SPDX-License-Identifier: Apache-2.0
package application
import (
"context"
dataContainer "github.com/edgexfoundry/edgex-go/internal/core/data/container"
v2DataContainer "github.com/edgexfoundry/edgex-go/internal/core/data/v2/bootstrap/container"
"github.com/edgexfoundry/go-mod-bootstrap/di"
"github.com/edgexfoundry/go-mod-core-contracts/errors"
)
// This function will be updated when CheckDevice in v2 core-metadata is available
func checkDevice(deviceName string, ctx context.Context, dic *di.Container) errors.EdgeX {
mdc := v2DataContainer.MetadataDeviceClientFrom(dic.Get)
configuration := dataContainer.ConfigurationFrom(dic.Get)
if configuration.Writable.MetaDataCheck {
_, err := mdc.CheckForDevice(ctx, deviceName)
if err != nil {
return errors.NewCommonEdgeX(errors.KindServerError, "checking device name failed", err)
}
}
return nil
}