Skip to content

Commit

Permalink
Allow for update of pipeline status
Browse files Browse the repository at this point in the history
  • Loading branch information
Diana Doherty committed Mar 5, 2021
1 parent 1fdd1e7 commit 56b2204
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 18 deletions.
59 changes: 59 additions & 0 deletions cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,70 @@ var updateConnectorCmd = &cobra.Command{
},
}

var updatePipelineCmd = &cobra.Command{
Use: "pipeline <name> --state <pause|resume|restart>",
Short: "Update pipeline state",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return errors.New("requires pipeline name\n\nUsage:\n meroxa update pipeline <name> --state <state>")
}

// Pipeline Name
pipelineName := args[0]

c, err := client()
if err != nil {
return err
}

// get pipeline id from name
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()

pipeline, err := c.GetPipelineByName(ctx, pipelineName)
if err != nil {
return err
}

c, err = client()
if err != nil {
return err
}

ctx = context.Background()
ctx, cancel = context.WithTimeout(ctx, 5*time.Second)
defer cancel()

// call meroxa-go to update pipeline status with name
if !flagRootOutputJSON {
fmt.Printf("Updating %s pipeline...\n", pipelineName)
}

p, err := c.UpdatePipelineStatus(ctx, pipeline.ID, state)
if err != nil {
return err
}

if flagRootOutputJSON {
display.JSONPrint(p)
} else {
fmt.Printf("Pipeline %s successfully updated!\n", p.Name)
}

return nil
},
}

func init() {
RootCmd.AddCommand(updateCmd)

// Subcommands
updateCmd.AddCommand(updateConnectorCmd)
updateConnectorCmd.Flags().StringVarP(&state, "state", "", "", "connector state")
updateConnectorCmd.MarkFlagRequired("state")

updateCmd.AddCommand(updatePipelineCmd)
updatePipelineCmd.Flags().StringVarP(&state, "state", "", "", "pipeline state")
updatePipelineCmd.MarkFlagRequired("state")
}
1 change: 1 addition & 0 deletions docs/commands/meroxa_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ Update a component of the Meroxa platform, including connectors

* [meroxa](meroxa.md) - The Meroxa CLI
* [meroxa update connector](meroxa_update_connector.md) - Update connector state
* [meroxa update pipeline](meroxa_update_pipeline.md) - Update pipeline state

###### Auto generated by spf13/cobra on 5-Mar-2021
27 changes: 27 additions & 0 deletions docs/commands/meroxa_update_pipeline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## meroxa update pipeline

Update pipeline state

```
meroxa update pipeline <name> --state <pause|resume|restart> [flags]
```

### Options

```
-h, --help help for pipeline
--state string pipeline state
```

### Options inherited from parent commands

```
--config string config file (default is $HOME/meroxa.env)
--json output json
```

### SEE ALSO

* [meroxa update](meroxa_update.md) - Update a component

###### Auto generated by spf13/cobra on 5-Mar-2021
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/magiconair/properties v1.8.4 // indirect
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mattn/go-runewidth v0.0.10 // indirect
github.com/meroxa/meroxa-go v0.0.0-20210305003756-7aa7db040d66
github.com/meroxa/meroxa-go v0.0.0-20210305152335-b84fb1af9381
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/nirasan/go-oauth-pkce-code-verifier v0.0.0-20170819232839-0fbfe93532da
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
github.com/mattn/go-runewidth v0.0.10 h1:CoZ3S2P7pvtP45xOtBw+/mDL2z0RKI576gSkzRRpdGg=
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/meroxa/meroxa-go v0.0.0-20210305003756-7aa7db040d66 h1:HxkaYeaLc5j2Tyn/4AunRhtcR2u739ng8dWJcrsGNC4=
github.com/meroxa/meroxa-go v0.0.0-20210305003756-7aa7db040d66/go.mod h1:yzdHMk8vDvV8iODTBDpkhpGoZed2aB+WR7y7fIN88pc=
github.com/meroxa/meroxa-go v0.0.0-20210305152335-b84fb1af9381 h1:qH0uj4i3tnugzibCHrwZartwmog0MqSSu5Y2VLF81rg=
github.com/meroxa/meroxa-go v0.0.0-20210305152335-b84fb1af9381/go.mod h1:yzdHMk8vDvV8iODTBDpkhpGoZed2aB+WR7y7fIN88pc=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
Expand Down
54 changes: 40 additions & 14 deletions vendor/github.com/meroxa/meroxa-go/pipeline.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ github.com/mattn/go-colorable
github.com/mattn/go-isatty
# github.com/mattn/go-runewidth v0.0.10
github.com/mattn/go-runewidth
# github.com/meroxa/meroxa-go v0.0.0-20210305003756-7aa7db040d66
# github.com/meroxa/meroxa-go v0.0.0-20210305152335-b84fb1af9381
github.com/meroxa/meroxa-go
# github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/go-homedir
Expand Down

0 comments on commit 56b2204

Please sign in to comment.