This is an automated email from the ASF dual-hosted git repository.
liuhan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-cli.git
The following commit(s) were added to refs/heads/master by this push:
new faa4794 Add get menu items command (#187)
faa4794 is described below
commit faa4794813dc4cf74bbcab3a26a283b6afea7e03
Author: mrproliu <[email protected]>
AuthorDate: Tue Jun 27 12:06:01 2023 +0000
Add get menu items command (#187)
---
CHANGES.md | 10 +++++++-
README.md | 1 +
assets/graphqls/menu/GetItems.graphql | 31 +++++++++++++++++++++++++
cmd/swctl/main.go | 2 ++
dist/LICENSE | 4 ++--
go.mod | 4 ++--
go.sum | 8 +++----
internal/commands/menu/get.go | 43 +++++++++++++++++++++++++++++++++++
internal/commands/menu/menu.go | 28 +++++++++++++++++++++++
pkg/graphql/menu/menu.go | 38 +++++++++++++++++++++++++++++++
10 files changed, 160 insertions(+), 9 deletions(-)
diff --git a/CHANGES.md b/CHANGES.md
index bce6a96..42bc400 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -2,7 +2,15 @@ Changes by Version
==================
Release Notes.
-0.11.0
+0.13.0
+------------------
+
+### Features
+## What's Changed
+
+* Add the sub-command `menu get` for get the ui menu items by @mrproliu in
https://github.com/apache/skywalking-cli/pull/187
+
+0.12.0
------------------
### Features
diff --git a/README.md b/README.md
index 40bc01e..06a061f 100644
--- a/README.md
+++ b/README.md
@@ -163,6 +163,7 @@ SkyWalking CLI and SkyWalking OAP communicate with
different query version, here
| \> = 0.11.0 | \> = 9.2.0 |
| \> = 0.12.0 | \> = 9.3.0 |
| \> = 0.12.0 | \> = 9.5.0 |
+| \> = 0.13.0 | \> = 9.6.0 |
# Contributing
diff --git a/assets/graphqls/menu/GetItems.graphql
b/assets/graphqls/menu/GetItems.graphql
new file mode 100644
index 0000000..e819aef
--- /dev/null
+++ b/assets/graphqls/menu/GetItems.graphql
@@ -0,0 +1,31 @@
+# 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.
+
+query {
+ result: getMenuItems {
+ name
+ icon
+ path
+ activate
+ subItems {
+ name
+ icon
+ path
+ activate
+ }
+ }
+}
diff --git a/cmd/swctl/main.go b/cmd/swctl/main.go
index 32674e4..0dd5055 100644
--- a/cmd/swctl/main.go
+++ b/cmd/swctl/main.go
@@ -35,6 +35,7 @@ import (
"github.com/apache/skywalking-cli/internal/commands/interceptor"
"github.com/apache/skywalking-cli/internal/commands/layer"
"github.com/apache/skywalking-cli/internal/commands/logs"
+ "github.com/apache/skywalking-cli/internal/commands/menu"
"github.com/apache/skywalking-cli/internal/commands/metrics"
"github.com/apache/skywalking-cli/internal/commands/process"
"github.com/apache/skywalking-cli/internal/commands/profiling"
@@ -106,6 +107,7 @@ services, service instances, etc.`
process.Command,
profiling.Command,
records.Command,
+ menu.Command,
}
app.Before = interceptor.BeforeChain(
diff --git a/dist/LICENSE b/dist/LICENSE
index 2889d81..f9c2588 100644
--- a/dist/LICENSE
+++ b/dist/LICENSE
@@ -213,7 +213,7 @@ The text of each license is also included at
licenses/license-[project].txt.
k8s.io/utils v0.0.0-20210802155522-efc7438f0176 Apache-2.0
sigs.k8s.io/controller-runtime v0.10.0 Apache-2.0
sigs.k8s.io/structured-merge-diff/v4 v4.1.2 Apache-2.0
- skywalking.apache.org/repo/goapi v0.0.0-20230612142312-4a524db7a92c
Apache-2.0
+ skywalking.apache.org/repo/goapi v0.0.0-20230627041834-548963a0d5d7
Apache-2.0
========================================================================
BSD-2-Clause licenses
@@ -250,7 +250,7 @@ The text of each license is also included at
licenses/license-[project].txt.
golang.org/x/term v0.5.0 BSD-3-Clause
golang.org/x/text v0.7.0 BSD-3-Clause
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac BSD-3-Clause
- google.golang.org/protobuf v1.30.0 BSD-3-Clause
+ google.golang.org/protobuf v1.31.0 BSD-3-Clause
gopkg.in/inf.v0 v0.9.1 BSD-3-Clause
========================================================================
diff --git a/go.mod b/go.mod
index 6dda07c..6b72ff2 100644
--- a/go.mod
+++ b/go.mod
@@ -20,7 +20,7 @@ require (
gopkg.in/yaml.v2 v2.4.0
k8s.io/apimachinery v0.22.1
sigs.k8s.io/controller-runtime v0.10.0
- skywalking.apache.org/repo/goapi v0.0.0-20230612142312-4a524db7a92c
+ skywalking.apache.org/repo/goapi v0.0.0-20230627041834-548963a0d5d7
)
require (
@@ -77,7 +77,7 @@ require (
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84 //
indirect
- google.golang.org/protobuf v1.30.0 // indirect
+ google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.51.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
diff --git a/go.sum b/go.sum
index 1344a45..426aa26 100644
--- a/go.sum
+++ b/go.sum
@@ -789,8 +789,8 @@ google.golang.org/protobuf v1.24.0/go.mod
h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
google.golang.org/protobuf v1.25.0/go.mod
h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod
h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod
h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
-google.golang.org/protobuf v1.30.0
h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
-google.golang.org/protobuf v1.30.0/go.mod
h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
+google.golang.org/protobuf v1.31.0
h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
+google.golang.org/protobuf v1.31.0/go.mod
h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod
h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod
h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod
h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
@@ -864,5 +864,5 @@ sigs.k8s.io/structured-merge-diff/v4 v4.1.2
h1:Hr/htKFmJEbtMgS/UD0N+gtgctAqz81t3
sigs.k8s.io/structured-merge-diff/v4 v4.1.2/go.mod
h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4=
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
-skywalking.apache.org/repo/goapi v0.0.0-20230612142312-4a524db7a92c
h1:5ZqcUo6Uevrvlj4T2KV9XS/bRcmpfIEAGRaxDOf9Zr4=
-skywalking.apache.org/repo/goapi v0.0.0-20230612142312-4a524db7a92c/go.mod
h1:bW4dg0GUN4rMCMS8DLlaY3ZiKUAJ1fQYKoZ91Bl0kTk=
+skywalking.apache.org/repo/goapi v0.0.0-20230627041834-548963a0d5d7
h1:ohL/krc7Pi032rl4zuYdzsS2R/HXcwGWY9UnW3JcvL0=
+skywalking.apache.org/repo/goapi v0.0.0-20230627041834-548963a0d5d7/go.mod
h1:onFubXaIoY/2FTRVrLMqCTlaNq4SilAEwF/2G0IcaBw=
diff --git a/internal/commands/menu/get.go b/internal/commands/menu/get.go
new file mode 100644
index 0000000..151b2b0
--- /dev/null
+++ b/internal/commands/menu/get.go
@@ -0,0 +1,43 @@
+// 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 menu
+
+import (
+ "github.com/apache/skywalking-cli/pkg/display"
+ "github.com/apache/skywalking-cli/pkg/display/displayable"
+ "github.com/apache/skywalking-cli/pkg/graphql/menu"
+
+ "github.com/urfave/cli/v2"
+)
+
+var Get = &cli.Command{
+ Name: "get",
+ Usage: "Get the UI menu items",
+ UsageText: `Get the UI menu items.
+
+Examples:
+1. Get the UI menu items:
+$swctl menu get`,
+ Action: func(ctx *cli.Context) error {
+ menuItems, err := menu.GetItems(ctx)
+ if err != nil {
+ return err
+ }
+ return display.Display(ctx, &displayable.Displayable{Data:
menuItems})
+ },
+}
diff --git a/internal/commands/menu/menu.go b/internal/commands/menu/menu.go
new file mode 100644
index 0000000..e281424
--- /dev/null
+++ b/internal/commands/menu/menu.go
@@ -0,0 +1,28 @@
+// 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 menu
+
+import "github.com/urfave/cli/v2"
+
+var Command = &cli.Command{
+ Name: "menu",
+ Usage: "Management the UI menu",
+ Subcommands: cli.Commands{
+ Get,
+ },
+}
diff --git a/pkg/graphql/menu/menu.go b/pkg/graphql/menu/menu.go
new file mode 100644
index 0000000..614174e
--- /dev/null
+++ b/pkg/graphql/menu/menu.go
@@ -0,0 +1,38 @@
+// 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 menu
+
+import (
+ "github.com/apache/skywalking-cli/assets"
+ "github.com/apache/skywalking-cli/pkg/graphql/client"
+
+ "github.com/machinebox/graphql"
+
+ "github.com/urfave/cli/v2"
+
+ api "skywalking.apache.org/repo/goapi/query"
+)
+
+func GetItems(ctx *cli.Context) ([]*api.MenuItem, error) {
+ var response map[string][]*api.MenuItem
+
+ request :=
graphql.NewRequest(assets.Read("graphqls/menu/GetItems.graphql"))
+
+ err := client.ExecuteQuery(ctx, request, &response)
+ return response["result"], err
+}