Skip to content

Commit

Permalink
feat: added stack sync-commit subcommand
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub <jakub.wojtowicz@sephcode.pl>
  • Loading branch information
sephriot committed Jan 17, 2025
1 parent 63593f3 commit 7b9218e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/cmd/stack/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,17 @@ func Command() *cli.Command {
Before: authenticated.Ensure,
ArgsUsage: cmd.EmptyArgsUsage,
},
{
Category: "Stack management",
Name: "sync-commit",
Usage: "Syncs the tracked stack commit",
Flags: []cli.Flag{
flagStackID,
},
Action: syncCommit,
Before: authenticated.Ensure,
ArgsUsage: cmd.EmptyArgsUsage,
},
{
Name: "resources",
Usage: "Manage and view resources for stacks",
Expand Down
31 changes: 31 additions & 0 deletions internal/cmd/stack/sync.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package stack

import (
"fmt"

"github.com/shurcooL/graphql"
"github.com/spacelift-io/spacectl/internal/cmd/authenticated"
"github.com/urfave/cli/v2"
)

func syncCommit(cliCtx *cli.Context) error {
stackID, err := getStackID(cliCtx)
if err != nil {
return err
}

if nArgs := cliCtx.NArg(); nArgs != 0 {
return fmt.Errorf("expected zero arguments but got %d", nArgs)
}

var mutation struct {
Stack struct {
ID string `graphql:"id"`
} `graphql:"stackSyncCommit(id: $stack)"`
}
variables := map[string]interface{}{
"stack": graphql.ID(stackID),
}

return authenticated.Client.Mutate(cliCtx.Context, &mutation, variables)
}

0 comments on commit 7b9218e

Please sign in to comment.