Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(vsctl): create ns,eb,sub with id #613

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions vsctl/command/eventbus.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package command
import (
"context"
"encoding/json"
"fmt"
"os"
"time"

Expand Down Expand Up @@ -58,7 +59,16 @@ func createEventbusCommand() *cobra.Command {
if eventbus == "" {
cmdFailedf(cmd, "the --name flag MUST be set")
}
var id uint64
if idStr != "" {
vID, err := vanus.NewIDFromString(idStr)
if err != nil {
cmdFailedWithHelpNotice(cmd, fmt.Sprintf("invalid eventbus id: %s\n", err.Error()))
}
id = vID.Uint64()
}
eb, err := client.CreateEventbus(context.Background(), &ctrlpb.CreateEventbusRequest{
Id: id,
Name: eventbus,
LogNumber: eventlogNum,
Description: description,
Expand All @@ -84,6 +94,7 @@ func createEventbusCommand() *cobra.Command {
}
},
}
cmd.Flags().StringVar(&idStr, "id", "", "eventbus id to create")
cmd.Flags().StringVar(&namespace, "namespace", "default", "namespace name to create eventbus, default name is default")
cmd.Flags().StringVar(&eventbus, "name", "", "eventbus name to create")
cmd.Flags().Int32Var(&eventlogNum, "eventlog", 1, "number of eventlog")
Expand Down
12 changes: 12 additions & 0 deletions vsctl/command/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package command
import (
"context"
"encoding/json"
"fmt"
"os"
"time"

Expand All @@ -26,6 +27,7 @@ import (
"github.com/spf13/cobra"
"google.golang.org/protobuf/types/known/emptypb"

"github.com/vanus-labs/vanus/internal/primitive/vanus"
ctrlpb "github.com/vanus-labs/vanus/proto/pkg/controller"
"github.com/vanus-labs/vanus/proto/pkg/meta"
metapb "github.com/vanus-labs/vanus/proto/pkg/meta"
Expand Down Expand Up @@ -59,7 +61,16 @@ func createNamespaceCommand() *cobra.Command {
if namespace == "" {
cmdFailedf(cmd, "the --name flag MUST be set")
}
var id uint64
if idStr != "" {
vID, err := vanus.NewIDFromString(idStr)
if err != nil {
cmdFailedWithHelpNotice(cmd, fmt.Sprintf("invalid namespace id: %s\n", err.Error()))
}
id = vID.Uint64()
}
_, err := client.CreateNamespace(context.Background(), &ctrlpb.CreateNamespaceRequest{
Id: id,
Name: namespace,
Description: description,
})
Expand All @@ -82,6 +93,7 @@ func createNamespaceCommand() *cobra.Command {
}
},
}
cmd.Flags().StringVar(&idStr, "id", "", "namespace id to create")
cmd.Flags().StringVar(&namespace, "name", "", "namespace name to creating")
cmd.Flags().StringVar(&description, "description", "", "namespace description")
return cmd
Expand Down
10 changes: 10 additions & 0 deletions vsctl/command/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,16 @@ func createSubscriptionCommand() *cobra.Command {
DisableDeadLetter: disableDeadLetter,
}
getSubscriptionConfig(cmd, config)
var id uint64
if idStr != "" {
vID, err := vanus.NewIDFromString(idStr)
if err != nil {
cmdFailedWithHelpNotice(cmd, fmt.Sprintf("invalid subscription id: %s\n", err.Error()))
}
id = vID.Uint64()
}
res, err := client.CreateSubscription(context.Background(), &ctrlpb.CreateSubscriptionRequest{
Id: id,
Subscription: &ctrlpb.SubscriptionRequest{
Config: config,
Filters: filter,
Expand All @@ -109,6 +118,7 @@ func createSubscriptionCommand() *cobra.Command {
printSubscription(cmd, false, false, false, res)
},
}
cmd.Flags().StringVar(&idStr, "id", "", "subscription id to create")
cmd.Flags().StringVar(&namespace, "namespace", "default", "namespace name, default name is default")
cmd.Flags().StringVar(&eventbus, "eventbus", "", "eventbus name to consuming")
cmd.Flags().StringVar(&sink, "sink", "", "the event you want to send to")
Expand Down