Skip to content

Commit ce2ff2b

Browse files
committed
[patch release v1.9.3] Update fleet struct
1 parent 70ded42 commit ce2ff2b

File tree

3 files changed

+17
-48
lines changed

3 files changed

+17
-48
lines changed

cmd/execute/execute.go

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,22 +101,11 @@ var ExecuteCmd = &cobra.Command{
101101
fmt.Printf("Error: %s\n", err)
102102
os.Exit(1)
103103
}
104-
105-
if len(fleet.Machines) == 3 {
106-
// 3 types of machines: small, medium, and large
107-
executionMachines = machines
108-
109-
if machines.Default != nil {
110-
fmt.Printf("Error: you need to use the small-medium-large format to specify the numbers of machines (e.g. 1-2-3)")
111-
os.Exit(1)
112-
}
113-
} else {
114-
// 1 type of machine
115-
executionMachines, err = handleSingleMachineType(*fleet, machines)
116-
if err != nil {
117-
fmt.Printf("Error: %s\n", err)
118-
os.Exit(1)
119-
}
104+
// 1 type of machine
105+
executionMachines, err = handleSingleMachineType(*fleet, machines)
106+
if err != nil {
107+
fmt.Printf("Error: %s\n", err)
108+
os.Exit(1)
120109
}
121110
} else {
122111
executionMachines = setMachinesToMinimum(version.MaxMachines)
@@ -852,7 +841,8 @@ func readWorkflowYAMLandCreateVersion(fileName string, workflowName string, obje
852841
}
853842

854843
func createToolWorkflow(wfName string, space *types.SpaceDetailed, project *types.Project, deleteProjectOnError bool,
855-
tool *types.Tool, primitiveNodes map[string]*types.PrimitiveNode, machine types.Machines) *types.WorkflowVersionDetailed {
844+
tool *types.Tool, primitiveNodes map[string]*types.PrimitiveNode, machine types.Machines,
845+
) *types.WorkflowVersionDetailed {
856846
if tool == nil {
857847
fmt.Println("No tool specified, couldn't create a workflow!")
858848
os.Exit(0)

cmd/execute/helpers.go

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ func getScripts(pageSize int, search string, name string) []types.Script {
9898
}
9999

100100
func createRun(versionID, fleetID uuid.UUID, watch bool, outputNodes []string, outputsDir string, useStaticIPs bool) {
101-
102101
run := types.CreateRun{
103102
VersionID: versionID,
104103
Machines: executionMachines,
@@ -397,28 +396,12 @@ func processInvalidInputType(newPNode, existingPNode types.PrimitiveNode) {
397396

398397
func GetAvailableMachines(fleetName string) types.Machines {
399398
hiveInfo := util.GetFleetInfo(fleetName)
399+
available := hiveInfo.Machines.Inactive
400400
availableMachines := types.Machines{}
401-
for _, machine := range hiveInfo.Machines {
402-
if machine.Name == "small" {
403-
available := machine.Total - machine.Running
404-
availableMachines.Small = &available
405-
}
406-
if machine.Name == "medium" {
407-
available := machine.Total - machine.Running
408-
availableMachines.Medium = &available
409-
}
410-
if machine.Name == "large" {
411-
available := machine.Total - machine.Running
412-
availableMachines.Large = &available
413-
}
414-
if machine.Name == "default" {
415-
available := machine.Total - machine.Running
416-
availableMachines.Default = &available
417-
}
418-
if machine.Name == "self_hosted" {
419-
available := machine.Total - machine.Running
420-
availableMachines.SelfHosted = &available
421-
}
401+
if hiveInfo.Type == "HOSTED" {
402+
availableMachines.SelfHosted = &available
403+
} else {
404+
availableMachines.Default = &available
422405
}
423406
return availableMachines
424407
}

types/user.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,11 @@ type Fleet struct {
5959
Vault uuid.UUID `json:"vault"`
6060
Cluster string `json:"cluster"`
6161
State string `json:"state"`
62-
Machines []struct {
63-
Name string `json:"name"`
64-
Description string `json:"description"`
65-
Mem string `json:"mem"`
66-
CPU string `json:"cpu"`
67-
Total int `json:"total"`
68-
Running int `json:"running"`
69-
Up int `json:"up"`
70-
Down int `json:"down"`
62+
Machines struct {
63+
Active int `json:"active"`
64+
Deleting int `json:"deleting"`
65+
Inactive int `json:"inactive"`
66+
Max int `json:"max"`
7167
} `json:"machines"`
7268
CreatedDate time.Time `json:"created_date"`
7369
ModifiedDate time.Time `json:"modified_date"`

0 commit comments

Comments
 (0)