Skip to content

Commit 7fe844b

Browse files
authored
Update fleet machines data format (#137)
* Update machine keys in fleet struct * Clean up WorkflowVersion fields
1 parent 58531e7 commit 7fe844b

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

pkg/trickest/run.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func (c *Client) CreateRun(ctx context.Context, versionID uuid.UUID, machines in
180180
return nil, fmt.Errorf("invalid fleet")
181181
}
182182

183-
if len(fleet.Machines) == 0 {
183+
if fleet.Machines.Max == 0 {
184184
return nil, fmt.Errorf("fleet has no machines")
185185
}
186186

@@ -191,7 +191,7 @@ func (c *Client) CreateRun(ctx context.Context, versionID uuid.UUID, machines in
191191
UseStaticIPs: &useStaticIPs,
192192
}
193193

194-
if fleet.Machines[0].Name == "self_hosted" {
194+
if fleet.Type == FleetTypeSelfHosted {
195195
run.Machines = Machines{
196196
SelfHosted: &machines,
197197
}

pkg/trickest/user.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,28 @@ type IPAddress struct {
4444
IPAddress string `json:"ip_address"`
4545
}
4646

47+
type FleetType string
48+
49+
const (
50+
FleetTypeManaged = "MANAGED"
51+
FleetTypeSelfHosted = "HOSTED"
52+
)
53+
4754
type Fleet struct {
4855
ID uuid.UUID `json:"id"`
4956
Name string `json:"name"`
5057
Vault uuid.UUID `json:"vault"`
5158
Cluster string `json:"cluster"`
5259
State string `json:"state"`
53-
Machines []struct {
54-
Name string `json:"name"`
55-
Description string `json:"description"`
56-
Mem string `json:"mem"`
57-
CPU string `json:"cpu"`
58-
Total int `json:"total"`
59-
Running int `json:"running"`
60-
Up int `json:"up"`
61-
Down int `json:"down"`
60+
Machines struct {
61+
Active int `json:"active"`
62+
Deleting int `json:"deleting"`
63+
Inactive int `json:"inactive"`
64+
Max int `json:"max"`
6265
} `json:"machines"`
6366
CreatedDate time.Time `json:"created_date"`
6467
ModifiedDate time.Time `json:"modified_date"`
65-
Type string `json:"type"`
68+
Type FleetType `json:"type"`
6669
Default bool `json:"default"`
6770
}
6871

pkg/trickest/workflow.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,11 @@ type ScheduleInfo struct {
4242
// WorkflowVersion represents a workflow version
4343
type WorkflowVersion struct {
4444
ID uuid.UUID `json:"id"`
45-
Version int `json:"version"`
4645
WorkflowInfo uuid.UUID `json:"workflow_info"`
4746
Name *string `json:"name,omitempty"`
4847
Description string `json:"description"`
49-
Public bool `json:"public"`
5048
CreatedDate time.Time `json:"created_date"`
5149
RunCount int `json:"run_count"`
52-
MaxMachines Machines `json:"max_machines"`
5350
Snapshot bool `json:"snapshot"`
5451
Data WorkflowVersionData `json:"data"`
5552
}

0 commit comments

Comments
 (0)