You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2022/08/28 16:36:24 UTC
[GitHub] [skywalking-banyandb] sacloudy opened a new pull request, #165: Add stream schema cli
sacloudy opened a new pull request, #165:
URL: https://github.com/apache/skywalking-banyandb/pull/165
- add cli commands for stream schema related operations.
- to fix: run stream schema ginkgo tests together may fail.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-banyandb] hanahmily commented on a diff in pull request #165: Add stream schema cli
Posted by GitBox <gi...@apache.org>.
hanahmily commented on code in PR #165:
URL: https://github.com/apache/skywalking-banyandb/pull/165#discussion_r972547385
##########
bydbctl/internal/cmd/stream_test.go:
##########
@@ -0,0 +1,240 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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 cmd_test
+
+import (
+ "context"
+ "strings"
+ "time"
+
+ "github.com/apache/skywalking-banyandb/banyand/discovery"
+ "github.com/apache/skywalking-banyandb/banyand/liaison/grpc"
+ "github.com/apache/skywalking-banyandb/banyand/liaison/http"
+ "github.com/apache/skywalking-banyandb/banyand/measure"
+ "github.com/apache/skywalking-banyandb/banyand/metadata"
+ "github.com/apache/skywalking-banyandb/banyand/query"
+ "github.com/apache/skywalking-banyandb/banyand/queue"
+ "github.com/apache/skywalking-banyandb/banyand/stream"
+ "github.com/apache/skywalking-banyandb/bydbctl/internal/cmd"
+ "github.com/apache/skywalking-banyandb/pkg/test"
+ "github.com/apache/skywalking-banyandb/pkg/test/helpers"
+ "github.com/ghodss/yaml"
+ . "github.com/onsi/ginkgo/v2"
+ . "github.com/onsi/gomega"
+ "github.com/spf13/cobra"
+ "github.com/zenizh/go-capturer"
+
+ database_v1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/database/v1"
+)
+
+var _ = Describe("Stream", func() {
+ var path string
+ var gracefulStop, deferFunc func()
+ var listenClientURL, listenPeerURL string
+ var rootCmd *cobra.Command
+ BeforeEach(func() {
+ var err error
+ path, deferFunc, err = test.NewSpace()
+ Expect(err).NotTo(HaveOccurred())
+ listenClientURL, listenPeerURL, err = test.NewEtcdListenUrls()
+ Expect(err).NotTo(HaveOccurred())
+ flags := []string{
+ "--stream-root-path=" + path, "--measure-root-path=" + path, "--metadata-root-path=" + path,
+ "--etcd-listen-client-url=" + listenClientURL, "--etcd-listen-peer-url=" + listenPeerURL,
+ }
+ gracefulStop = setup(false, flags)
+ Eventually(helpers.HTTPHealthCheck("localhost:17913"), 10*time.Second).Should(Succeed())
+ time.Sleep(1 * time.Second)
+ // extracting the operation of creating stream schema
+ rootCmd = &cobra.Command{Use: "root"}
+ cmd.RootCmdFlags(rootCmd)
+ rootCmd.SetArgs([]string{"group", "create", "-r", "{\"group\":{\"metadata\":{\"group\":\"\",\"name\":\"group1\"}}}"})
+ out := capturer.CaptureStdout(func() {
+ err := rootCmd.Execute()
+ Expect(err).NotTo(HaveOccurred())
+ })
+ Expect(out).To(Equal("{}\n"))
+ rootCmd.SetArgs([]string{"stream", "create", "-r", "{\"stream\":{\"metadata\":{\"group\":\"group1\",\"name\":\"name1\"}}}"})
+ out = capturer.CaptureStdout(func() {
+ err := rootCmd.Execute()
+ Expect(err).NotTo(HaveOccurred())
+ })
+ Expect(out).To(Equal("{}\n"))
+ })
+
+ It("get stream schema", func() {
+ rootCmd.SetArgs([]string{"stream", "get", "-r", "{\"metadata\":{\"group\":\"group1\",\"name\":\"name1\"}}"})
+ out := capturer.CaptureStdout(func() {
+ err := rootCmd.Execute()
+ Expect(err).NotTo(HaveOccurred())
+ })
+ GinkgoWriter.Write([]byte(out))
+ resp := new(database_v1.StreamRegistryServiceGetResponse)
+ Expect(yaml.Unmarshal([]byte(out), resp)).To(Succeed())
+ GinkgoWriter.Write([]byte(resp.String()))
+ Expect(resp.Stream.Metadata.Name).To(Equal("name1"))
+ Expect(resp.Stream.Metadata.Group).To(Equal("group1"))
Review Comment:
Please follow them to verify the response
##########
bydbctl/internal/cmd/stream.go:
##########
@@ -0,0 +1,242 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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 cmd
+
+import (
+ "encoding/json"
+ "errors"
+ "fmt"
+
+ "github.com/apache/skywalking-banyandb/pkg/version"
+ "github.com/ghodss/yaml"
+ "github.com/go-resty/resty/v2"
+ "github.com/spf13/cobra"
+ "github.com/spf13/viper"
+)
+
+func newStreamCmd() *cobra.Command {
+ StreamCmd := &cobra.Command{
+ Use: "stream",
+ Version: version.Build(),
+ Short: "banyandb stream schema related Operation",
+ }
+
+ StreamCreateCmd := &cobra.Command{
+ Use: "create",
+ Version: version.Build(),
+ Short: "banyandb stream schema create Operation",
+ RunE: func(_ *cobra.Command, _ []string) error {
+ return rest("stream", func(request *resty.Request) (*resty.Response, error) {
Review Comment:
Use `rest` function to tweak other commands
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-banyandb] codecov-commenter commented on pull request #165: Add stream schema cli
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #165:
URL: https://github.com/apache/skywalking-banyandb/pull/165#issuecomment-1243064941
# [Codecov](https://codecov.io/gh/apache/skywalking-banyandb/pull/165?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#165](https://codecov.io/gh/apache/skywalking-banyandb/pull/165?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (3bf0cda) into [main](https://codecov.io/gh/apache/skywalking-banyandb/commit/945857d771a5b8eb3aa6d5a34da0ed6297995176?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (945857d) will **decrease** coverage by `0.40%`.
> The diff coverage is `44.06%`.
```diff
@@ Coverage Diff @@
## main #165 +/- ##
==========================================
- Coverage 53.52% 53.12% -0.41%
==========================================
Files 86 90 +4
Lines 7869 8275 +406
==========================================
+ Hits 4212 4396 +184
- Misses 3262 3433 +171
- Partials 395 446 +51
```
| [Impacted Files](https://codecov.io/gh/apache/skywalking-banyandb/pull/165?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [banyand/metadata/schema/group.go](https://codecov.io/gh/apache/skywalking-banyandb/pull/165/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YmFueWFuZC9tZXRhZGF0YS9zY2hlbWEvZ3JvdXAuZ28=) | `61.66% <0.00%> (ø)` | |
| [bydbctl/internal/cmd/use\_group.go](https://codecov.io/gh/apache/skywalking-banyandb/pull/165/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnlkYmN0bC9pbnRlcm5hbC9jbWQvdXNlX2dyb3VwLmdv) | `25.92% <25.92%> (ø)` | |
| [banyand/metadata/schema/stream.go](https://codecov.io/gh/apache/skywalking-banyandb/pull/165/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YmFueWFuZC9tZXRhZGF0YS9zY2hlbWEvc3RyZWFtLmdv) | `46.29% <40.00%> (-0.65%)` | :arrow_down: |
| [bydbctl/internal/cmd/stream.go](https://codecov.io/gh/apache/skywalking-banyandb/pull/165/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnlkYmN0bC9pbnRlcm5hbC9jbWQvc3RyZWFtLmdv) | `41.69% <41.69%> (ø)` | |
| [bydbctl/internal/cmd/group.go](https://codecov.io/gh/apache/skywalking-banyandb/pull/165/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnlkYmN0bC9pbnRlcm5hbC9jbWQvZ3JvdXAuZ28=) | `47.69% <47.69%> (ø)` | |
| [bydbctl/internal/cmd/root.go](https://codecov.io/gh/apache/skywalking-banyandb/pull/165/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnlkYmN0bC9pbnRlcm5hbC9jbWQvcm9vdC5nbw==) | `58.33% <50.00%> (+58.33%)` | :arrow_up: |
| [banyand/measure/service.go](https://codecov.io/gh/apache/skywalking-banyandb/pull/165/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YmFueWFuZC9tZWFzdXJlL3NlcnZpY2UuZ28=) | `73.33% <100.00%> (ø)` | |
| [banyand/stream/service.go](https://codecov.io/gh/apache/skywalking-banyandb/pull/165/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YmFueWFuZC9zdHJlYW0vc2VydmljZS5nbw==) | `65.78% <100.00%> (-0.45%)` | :arrow_down: |
| [bydbctl/internal/cmd/bydb\_cmd.go](https://codecov.io/gh/apache/skywalking-banyandb/pull/165/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnlkYmN0bC9pbnRlcm5hbC9jbWQvYnlkYl9jbWQuZ28=) | `100.00% <100.00%> (ø)` | |
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-banyandb] hanahmily commented on a diff in pull request #165: Add stream schema cli
Posted by GitBox <gi...@apache.org>.
hanahmily commented on code in PR #165:
URL: https://github.com/apache/skywalking-banyandb/pull/165#discussion_r967903810
##########
bydbctl/internal/cmd/stream.go:
##########
@@ -0,0 +1,322 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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 cmd
+
+import (
+ "encoding/json"
+ "errors"
+ "fmt"
+
+ "github.com/apache/skywalking-banyandb/pkg/version"
+ "github.com/ghodss/yaml"
+ "github.com/go-resty/resty/v2"
+ "github.com/spf13/cobra"
+ "github.com/spf13/viper"
+)
+
+func newStreamCmd() *cobra.Command {
+ StreamCmd := &cobra.Command{
+ Use: "stream",
+ Version: version.Build(),
+ Short: "banyandb stream schema related Operation",
+ PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) {
+ return cmd.Parent().PersistentPreRunE(cmd.Parent(), args)
+ },
+ }
+
+ StreamCreateCmd := &cobra.Command{
+ Use: "create",
+ Version: version.Build(),
+ Short: "banyandb stream schema create Operation",
+ PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) {
+ return cmd.Parent().PersistentPreRunE(cmd.Parent(), args)
+ },
+ RunE: func(cmd *cobra.Command, args []string) (err error) {
+ client := resty.New()
+ addr, err := cmd.Flags().GetString("addr")
Review Comment:
Please use `Addr` and `JSON` as https://github.com/spf13/cobra/blob/main/user_guide.md#working-with-flags
##########
bydbctl/internal/cmd/stream.go:
##########
@@ -0,0 +1,322 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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 cmd
+
+import (
+ "encoding/json"
+ "errors"
+ "fmt"
+
+ "github.com/apache/skywalking-banyandb/pkg/version"
+ "github.com/ghodss/yaml"
+ "github.com/go-resty/resty/v2"
+ "github.com/spf13/cobra"
+ "github.com/spf13/viper"
+)
+
+func newStreamCmd() *cobra.Command {
+ StreamCmd := &cobra.Command{
+ Use: "stream",
+ Version: version.Build(),
+ Short: "banyandb stream schema related Operation",
+ PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) {
+ return cmd.Parent().PersistentPreRunE(cmd.Parent(), args)
+ },
+ }
+
+ StreamCreateCmd := &cobra.Command{
+ Use: "create",
+ Version: version.Build(),
+ Short: "banyandb stream schema create Operation",
+ PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) {
+ return cmd.Parent().PersistentPreRunE(cmd.Parent(), args)
+ },
+ RunE: func(cmd *cobra.Command, args []string) (err error) {
+ client := resty.New()
+ addr, err := cmd.Flags().GetString("addr")
+ if err != nil {
+ return err
+ }
+ body, err := cmd.Flags().GetString("json")
+ if err != nil {
+ return err
+ }
+ var data map[string]interface{}
+ err = json.Unmarshal([]byte(body), &data)
+ if err != nil {
+ return err
+ }
+ stream, ok := data["stream"].(map[string]interface{})
+ if !ok {
+ return errors.New("input json format error")
+ }
+ metadata, ok := stream["metadata"].(map[string]interface{})
+ if !ok {
+ return errors.New("input json format error")
+ }
+ _, ok = metadata["group"].(string)
+ if !ok {
+ metadata["group"] = fmt.Sprintf("%v", viper.Get("group"))
Review Comment:
Could you return an error in case the group is absent?
##########
bydbctl/internal/cmd/root.go:
##########
@@ -30,7 +33,41 @@ func NewRoot() *cobra.Command {
DisableAutoGenTag: true,
Version: version.Build(),
Short: "bydbctl is the command line tool of BanyanDB",
+ PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) {
+ viper.SetConfigType("yaml")
+ viper.SetConfigName("config")
+ configPath := os.Getenv("HOME") + "/.bydbctl"
+ viper.AddConfigPath(configPath)
+ _, err = os.Stat(configPath)
+ if !os.IsExist(err) {
+ err = os.MkdirAll(configPath, 0o777)
+ if err != nil {
+ return err
+ }
+ }
+ if err = viper.SafeWriteConfig(); err != nil {
+ if os.IsNotExist(err) {
+ err = viper.WriteConfig()
+ if err != nil {
+ return err
+ }
+ }
+ }
+ if err = viper.ReadInConfig(); err != nil {
+ if _, ok := err.(viper.ConfigFileNotFoundError); ok {
+ logger.GetLogger().Fatal().Err(err).Msg("Config file not found")
+ } else {
+ logger.GetLogger().Fatal().Err(err).Msg("Config file was found but another error was produced")
+ }
+ return err
+ }
+ return nil
+ },
}
- // cmd.AddCommand(...)
+ cmd.AddCommand(newBanyanDBCmd()...)
+ Addr := ""
Review Comment:
You should define Addr and JSON outside to share them with other commands
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-banyandb] hanahmily merged pull request #165: Add stream schema cli
Posted by GitBox <gi...@apache.org>.
hanahmily merged PR #165:
URL: https://github.com/apache/skywalking-banyandb/pull/165
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-banyandb] hanahmily commented on pull request #165: Add stream schema cli
Posted by GitBox <gi...@apache.org>.
hanahmily commented on PR #165:
URL: https://github.com/apache/skywalking-banyandb/pull/165#issuecomment-1240658648
Most cases failed to expect the first one. This might relate to the following place:
https://github.com/apache/skywalking-banyandb/blob/main/banyand/liaison/http/server.go#L125
The HTTP server blocks and the `GracefulStop` doesn't contain any operation to stop the server. Would you please use `http.Server` instead of `http.ListenAndServer` ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-banyandb] sacloudy commented on a diff in pull request #165: Add stream schema cli
Posted by GitBox <gi...@apache.org>.
sacloudy commented on code in PR #165:
URL: https://github.com/apache/skywalking-banyandb/pull/165#discussion_r961204140
##########
bydbctl/internal/cmd/root.go:
##########
@@ -30,7 +32,33 @@ func NewRoot() *cobra.Command {
DisableAutoGenTag: true,
Version: version.Build(),
Short: "bydbctl is the command line tool of BanyanDB",
+ PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) {
+ viper.SetConfigType("yaml")
+ viper.SetConfigName("config")
+ viper.AddConfigPath("$HOME/.bydbctl")
+ if err = viper.SafeWriteConfig(); err != nil {
+ if os.IsNotExist(err) {
+ err = viper.WriteConfig()
+ if err != nil {
+ return err
+ }
+ }
+ }
+ if err = viper.ReadInConfig(); err != nil {
+ if _, ok := err.(viper.ConfigFileNotFoundError); ok {
+ logger.GetLogger().Fatal().Err(err).Msg("Config file not found")
Review Comment:
I think I’ve created it in viper.SafeWriteConfig
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-banyandb] hanahmily commented on pull request #165: Add stream schema cli
Posted by GitBox <gi...@apache.org>.
hanahmily commented on PR #165:
URL: https://github.com/apache/skywalking-banyandb/pull/165#issuecomment-1229823723
@sacloudy Please fix issues raised by the checkers
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-banyandb] hanahmily commented on a diff in pull request #165: Add stream schema cli
Posted by GitBox <gi...@apache.org>.
hanahmily commented on code in PR #165:
URL: https://github.com/apache/skywalking-banyandb/pull/165#discussion_r960493288
##########
bydbctl/internal/cmd/root.go:
##########
@@ -30,7 +32,33 @@ func NewRoot() *cobra.Command {
DisableAutoGenTag: true,
Version: version.Build(),
Short: "bydbctl is the command line tool of BanyanDB",
+ PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) {
+ viper.SetConfigType("yaml")
+ viper.SetConfigName("config")
+ viper.AddConfigPath("$HOME/.bydbctl")
+ if err = viper.SafeWriteConfig(); err != nil {
+ if os.IsNotExist(err) {
+ err = viper.WriteConfig()
+ if err != nil {
+ return err
+ }
+ }
+ }
+ if err = viper.ReadInConfig(); err != nil {
+ if _, ok := err.(viper.ConfigFileNotFoundError); ok {
+ logger.GetLogger().Fatal().Err(err).Msg("Config file not found")
Review Comment:
You should create a config file if not found.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-banyandb] sacloudy commented on a diff in pull request #165: Add stream schema cli
Posted by GitBox <gi...@apache.org>.
sacloudy commented on code in PR #165:
URL: https://github.com/apache/skywalking-banyandb/pull/165#discussion_r961204140
##########
bydbctl/internal/cmd/root.go:
##########
@@ -30,7 +32,33 @@ func NewRoot() *cobra.Command {
DisableAutoGenTag: true,
Version: version.Build(),
Short: "bydbctl is the command line tool of BanyanDB",
+ PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) {
+ viper.SetConfigType("yaml")
+ viper.SetConfigName("config")
+ viper.AddConfigPath("$HOME/.bydbctl")
+ if err = viper.SafeWriteConfig(); err != nil {
+ if os.IsNotExist(err) {
+ err = viper.WriteConfig()
+ if err != nil {
+ return err
+ }
+ }
+ }
+ if err = viper.ReadInConfig(); err != nil {
+ if _, ok := err.(viper.ConfigFileNotFoundError); ok {
+ logger.GetLogger().Fatal().Err(err).Msg("Config file not found")
Review Comment:
I think I’ve created it in viper.SafeWriteConfig
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org