Skip to content

Commit

Permalink
add kubemq targets builder
Browse files Browse the repository at this point in the history
  • Loading branch information
kubemq committed Jan 27, 2021
1 parent 186e790 commit 426b7bb
Show file tree
Hide file tree
Showing 13 changed files with 686 additions and 38 deletions.
47 changes: 18 additions & 29 deletions .idea/workspace.xml

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

2 changes: 1 addition & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: '2'

vars:
BINARY_NAME: kubemqctl
VERSION: v3.3.1
VERSION: v3.4.0

tasks:
check_update:
Expand Down
13 changes: 12 additions & 1 deletion cmd/commands/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/kubemq-io/kubemqctl/pkg/config"
"github.com/kubemq-io/kubemqctl/pkg/k8s"
"github.com/kubemq-io/kubemqctl/pkg/kubemq"
"github.com/kubemq-io/kubemqctl/pkg/targets"
"github.com/kubemq-io/kubemqctl/pkg/utils"
"github.com/spf13/cobra"
"io/ioutil"
Expand All @@ -21,6 +22,7 @@ type CommandsSendOptions struct {
metadata string
timeout int
fileName string
build bool
}

var commandsSendExamples = `
Expand Down Expand Up @@ -59,6 +61,7 @@ func NewCmdCommandsSend(ctx context.Context, cfg *config.Config) *cobra.Command
cmd.PersistentFlags().StringVarP(&o.metadata, "metadata", "m", "", "Set metadata body")
cmd.PersistentFlags().IntVarP(&o.timeout, "timeout", "o", 30, "Set command timeout")
cmd.PersistentFlags().StringVarP(&o.fileName, "file", "f", "", "set load body from file")
cmd.PersistentFlags().BoolVarP(&o.build, "build", "b", false, "build kubemq targets request")
return cmd
}

Expand All @@ -70,7 +73,14 @@ func (o *CommandsSendOptions) Complete(args []string, transport string) error {
} else {
return fmt.Errorf("missing channel argument")
}

if o.build {
data, err := targets.BuildRequest()
if err != nil {
return err
}
o.body = string(data)
return nil
}
if o.fileName != "" {
data, err := ioutil.ReadFile(o.fileName)
if err != nil {
Expand Down Expand Up @@ -113,6 +123,7 @@ func (o *CommandsSendOptions) Run(ctx context.Context) error {
if err != nil {
return fmt.Errorf("sending commands body, %s", err.Error())
}
fmt.Println("Getting Response:")
printCommandResponse(res)
return nil
}
6 changes: 3 additions & 3 deletions cmd/create/cluster/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ func (o *deployOptions) validate() error {
return err
}

if o.license.licenseData == "" && o.key == "" {
return fmt.Errorf("license key is required, get a key at https://account.kubemq.io/login/register")
}
//if o.license.licenseData == "" && o.key == "" {
// return fmt.Errorf("license key is required, get a key at https://account.kubemq.io/login/register")
//}
return nil
}

Expand Down
12 changes: 11 additions & 1 deletion cmd/events/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/kubemq-io/kubemqctl/pkg/config"
"github.com/kubemq-io/kubemqctl/pkg/k8s"
"github.com/kubemq-io/kubemqctl/pkg/kubemq"
"github.com/kubemq-io/kubemqctl/pkg/targets"
"github.com/kubemq-io/kubemqctl/pkg/utils"
"github.com/spf13/cobra"
"io/ioutil"
Expand All @@ -23,6 +24,7 @@ type EventsSendOptions struct {
messages int
isStream bool
fileName string
build bool
}

var eventsSendExamples = `
Expand Down Expand Up @@ -65,6 +67,7 @@ func NewCmdEventsSend(ctx context.Context, cfg *config.Config) *cobra.Command {
cmd.PersistentFlags().IntVarP(&o.messages, "messages", "m", 1, "set how many 'events' messages to send")
cmd.PersistentFlags().BoolVarP(&o.isStream, "stream", "s", false, "set stream of all messages at once")
cmd.PersistentFlags().StringVarP(&o.fileName, "file", "f", "", "set body body from file")
cmd.PersistentFlags().BoolVarP(&o.build, "build", "b", false, "build kubemq targets request")
return cmd
}

Expand All @@ -76,7 +79,14 @@ func (o *EventsSendOptions) Complete(args []string, transport string) error {
} else {
return fmt.Errorf("missing channel argument")
}

if o.build {
data, err := targets.BuildRequest()
if err != nil {
return err
}
o.body = string(data)
return nil
}
if o.fileName != "" {
data, err := ioutil.ReadFile(o.fileName)
if err != nil {
Expand Down
12 changes: 11 additions & 1 deletion cmd/events_store/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/kubemq-io/kubemqctl/pkg/config"
"github.com/kubemq-io/kubemqctl/pkg/k8s"
"github.com/kubemq-io/kubemqctl/pkg/kubemq"
"github.com/kubemq-io/kubemqctl/pkg/targets"
"github.com/kubemq-io/kubemqctl/pkg/utils"
"github.com/spf13/cobra"
"io/ioutil"
Expand All @@ -23,6 +24,7 @@ type EventsStoreSendOptions struct {
messages int
isStream bool
fileName string
build bool
}

var eventsSendExamples = `
Expand Down Expand Up @@ -65,6 +67,7 @@ func NewCmdEventsStoreSend(ctx context.Context, cfg *config.Config) *cobra.Comma
cmd.PersistentFlags().IntVarP(&o.messages, "messages", "m", 1, "set how many 'events store' messages to send")
cmd.PersistentFlags().BoolVarP(&o.isStream, "stream", "s", false, "set stream of all messages at once")
cmd.PersistentFlags().StringVarP(&o.fileName, "file", "f", "", "set load body from file")
cmd.PersistentFlags().BoolVarP(&o.build, "build", "b", false, "build kubemq targets request")
return cmd
}

Expand All @@ -76,7 +79,14 @@ func (o *EventsStoreSendOptions) Complete(args []string, transport string) error
} else {
return fmt.Errorf("missing channel argument")
}

if o.build {
data, err := targets.BuildRequest()
if err != nil {
return err
}
o.body = string(data)
return nil
}
if o.fileName != "" {
data, err := ioutil.ReadFile(o.fileName)
if err != nil {
Expand Down
13 changes: 12 additions & 1 deletion cmd/queries/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/kubemq-io/kubemqctl/pkg/config"
"github.com/kubemq-io/kubemqctl/pkg/k8s"
"github.com/kubemq-io/kubemqctl/pkg/kubemq"
"github.com/kubemq-io/kubemqctl/pkg/targets"
"github.com/kubemq-io/kubemqctl/pkg/utils"
"github.com/spf13/cobra"
"io/ioutil"
Expand All @@ -23,6 +24,7 @@ type QueriesSendOptions struct {
cacheKey string
cacheTTL time.Duration
fileName string
build bool
}

var queriesSendExamples = `
Expand Down Expand Up @@ -66,6 +68,7 @@ func NewCmdQueriesSend(ctx context.Context, cfg *config.Config) *cobra.Command {
cmd.PersistentFlags().IntVarP(&o.timeout, "timeout", "o", 30, "set query timeout")
cmd.PersistentFlags().DurationVarP(&o.cacheTTL, "cache-duration", "d", 10*time.Minute, "set cache duration timeout")
cmd.PersistentFlags().StringVarP(&o.fileName, "file", "f", "", "set load body from file")
cmd.PersistentFlags().BoolVarP(&o.build, "build", "b", false, "build kubemq targets request")
return cmd
}

Expand All @@ -77,7 +80,14 @@ func (o *QueriesSendOptions) Complete(args []string, transport string) error {
} else {
return fmt.Errorf("missing channel argument")
}

if o.build {
data, err := targets.BuildRequest()
if err != nil {
return err
}
o.body = string(data)
return nil
}
if o.fileName != "" {
data, err := ioutil.ReadFile(o.fileName)
if err != nil {
Expand Down Expand Up @@ -120,6 +130,7 @@ func (o *QueriesSendOptions) Run(ctx context.Context) error {
if err != nil {
return fmt.Errorf("sending query body, %s", err.Error())
}
fmt.Println("Getting Response:")
printQueryResponse(res)
return nil
}
12 changes: 11 additions & 1 deletion cmd/queue/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/kubemq-io/kubemqctl/pkg/config"
"github.com/kubemq-io/kubemqctl/pkg/k8s"
"github.com/kubemq-io/kubemqctl/pkg/kubemq"
"github.com/kubemq-io/kubemqctl/pkg/targets"
"github.com/kubemq-io/kubemqctl/pkg/utils"
"github.com/spf13/cobra"
"io/ioutil"
Expand All @@ -23,6 +24,7 @@ type QueueSendOptions struct {
deadLetter string
messages int
fileName string
build bool
}

var queueSendExamples = `
Expand Down Expand Up @@ -74,6 +76,7 @@ func NewCmdQueueSend(ctx context.Context, cfg *config.Config) *cobra.Command {
cmd.PersistentFlags().StringVarP(&o.deadLetter, "dead-letter-queue", "q", "", "set dead-letter queue name")
cmd.PersistentFlags().StringVarP(&o.metadata, "metadata", "", "", "set queue message metadata field")
cmd.PersistentFlags().StringVarP(&o.fileName, "file", "f", "", "set load message body from file")
cmd.PersistentFlags().BoolVarP(&o.build, "build", "b", false, "build kubemq targets request")

return cmd
}
Expand All @@ -86,7 +89,14 @@ func (o *QueueSendOptions) Complete(args []string, transport string) error {
} else {
return fmt.Errorf("missing channel argument")
}

if o.build {
data, err := targets.BuildRequest()
if err != nil {
return err
}
o.body = string(data)
return nil
}
if o.fileName != "" {
data, err := ioutil.ReadFile(o.fileName)
if err != nil {
Expand Down
Loading

0 comments on commit 426b7bb

Please sign in to comment.