Skip to content
Merged
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
2 changes: 1 addition & 1 deletion assets/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"embed"
"strings"

"github.com/apache/skywalking-cli/internal/logger"
"github.com/apache/skywalking-cli/pkg/logger"
)

//go:embed *
Expand Down
8 changes: 7 additions & 1 deletion cmd/swctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ import (
"github.com/apache/skywalking-cli/internal/commands/records"
"github.com/apache/skywalking-cli/internal/commands/service"
"github.com/apache/skywalking-cli/internal/commands/trace"
"github.com/apache/skywalking-cli/internal/logger"
intutil "github.com/apache/skywalking-cli/internal/util"
"github.com/apache/skywalking-cli/pkg/logger"
"github.com/apache/skywalking-cli/pkg/util"

"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -173,6 +173,12 @@ func flags() []cli.Flag {
"if `authorization` is set, `--username` and `--password` are ignored",
Value: "",
}),
altsrc.NewStringFlag(&cli.StringFlag{
Name: "insecure",
Required: false,
Usage: "skip TLS certificate verification",
Value: "",
}),
altsrc.NewStringFlag(&cli.StringFlag{
Name: "timezone",
Required: false,
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/event/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ import (

"github.com/apache/skywalking-cli/internal/commands/interceptor"
"github.com/apache/skywalking-cli/internal/flags"
"github.com/apache/skywalking-cli/internal/logger"
"github.com/apache/skywalking-cli/internal/model"
"github.com/apache/skywalking-cli/pkg/display"
"github.com/apache/skywalking-cli/pkg/display/displayable"
"github.com/apache/skywalking-cli/pkg/grpc"
"github.com/apache/skywalking-cli/pkg/logger"
)

var reportCommand = &cli.Command{
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/healthcheck/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (

"github.com/apache/skywalking-cli/pkg/healthcheck"

"github.com/apache/skywalking-cli/internal/logger"
hc "github.com/apache/skywalking-cli/pkg/graphql/healthcheck"
"github.com/apache/skywalking-cli/pkg/logger"
)

var Command = &cli.Command{
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/interceptor/duration.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import (

"github.com/urfave/cli/v2"

"github.com/apache/skywalking-cli/internal/logger"
"github.com/apache/skywalking-cli/internal/model"
"github.com/apache/skywalking-cli/pkg/logger"
)

func TryParseTime(unparsed string, userStep api.Step) (api.Step, time.Time, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/interceptor/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"

"github.com/apache/skywalking-cli/internal/logger"
"github.com/apache/skywalking-cli/pkg/graphql/utils"
"github.com/apache/skywalking-cli/pkg/logger"

api "skywalking.apache.org/repo/goapi/query"
)
Expand Down
1 change: 1 addition & 0 deletions internal/commands/interceptor/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func BeforeChain(beforeFunctions ...cli.BeforeFunc) cli.BeforeFunc {
return func(cliCtx *cli.Context) error {
ctx := cliCtx.Context
ctx = context.WithValue(ctx, contextkey.BaseURL{}, cliCtx.String("base-url"))
ctx = context.WithValue(ctx, contextkey.Insecure{}, cliCtx.Bool("insecure"))
ctx = context.WithValue(ctx, contextkey.Username{}, cliCtx.String("username"))
ctx = context.WithValue(ctx, contextkey.Password{}, cliCtx.String("password"))
ctx = context.WithValue(ctx, contextkey.Authorization{}, cliCtx.String("authorization"))
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/interceptor/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
"github.com/urfave/cli/v2"
api "skywalking.apache.org/repo/goapi/query"

"github.com/apache/skywalking-cli/internal/logger"
"github.com/apache/skywalking-cli/pkg/graphql/metadata"
"github.com/apache/skywalking-cli/pkg/logger"
)

type nodeType int
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/interceptor/timezone.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (

"github.com/urfave/cli/v2"

"github.com/apache/skywalking-cli/internal/logger"
"github.com/apache/skywalking-cli/pkg/graphql/metadata"
"github.com/apache/skywalking-cli/pkg/logger"
)

// TimezoneInterceptor sets the server timezone if the server supports the API,
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/metrics/aggregation/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import (

"github.com/apache/skywalking-cli/internal/commands/interceptor"
"github.com/apache/skywalking-cli/internal/flags"
"github.com/apache/skywalking-cli/internal/logger"
"github.com/apache/skywalking-cli/internal/model"
"github.com/apache/skywalking-cli/pkg/display"
"github.com/apache/skywalking-cli/pkg/display/displayable"
"github.com/apache/skywalking-cli/pkg/graphql/metrics"
"github.com/apache/skywalking-cli/pkg/logger"
)

var SortedMetrics = &cli.Command{
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/metrics/aggregation/sampled-record.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import (

"github.com/apache/skywalking-cli/internal/commands/interceptor"
"github.com/apache/skywalking-cli/internal/flags"
"github.com/apache/skywalking-cli/internal/logger"
"github.com/apache/skywalking-cli/internal/model"
"github.com/apache/skywalking-cli/pkg/display"
"github.com/apache/skywalking-cli/pkg/display/displayable"
"github.com/apache/skywalking-cli/pkg/graphql/metadata"
"github.com/apache/skywalking-cli/pkg/graphql/metrics"
"github.com/apache/skywalking-cli/pkg/logger"
)

var SampledRecords = &cli.Command{
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/metrics/aggregation/topn.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import (

"github.com/apache/skywalking-cli/internal/commands/interceptor"
"github.com/apache/skywalking-cli/internal/flags"
"github.com/apache/skywalking-cli/internal/logger"
"github.com/apache/skywalking-cli/internal/model"
"github.com/apache/skywalking-cli/pkg/display"
"github.com/apache/skywalking-cli/pkg/display/displayable"
"github.com/apache/skywalking-cli/pkg/graphql/metrics"
"github.com/apache/skywalking-cli/pkg/logger"
)

var TopN = &cli.Command{
Expand Down
1 change: 1 addition & 0 deletions pkg/contextkey/contextkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package contextkey

type (
BaseURL struct{}
Insecure struct{}
Username struct{}
Password struct{}
Authorization struct{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/display/graph/flamegraph/flamegraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"path/filepath"
"time"

"github.com/apache/skywalking-cli/internal/logger"
"github.com/apache/skywalking-cli/pkg/logger"

api "skywalking.apache.org/repo/goapi/query"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/display/graph/tree/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
ui "github.com/gizak/termui/v3"
"github.com/gizak/termui/v3/widgets"

"github.com/apache/skywalking-cli/internal/logger"
"github.com/apache/skywalking-cli/pkg/logger"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion pkg/display/graph/tree/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
ui "github.com/gizak/termui/v3"
"github.com/gizak/termui/v3/widgets"

"github.com/apache/skywalking-cli/internal/logger"
"github.com/apache/skywalking-cli/pkg/logger"
)

type Node struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/display/table/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

d "github.com/apache/skywalking-cli/pkg/display/displayable"

"github.com/apache/skywalking-cli/internal/logger"
"github.com/apache/skywalking-cli/pkg/logger"

"github.com/olekukonko/tablewriter"
)
Expand Down
20 changes: 16 additions & 4 deletions pkg/graphql/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,32 @@ package client

import (
"context"
"crypto/tls"
"encoding/base64"
"net/http"

"github.com/machinebox/graphql"

"github.com/apache/skywalking-cli/internal/logger"
"github.com/apache/skywalking-cli/pkg/contextkey"
"github.com/apache/skywalking-cli/pkg/logger"
)

func newClient(ctx context.Context) (client *graphql.Client) {
client = graphql.NewClient(ctx.Value(contextkey.BaseURL{}).(string))
func newClient(ctx context.Context) *graphql.Client {
options := []graphql.ClientOption{}

insecure := ctx.Value(contextkey.Insecure{}).(bool)
if insecure {
customTransport := http.DefaultTransport.(*http.Transport).Clone()
customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: insecure} // #nosec G402
httpClient := &http.Client{Transport: customTransport}
options = append(options, graphql.WithHTTPClient(httpClient))
}

client := graphql.NewClient(ctx.Value(contextkey.BaseURL{}).(string), options...)
client.Log = func(msg string) {
logger.Log.Debugln(msg)
}
return
return client
}

// ExecuteQuery executes the `request` and parse to the `response`, returning `error` if there is any.
Expand Down
2 changes: 1 addition & 1 deletion pkg/graphql/dashboard/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ import (
"gopkg.in/yaml.v2"

"github.com/apache/skywalking-cli/assets"
"github.com/apache/skywalking-cli/internal/logger"
"github.com/apache/skywalking-cli/pkg/graphql/metrics"
"github.com/apache/skywalking-cli/pkg/graphql/utils"
"github.com/apache/skywalking-cli/pkg/logger"
)

type ButtonTemplate struct {
Expand Down
6 changes: 3 additions & 3 deletions pkg/graphql/utils/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ import (

api "skywalking.apache.org/repo/goapi/query"

"github.com/apache/skywalking-cli/internal/logger"
"github.com/apache/skywalking-cli/pkg/logger"
)

// MetricsValuesArrayToMap converts Array of MetricsValues into a map that uses time as key.
func MetricsValuesArrayToMap(duration api.Duration, mvArray []api.MetricsValues,
labelsMap map[string]string) map[string]map[string]*displayable.MetricValue {
labelsMap map[string]string,
) map[string]map[string]*displayable.MetricValue {
ret := make(map[string]map[string]*displayable.MetricValue, len(mvArray))
for _, mvs := range mvArray {
label := *mvs.Label
Expand All @@ -47,7 +48,6 @@ func MetricsValuesToMap(duration api.Duration, metricsValues api.MetricsValues)
ret := map[string]*displayable.MetricValue{}
format := StepFormats[duration.Step]
startTime, err := time.Parse(format, duration.Start)

if err != nil {
logger.Log.Fatalln(err)
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/healthcheck/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"crypto/tls"
"time"

"github.com/apache/skywalking-cli/internal/logger"
"github.com/apache/skywalking-cli/pkg/logger"

"google.golang.org/grpc"
"google.golang.org/grpc/codes"
Expand All @@ -43,7 +43,8 @@ func HealthCheck(addr string, enableTLS bool) int {

opts := []grpc.DialOption{
grpc.WithUserAgent("swctl_health_probe"),
grpc.WithBlock()}
grpc.WithBlock(),
}
if enableTLS {
// #nosec
creds := credentials.NewTLS(&tls.Config{
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion pkg/util/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"os/user"
"strings"

"github.com/apache/skywalking-cli/internal/logger"
"github.com/apache/skywalking-cli/pkg/logger"
)

// UserHomeDir returns the current user's home directory absolute path,
Expand Down
Loading