Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require (
github.com/mattn/go-shellwords v1.0.12
github.com/mitchellh/go-homedir v1.1.0
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
github.com/planetscale/planetscale-go v0.154.0
github.com/planetscale/planetscale-go v0.155.0
github.com/planetscale/psdb v0.0.0-20250717190954-65c6661ab6e4
github.com/planetscale/psdbproxy v0.0.0-20250728082226-3f4ea3a74ec7
github.com/spf13/cobra v1.10.2
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,8 @@ github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjL
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/planetscale/noglog v0.2.1-0.20210421230640-bea75fcd2e8e h1:MZ8D+Z3m2vvqGZLvoQfpaGg/j1fNDr4j03s3PRz4rVY=
github.com/planetscale/noglog v0.2.1-0.20210421230640-bea75fcd2e8e/go.mod h1:hwAsSPQdvPa3WcfKfzTXxtEq/HlqwLjQasfO6QbGo4Q=
github.com/planetscale/planetscale-go v0.153.0 h1:b+X6JUvPkhjv083b+b8IHsv8INNMvvGwANjIGQOfMlM=
github.com/planetscale/planetscale-go v0.153.0/go.mod h1:paQCI5SgquuoewvMQM7R+r1XJO868bdP6/ihGidYRM0=
github.com/planetscale/planetscale-go v0.154.0 h1:bHBiOlGy7Cs7FDFmQgjjJnGUr2xPlqlB3uVPbh/Kl2Q=
github.com/planetscale/planetscale-go v0.154.0/go.mod h1:paQCI5SgquuoewvMQM7R+r1XJO868bdP6/ihGidYRM0=
github.com/planetscale/planetscale-go v0.155.0 h1:KYFRWFn9d5BeZc++4DF0wS+mlRQ4efrAy+6Zw/1kzXs=
github.com/planetscale/planetscale-go v0.155.0/go.mod h1:paQCI5SgquuoewvMQM7R+r1XJO868bdP6/ihGidYRM0=
github.com/planetscale/psdb v0.0.0-20250717190954-65c6661ab6e4 h1:Xv5pj20Rhfty1Tv0OVcidg4ez4PvGrpKvb6rvUwQgDs=
github.com/planetscale/psdb v0.0.0-20250717190954-65c6661ab6e4/go.mod h1:M52h5IWxAcbdQ1hSZrLAGQC4ZXslxEsK/Wh9nu3wdWs=
github.com/planetscale/psdbproxy v0.0.0-20250728082226-3f4ea3a74ec7 h1:aRd6vdE1fyuSI4RVj7oCr8lFmgqXvpnPUmN85VbZCp8=
Expand Down
15 changes: 11 additions & 4 deletions internal/cmd/branch/vtctld/workflows.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import (

func ListWorkflowsCmd(ch *cmdutil.Helper) *cobra.Command {
var flags struct {
keyspace string
workflow string
keyspace string
workflow string
includeLogs bool
}

cmd := &cobra.Command{
Expand All @@ -32,13 +33,18 @@ func ListWorkflowsCmd(ch *cmdutil.Helper) *cobra.Command {
progressTarget(ch.Config.Organization, database, branch)))
defer end()

data, err := client.Vtctld.ListWorkflows(ctx, &ps.VtctldListWorkflowsRequest{
req := &ps.VtctldListWorkflowsRequest{
Organization: ch.Config.Organization,
Database: database,
Branch: branch,
Keyspace: flags.keyspace,
Workflow: flags.workflow,
})
}
if cmd.Flags().Changed("include-logs") {
req.IncludeLogs = &flags.includeLogs
}

data, err := client.Vtctld.ListWorkflows(ctx, req)
if err != nil {
return cmdutil.HandleError(err)
}
Expand All @@ -50,6 +56,7 @@ func ListWorkflowsCmd(ch *cmdutil.Helper) *cobra.Command {

cmd.Flags().StringVar(&flags.keyspace, "keyspace", "", "Keyspace to list workflows for")
cmd.Flags().StringVar(&flags.workflow, "workflow", "", "Filter by workflow name")
cmd.Flags().BoolVar(&flags.includeLogs, "include-logs", true, "Include workflow logs in the response")
cmd.MarkFlagRequired("keyspace") // nolint:errcheck

return cmd
Expand Down
91 changes: 57 additions & 34 deletions internal/cmd/branch/vtctld/workflows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,65 @@ import (
)

func TestListWorkflows(t *testing.T) {
c := qt.New(t)

org := "my-org"
db := "my-db"
branch := "my-branch"

svc := &mock.VtctldService{
ListWorkflowsFn: func(ctx context.Context, req *ps.VtctldListWorkflowsRequest) (json.RawMessage, error) {
c.Assert(req.Organization, qt.Equals, org)
c.Assert(req.Database, qt.Equals, db)
c.Assert(req.Branch, qt.Equals, branch)
c.Assert(req.Keyspace, qt.Equals, "my-keyspace")
return json.RawMessage(`{"workflows":[]}`), nil
},
}
includeLogsFalse := false

var buf bytes.Buffer
format := printer.JSON
p := printer.NewPrinter(&format)
p.SetResourceOutput(&buf)

ch := &cmdutil.Helper{
Printer: p,
Config: &config.Config{Organization: org},
Client: func() (*ps.Client, error) {
return &ps.Client{
Vtctld: svc,
}, nil
tests := []struct {
name string
args []string
includeLogs *bool
}{
{
name: "default omits include_logs override",
args: []string{"--keyspace", "my-keyspace"},
includeLogs: nil,
},
{
name: "include_logs false",
args: []string{"--keyspace", "my-keyspace", "--include-logs=false"},
includeLogs: &includeLogsFalse,
},
}

cmd := ListWorkflowsCmd(ch)
cmd.SetArgs([]string{db, branch,
"--keyspace", "my-keyspace",
})
err := cmd.Execute()
c.Assert(err, qt.IsNil)
c.Assert(svc.ListWorkflowsFnInvoked, qt.IsTrue)
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
c := qt.New(t)

org := "my-org"
db := "my-db"
branch := "my-branch"

svc := &mock.VtctldService{
ListWorkflowsFn: func(ctx context.Context, req *ps.VtctldListWorkflowsRequest) (json.RawMessage, error) {
c.Assert(req.Organization, qt.Equals, org)
c.Assert(req.Database, qt.Equals, db)
c.Assert(req.Branch, qt.Equals, branch)
c.Assert(req.Keyspace, qt.Equals, "my-keyspace")
c.Assert(req.IncludeLogs, qt.DeepEquals, tt.includeLogs)
return json.RawMessage(`{"workflows":[]}`), nil
},
}

var buf bytes.Buffer
format := printer.JSON
p := printer.NewPrinter(&format)
p.SetResourceOutput(&buf)

ch := &cmdutil.Helper{
Printer: p,
Config: &config.Config{Organization: org},
Client: func() (*ps.Client, error) {
return &ps.Client{
Vtctld: svc,
}, nil
},
}

cmd := ListWorkflowsCmd(ch)
cmd.SetArgs(append([]string{db, branch}, tt.args...))

err := cmd.Execute()
c.Assert(err, qt.IsNil)
c.Assert(svc.ListWorkflowsFnInvoked, qt.IsTrue)
})
}
}
Loading