diff --git a/cmd/execute/execute.go b/cmd/execute/execute.go index b77d2d2..9a24623 100644 --- a/cmd/execute/execute.go +++ b/cmd/execute/execute.go @@ -130,7 +130,7 @@ var ExecuteCmd = &cobra.Command{ os.Exit(0) } - createRun(version.ID, watch, &executionMachines, outputNodes, outputsDirectory) + createRun(version.ID, fleet.ID, watch, &executionMachines, outputNodes, outputsDirectory) }, } diff --git a/cmd/execute/helpers.go b/cmd/execute/helpers.go index d292f96..c18821f 100644 --- a/cmd/execute/helpers.go +++ b/cmd/execute/helpers.go @@ -98,11 +98,13 @@ func getScripts(pageSize int, search string, name string) []types.Script { return scripts.Results } -func createRun(versionID uuid.UUID, watch bool, machines *types.Machines, outputNodes []string, outputsDir string) { +func createRun(versionID, fleetID uuid.UUID, watch bool, machines *types.Machines, outputNodes []string, outputsDir string) { + run := types.CreateRun{ VersionID: versionID, Vault: fleet.Vault, Machines: executionMachines, + Fleet: &fleetID, } data, err := json.Marshal(run) @@ -117,6 +119,18 @@ func createRun(versionID uuid.UUID, watch bool, machines *types.Machines, output os.Exit(0) } + if resp.Status() != http.StatusCreated { + run.Fleet = nil + + data, err := json.Marshal(run) + if err != nil { + fmt.Println("Error encoding create run request!") + os.Exit(0) + } + + resp = request.Trickest.Post().Body(data).DoF("execution/") + } + if resp.Status() != http.StatusCreated { request.ProcessUnexpectedResponse(resp) } diff --git a/types/execute.go b/types/execute.go index 93e2009..6a0c2d6 100644 --- a/types/execute.go +++ b/types/execute.go @@ -42,9 +42,10 @@ type TreeNode struct { } type CreateRun struct { - Machines Machines `json:"machines"` - VersionID uuid.UUID `json:"workflow_version_info"` - Vault uuid.UUID `json:"vault"` + Machines Machines `json:"machines"` + VersionID uuid.UUID `json:"workflow_version_info"` + Vault uuid.UUID `json:"vault"` + Fleet *uuid.UUID `json:"fleet,omitempty"` } type CreateRunResponse struct { diff --git a/types/user.go b/types/user.go index 96716f4..0a5dc66 100644 --- a/types/user.go +++ b/types/user.go @@ -56,7 +56,6 @@ type Fleets struct { type Fleet struct { ID uuid.UUID `json:"id"` Name string `json:"name"` - HiveType string `json:"hive_type"` Vault uuid.UUID `json:"vault"` Cluster string `json:"cluster"` State string `json:"state"`