-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add new command for prioriting a run and flag to prioritize loc…
…al-preview
- Loading branch information
1 parent
deba5a0
commit 89a33d3
Showing
7 changed files
with
90 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ key.* | |
completions | ||
|
||
*.csv | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package stack | ||
|
||
import ( | ||
"fmt" | ||
"github.com/shurcooL/graphql" | ||
"github.com/spacelift-io/spacectl/internal/cmd/authenticated" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
type setRunPriorityMutation struct { | ||
SetRunPriority struct { | ||
ID string `graphql:"id"` | ||
} `graphql:"runPrioritizeSet(stack: $stackId, run: $runId, prioritize: $prioritize)"` | ||
} | ||
|
||
func runPrioritize(cliCtx *cli.Context) error { | ||
stackID, err := getStackID(cliCtx) | ||
if err != nil { | ||
return err | ||
} | ||
runID := cliCtx.String(flagRequiredRun.Name) | ||
|
||
var mutation setRunPriorityMutation | ||
|
||
variables := map[string]interface{}{ | ||
"stackId": graphql.ID(stackID), | ||
"runId": graphql.ID(runID), | ||
"prioritize": graphql.Boolean(true), | ||
} | ||
|
||
if err = authenticated.Client.Mutate(cliCtx.Context, &mutation, variables); err != nil { | ||
return err | ||
} | ||
|
||
fmt.Printf("Run ID %q has been successfully prioritized\n", runID) | ||
fmt.Println("The live run can be visited at", authenticated.Client.URL( | ||
"/stack/%s/run/%s", | ||
stackID, | ||
mutation.SetRunPriority.ID, | ||
)) | ||
|
||
if !cliCtx.Bool(flagTail.Name) { | ||
return nil | ||
} | ||
|
||
terminal, err := runLogsWithAction(cliCtx.Context, stackID, mutation.SetRunPriority.ID, nil) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return terminal.Error() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters