You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ha...@apache.org on 2023/07/06 10:23:07 UTC

[skywalking-banyandb] branch property updated (a326a653 -> f23e26c2)

This is an automated email from the ASF dual-hosted git repository.

hanahmily pushed a change to branch property
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git


 discard a326a653 List all properties in a group
     new f23e26c2 List all properties in a group

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (a326a653)
            \
             N -- N -- N   refs/heads/property (f23e26c2)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 docs/crud/property.md | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)


[skywalking-banyandb] 01/01: List all properties in a group

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hanahmily pushed a commit to branch property
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git

commit f23e26c262bcecab369638eade961a3eba16dfdf
Author: Gao Hongtao <ha...@gmail.com>
AuthorDate: Sun Jul 2 07:21:00 2023 +0000

    List all properties in a group
    
    Signed-off-by: Gao Hongtao <ha...@gmail.com>
---
 CHANGES.md                                |  6 +++++
 api/proto/banyandb/common/v1/common.proto |  2 +-
 api/proto/banyandb/property/v1/rpc.proto  |  3 +++
 bydbctl/internal/cmd/property.go          |  6 ++++-
 bydbctl/internal/cmd/property_test.go     | 40 ++++++++++++++++++++++++++++++-
 bydbctl/internal/cmd/root.go              |  8 +++++++
 docs/crud/property.md                     | 12 ++++++++--
 test/integration/other/property_test.go   |  9 ++++++-
 8 files changed, 80 insertions(+), 6 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index 429c2781..7d88f264 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -2,6 +2,12 @@
 
 Release Notes.
 
+## 0.5.0
+
+### Features
+
+- List all properties in a group.
+
 ## 0.4.0
 
 ### Features
diff --git a/api/proto/banyandb/common/v1/common.proto b/api/proto/banyandb/common/v1/common.proto
index fb8572f3..16fe8e67 100644
--- a/api/proto/banyandb/common/v1/common.proto
+++ b/api/proto/banyandb/common/v1/common.proto
@@ -36,7 +36,7 @@ message Metadata {
   // group contains a set of options, like retention policy, max
   string group = 1;
   // name of the entity
-  string name = 2 [(validate.rules).string.min_len = 1];
+  string name = 2;
   uint32 id = 3;
   // readonly. create_revision is the revision of last creation on this key.
   int64 create_revision = 4;
diff --git a/api/proto/banyandb/property/v1/rpc.proto b/api/proto/banyandb/property/v1/rpc.proto
index 10a09c78..8151c8bc 100644
--- a/api/proto/banyandb/property/v1/rpc.proto
+++ b/api/proto/banyandb/property/v1/rpc.proto
@@ -102,6 +102,9 @@ service PropertyService {
   rpc List(ListRequest) returns (ListResponse) {
     option (google.api.http) = {
       get: "/v1/property/lists/{container.group}/{container.name}/{ids}/{tags}"
+      additional_bindings {
+        get: "/v1/property/lists/{container.group}"
+      }
     };
   }
 }
diff --git a/bydbctl/internal/cmd/property.go b/bydbctl/internal/cmd/property.go
index 47fa68fd..27c8420d 100644
--- a/bydbctl/internal/cmd/property.go
+++ b/bydbctl/internal/cmd/property.go
@@ -35,6 +35,7 @@ var (
 	propertySchemaPathWithoutTagParams  = propertySchemaPath + "/{group}/{name}/{id}"
 	propertySchemaPathWithTagParams     = propertySchemaPath + "/{group}/{name}/{id}/{tag}"
 	propertyListSchemaPathWithTagParams = propertySchemaPath + "/lists/{group}/{name}/{ids}/{tags}"
+	propertyListSchemaPath              = propertySchemaPath + "/lists/{group}"
 )
 
 func newPropertyCmd() *cobra.Command {
@@ -103,12 +104,15 @@ func newPropertyCmd() *cobra.Command {
 		Short:   "List properties",
 		RunE: func(_ *cobra.Command, _ []string) (err error) {
 			return rest(parseFromFlags, func(request request) (*resty.Response, error) {
+				if len(request.name) == 0 {
+					return request.req.SetPathParam("group", request.group).Get(getPath(propertyListSchemaPath))
+				}
 				return request.req.SetPathParam("name", request.name).SetPathParam("group", request.group).
 					SetPathParam("ids", request.ids()).SetPathParam("tags", request.tags()).Get(getPath(propertyListSchemaPathWithTagParams))
 			}, yamlPrinter)
 		},
 	}
-	bindNameFlag(listCmd)
+	listCmd.Flags().StringVarP(&name, "name", "n", "", "the name of the resource")
 	listCmd.Flags().StringArrayVarP(&ids, "ids", "", nil, "id selector")
 	listCmd.Flags().StringArrayVarP(&tags, "tags", "t", nil, "tag selector")
 
diff --git a/bydbctl/internal/cmd/property_test.go b/bydbctl/internal/cmd/property_test.go
index 614375d1..191591c6 100644
--- a/bydbctl/internal/cmd/property_test.go
+++ b/bydbctl/internal/cmd/property_test.go
@@ -201,7 +201,44 @@ tags:
 		Expect(err).To(MatchError("rpc error: code = NotFound desc = banyandb: resource not found"))
 	})
 
-	It("list property", func() {
+	It("list all properties", func() {
+		// create another property for list operation
+		rootCmd.SetArgs([]string{"property", "apply", "-f", "-"})
+		rootCmd.SetIn(strings.NewReader(`
+metadata:
+  container:
+    group: ui-template 
+    name: service
+  id: spring
+tags:
+  - key: content
+    value:
+      str:
+        value: bar
+  - key: state
+    value:
+      int:
+        value: 1
+`))
+		out := capturer.CaptureStdout(func() {
+			err := rootCmd.Execute()
+			Expect(err).NotTo(HaveOccurred())
+		})
+		Expect(out).To(ContainSubstring("created: true"))
+		Expect(out).To(ContainSubstring("tagsNum: 2"))
+		// list
+		rootCmd.SetArgs([]string{"property", "list", "-g", "ui-template"})
+		out = capturer.CaptureStdout(func() {
+			cmd.ResetFlags()
+			err := rootCmd.Execute()
+			Expect(err).NotTo(HaveOccurred())
+		})
+		resp := new(propertyv1.ListResponse)
+		helpers.UnmarshalYAML([]byte(out), resp)
+		Expect(resp.Property).To(HaveLen(2))
+	})
+
+	It("list properties in a container", func() {
 		// create another property for list operation
 		rootCmd.SetArgs([]string{"property", "apply", "-f", "-"})
 		rootCmd.SetIn(strings.NewReader(`
@@ -229,6 +266,7 @@ tags:
 		// list
 		rootCmd.SetArgs([]string{"property", "list", "-g", "ui-template", "-n", "service"})
 		out = capturer.CaptureStdout(func() {
+			cmd.ResetFlags()
 			err := rootCmd.Execute()
 			Expect(err).NotTo(HaveOccurred())
 		})
diff --git a/bydbctl/internal/cmd/root.go b/bydbctl/internal/cmd/root.go
index 7c7a16e2..c7956d8c 100644
--- a/bydbctl/internal/cmd/root.go
+++ b/bydbctl/internal/cmd/root.go
@@ -42,6 +42,14 @@ var (
 	}
 )
 
+// ResetFlags resets the flags.
+func ResetFlags() {
+	filePath = ""
+	name = ""
+	start = ""
+	end = ""
+}
+
 // Execute executes the root command.
 func Execute() error {
 	return rootCmd.Execute()
diff --git a/docs/crud/property.md b/docs/crud/property.md
index 05378438..7f28d856 100644
--- a/docs/crud/property.md
+++ b/docs/crud/property.md
@@ -95,9 +95,17 @@ $ bydbctl property delete -g sw -n ui_template --id General-Service --tags state
 
 ## List operation
 
-List operation lists all properties.
+List operation lists all properties in a group.
 
-### Examples of listing
+### Examples of listing in a group
+
+```shell
+$ bydbctl property list -g sw
+```
+
+List operation lists all properties in a group with a name.
+
+### Examples of listing in a group with a name
 
 ```shell
 $ bydbctl property list -g sw -n ui_template
diff --git a/test/integration/other/property_test.go b/test/integration/other/property_test.go
index d7ec7c66..79f8f38b 100644
--- a/test/integration/other/property_test.go
+++ b/test/integration/other/property_test.go
@@ -140,7 +140,14 @@ var _ = Describe("Property application", func() {
 		Expect(conn.Close()).To(Succeed())
 		deferFn()
 	})
-	It("lists properties", func() {
+	It("lists properties in a group", func() {
+		got, err := client.List(context.Background(), &propertyv1.ListRequest{Container: &commonv1.Metadata{
+			Group: "g",
+		}})
+		Expect(err).NotTo(HaveOccurred())
+		Expect(len(got.Property)).To(Equal(1))
+	})
+	It("lists properties in a container", func() {
 		got, err := client.List(context.Background(), &propertyv1.ListRequest{Container: md.Container})
 		Expect(err).NotTo(HaveOccurred())
 		Expect(len(got.Property)).To(Equal(1))