Skip to content

Commit 95bfb23

Browse files
mirkoCrobulucarin91
authored andcommitted
add current value to brickinstance variable response
1 parent bf8a15f commit 95bfb23

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

internal/orchestrator/bricks/bricks.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,23 +101,23 @@ func (s *Service) AppBrickInstanceDetails(a *app.ArduinoApp, brickID string) (Br
101101
return BrickInstanceDetails{}, fmt.Errorf("brick %s not added in the app", brickID)
102102
}
103103

104-
variables := make(map[string]BrickVariable, len(brick.Variables))
104+
variables := make(map[string]BrickInstanceVariable, len(brick.Variables))
105105
for _, v := range brick.Variables {
106-
variables[v.Name] = BrickVariable{
107-
DefaultValue: v.DefaultValue,
108-
Description: v.Description,
109-
Required: v.IsRequired(),
106+
variables[v.Name] = BrickInstanceVariable{
107+
Value: v.DefaultValue,
108+
Description: v.Description,
109+
Required: v.IsRequired(),
110110
}
111111
}
112112
// Add/Update the variables with the ones from the app descriptor
113113
appVars := a.Descriptor.Bricks[brickIndex].Variables
114114
for varName, appValue := range appVars {
115115
if v, ok := variables[varName]; ok {
116-
v.DefaultValue = appValue
116+
v.Value = appValue
117117
variables[varName] = v
118118
} else {
119-
variables[varName] = BrickVariable{
120-
DefaultValue: appValue,
119+
variables[varName] = BrickInstanceVariable{
120+
Value: appValue,
121121
}
122122
}
123123
}

internal/orchestrator/bricks/types.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,19 @@ type BrickInstance struct {
4444
}
4545

4646
type BrickInstanceDetails struct {
47-
ID string `json:"id"`
48-
Name string `json:"name"`
49-
Author string `json:"author"`
50-
Category string `json:"category"`
51-
Status string `json:"status"`
52-
Variables map[string]BrickVariable `json:"variables,omitempty"`
53-
ModelID string `json:"model,omitempty"`
47+
ID string `json:"id"`
48+
Name string `json:"name"`
49+
Author string `json:"author"`
50+
Category string `json:"category"`
51+
Status string `json:"status"`
52+
Variables map[string]BrickInstanceVariable `json:"variables,omitempty"`
53+
ModelID string `json:"model,omitempty"`
54+
}
55+
56+
type BrickInstanceVariable struct {
57+
Value string `json:"value,omitempty"`
58+
Description string `json:"description,omitempty"`
59+
Required bool `json:"required"`
5460
}
5561

5662
type BrickVariable struct {

0 commit comments

Comments
 (0)