Skip to content

Commit c6cd436

Browse files
committed
Check thing template has variables
1 parent 5e9daf1 commit c6cd436

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

internal/template/load.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ func LoadThing(file string) (*iotclient.ThingCreate, error) {
6565

6666
// Adapt thing template to thing structure
6767
delete(template, "id")
68-
template["properties"] = template["variables"]
68+
vars, ok := template["variables"]
69+
if !ok {
70+
return nil, errors.New("loaded thing template doesn't have a `variables` field")
71+
}
72+
template["properties"] = vars
6973
delete(template, "variables")
7074

7175
// Convert template into thing structure exploiting json marshalling/unmarshalling

0 commit comments

Comments
 (0)