fix(inputs.opcua): Assign node id correctly (#11723)

This commit is contained in:
Sebastian Spaink 2022-08-31 16:56:30 -05:00 committed by GitHub
parent 93e6941495
commit 15c7bc51f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -22,6 +22,7 @@ import (
)
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embed the sampleConfig data.
//
//go:embed sample.conf
var sampleConfig string
@ -295,7 +296,7 @@ func newMP(n *Node) metricParts {
func (o *OpcUA) validateOPCTags() error {
nameEncountered := map[metricParts]struct{}{}
for _, node := range o.nodes {
for i, node := range o.nodes {
mp := newMP(&node)
//check empty name
if node.tag.FieldName == "" {
@ -322,10 +323,10 @@ func (o *OpcUA) validateOPCTags() error {
return fmt.Errorf("invalid identifier type '%s' in '%s'", node.tag.IdentifierType, node.tag.FieldName)
}
node.idStr = BuildNodeID(node.tag)
o.nodes[i].idStr = BuildNodeID(node.tag)
//parse NodeIds and NodeIds errors
nid, niderr := ua.ParseNodeID(node.idStr)
nid, niderr := ua.ParseNodeID(o.nodes[i].idStr)
// build NodeIds and Errors
o.nodeIDs = append(o.nodeIDs, nid)
o.nodeIDerror = append(o.nodeIDerror, niderr)