-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add run confirmation and user provided metadata. (#14)
* Add run confirmation and user provided metadata. * Fix lint. * Fix lint. * Change to graphql fork. * Fix passing request options.
- Loading branch information
Showing
11 changed files
with
125 additions
and
21 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
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,5 @@ | ||
package stack | ||
|
||
// UserProvidedRunMetadataHeader is the HTTP header used to pass arbitrary metadata | ||
// to runs when creating or confirming them. | ||
const UserProvidedRunMetadataHeader = "Spacelift-User-Provided-Run-Metadata" |
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,56 @@ | ||
package stack | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/shurcooL/graphql" | ||
"github.com/urfave/cli/v2" | ||
|
||
"github.com/spacelift-io/spacectl/internal/cmd/authenticated" | ||
) | ||
|
||
func runConfirm() cli.ActionFunc { | ||
return func(cliCtx *cli.Context) error { | ||
var mutation struct { | ||
RunConfirm struct { | ||
ID string `grapqhl:"id"` | ||
} `graphql:"runConfirm(stack: $stack, run: $run)"` | ||
} | ||
|
||
variables := map[string]interface{}{ | ||
"stack": graphql.ID(stackID), | ||
"run": graphql.ID(cliCtx.String(flagRun.Name)), | ||
} | ||
|
||
ctx := context.Background() | ||
|
||
var requestOpts []graphql.RequestOption | ||
if cliCtx.IsSet(flagRunMetadata.Name) { | ||
requestOpts = append(requestOpts, graphql.WithHeader(UserProvidedRunMetadataHeader, cliCtx.String(flagRunMetadata.Name))) | ||
} | ||
|
||
if err := authenticated.Client.Mutate(ctx, &mutation, variables, requestOpts...); err != nil { | ||
return err | ||
} | ||
|
||
fmt.Println("You have successfully confirmed a deployment") | ||
|
||
fmt.Println("The live run can be visited at", authenticated.Client.URL( | ||
"/stack/%s/run/%s", | ||
stackID, | ||
mutation.RunConfirm.ID, | ||
)) | ||
|
||
if !cliCtx.Bool(flagTail.Name) { | ||
return nil | ||
} | ||
|
||
terminal, err := runLogs(ctx, stackID, mutation.RunConfirm.ID) | ||
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
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