Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
Merge pull request vitessio#7575 from tinyspeck/am_vtctld_workflows
Browse files Browse the repository at this point in the history
Note (@rafael): This one required a bunch of manual intervention
[vtctld] Add v0 GetWorkflows rpc and workflow/vexec packages

Signed-off-by: Rafael Chacon <[email protected]>
  • Loading branch information
rohit-nayak-ps authored and rafael committed Apr 6, 2021
1 parent 31d5ee1 commit 71b359e
Show file tree
Hide file tree
Showing 20 changed files with 3,452 additions and 727 deletions.
69 changes: 69 additions & 0 deletions go/cmd/vtctldclient/internal/command/workflows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
Copyright 2021 The Vitess Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package command

import (
"fmt"

"github.com/spf13/cobra"

"vitess.io/vitess/go/cmd/vtctldclient/cli"

vtctldatapb "vitess.io/vitess/go/vt/proto/vtctldata"
)

var (
// GetWorkflows makes a GetWorkflows gRPC call to a vtctld.
GetWorkflows = &cobra.Command{
Use: "GetWorkflows <keyspace>",
Args: cobra.ExactArgs(1),
RunE: commandGetWorkflows,
}
)

var getWorkflowsOptions = struct {
ShowAll bool
}{}

func commandGetWorkflows(cmd *cobra.Command, args []string) error {
cli.FinishedParsing(cmd)

ks := cmd.Flags().Arg(0)

resp, err := client.GetWorkflows(commandCtx, &vtctldatapb.GetWorkflowsRequest{
Keyspace: ks,
ActiveOnly: !getWorkflowsOptions.ShowAll,
})

if err != nil {
return err
}

data, err := cli.MarshalJSON(resp)
if err != nil {
return err
}

fmt.Printf("%s\n", data)

return nil
}

func init() {
GetWorkflows.Flags().BoolVarP(&getWorkflowsOptions.ShowAll, "show-all", "a", false, "Show all workflows instead of just active workflows")
Root.AddCommand(GetWorkflows)
}
Loading

0 comments on commit 71b359e

Please sign in to comment.