Skip to content

Commit

Permalink
feat: use patch config to patch ts config
Browse files Browse the repository at this point in the history
  • Loading branch information
slntopp committed Feb 9, 2024
1 parent a793d4e commit 70b2d77
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,18 +179,6 @@ func main() {
Namespace: namespace,
}

if i == 0 {
req.Device.Config, _ = structpb.NewStruct(map[string]interface{}{
"infinimesh.timeseries": map[string]interface{}{
"enabled": true,
"include_metrics": []string{
"speed",
"sats",
},
},
})
}

res, err := devc.Create(ctx, req)
if err != nil {
panic(err)
Expand All @@ -203,6 +191,25 @@ func main() {
}
}(res.GetDevice())

if i == 0 {
config, _ := structpb.NewStruct(map[string]interface{}{
"infinimesh.timeseries": map[string]interface{}{
"enabled": true,
"include_metrics": []string{
"speed",
"sats",
},
},
})
_, err = devc.PatchConfig(ctx, &devpb.Device{
Uuid: res.GetDevice().GetUuid(),
Config: config,
})
if err != nil {
fmt.Printf("[WARN] Couldn't patch config for device %s: %v", res.GetDevice().GetUuid(), err)
}
}

truck := &common.Truck{
Uuid: res.GetDevice().GetUuid(),
Point: rand.Int63n(rows),
Expand Down

0 comments on commit 70b2d77

Please sign in to comment.