You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ke...@apache.org on 2022/08/11 08:57:07 UTC
[skywalking-cli] branch trim/licenseheader updated (6745233 -> c4b154a)
This is an automated email from the ASF dual-hosted git repository.
kezhenxu94 pushed a change to branch trim/licenseheader
in repository https://gitbox.apache.org/repos/asf/skywalking-cli.git
discard 6745233 Trim license headers in query string
new c4b154a Trim license headers in query string
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 (6745233)
\
N -- N -- N refs/heads/trim/licenseheader (c4b154a)
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:
assets/assets.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[skywalking-cli] 01/01: Trim license headers in query string
Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
kezhenxu94 pushed a commit to branch trim/licenseheader
in repository https://gitbox.apache.org/repos/asf/skywalking-cli.git
commit c4b154ab67e8ed5a8b0d659b28c0bf025bd4fcb3
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Thu Aug 11 16:57:00 2022 +0800
Trim license headers in query string
---
assets/assets.go | 16 ++++++++--
assets/assets_test.go | 65 +++++++++++++++++++++++++++++++++++++++++
go.mod | 1 +
pkg/graphql/dashboard/global.go | 4 ++-
4 files changed, 83 insertions(+), 3 deletions(-)
diff --git a/assets/assets.go b/assets/assets.go
index 5265f03..29352f4 100644
--- a/assets/assets.go
+++ b/assets/assets.go
@@ -19,6 +19,7 @@ package assets
import (
"embed"
+ "strings"
"github.com/apache/skywalking-cli/internal/logger"
)
@@ -26,11 +27,22 @@ import (
//go:embed *
var assets embed.FS
-// Read reads all content from a file under assets, which is packed in to the binary
+// Read reads all content from a file under assets, which is packed in to the binary.
+// It will also trim the consecutive lines starting with #.
func Read(filename string) string {
content, err := assets.ReadFile(filename)
if err != nil {
logger.Log.Fatalln("failed to read asset: ", filename, err)
}
- return string(content)
+ var lines []string
+ stop := false
+ for _, line := range strings.Split(string(content), "\n") {
+ if !stop && strings.HasPrefix(line, "#") {
+ continue
+ }
+ stop = true
+ lines = append(lines, line)
+ }
+
+ return strings.Join(lines, "\n")
}
diff --git a/assets/assets_test.go b/assets/assets_test.go
new file mode 100644
index 0000000..6b87025
--- /dev/null
+++ b/assets/assets_test.go
@@ -0,0 +1,65 @@
+// 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 assets
+
+import "testing"
+
+func TestRead(t *testing.T) {
+ type args struct {
+ filename string
+ }
+ tests := []struct {
+ name string
+ args args
+ want string
+ }{
+ {
+ name: "Trim license header",
+ args: args{
+ filename: "graphqls/dependency/EndpointDependency.graphql",
+ },
+ want: `
+query ($endpointId:ID!, $duration: Duration!) {
+ result: getEndpointDependencies(duration: $duration, endpointId: $endpointId) {
+ nodes {
+ id
+ name
+ serviceId
+ serviceName
+ type
+ isReal
+ }
+ calls {
+ id
+ source
+ target
+ detectPoints
+ }
+ }
+}
+`,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ if got := Read(tt.args.filename); got != tt.want {
+ t.Errorf("Read() = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}
diff --git a/go.mod b/go.mod
index 89b1960..5267337 100644
--- a/go.mod
+++ b/go.mod
@@ -20,6 +20,7 @@ require (
golang.org/x/net v0.0.0-20220421235706-1d1ef9303861 // indirect
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 // indirect
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 // indirect
+ golang.org/x/text v0.3.7
google.golang.org/grpc v1.40.0
gopkg.in/yaml.v2 v2.4.0
k8s.io/apimachinery v0.21.1
diff --git a/pkg/graphql/dashboard/global.go b/pkg/graphql/dashboard/global.go
index 13b1aad..cb3327f 100644
--- a/pkg/graphql/dashboard/global.go
+++ b/pkg/graphql/dashboard/global.go
@@ -23,6 +23,8 @@ import (
"strings"
"sync"
+ "golang.org/x/text/cases"
+ "golang.org/x/text/language"
api "skywalking.apache.org/repo/goapi/query"
"github.com/spf13/viper"
@@ -134,7 +136,7 @@ func getButtonTexts(byteValue []byte) ([]string, error) {
for s := range c {
if s != "style" {
- ret = append(ret, strings.Title(s))
+ ret = append(ret, cases.Title(language.Und).String(s))
}
}
return ret, nil