Skip to content

Commit

Permalink
Update execution endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mhmdiaa committed Nov 28, 2023
1 parent a8bfa50 commit ffd343e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/execute/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
}

Expand Down
16 changes: 15 additions & 1 deletion cmd/execute/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
Expand Down
7 changes: 4 additions & 3 deletions types/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion types/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit ffd343e

Please sign in to comment.