Skip to content

Commit

Permalink
fix lint problom in traceectl
Browse files Browse the repository at this point in the history
  • Loading branch information
ShohamBit committed Jan 8, 2025
1 parent 0618d49 commit 59e6e3c
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 16 deletions.
9 changes: 3 additions & 6 deletions cmd/traceectl/cmd/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ var describeEventCmd = &cobra.Command{
Long: `Retrieves the detailed definition of a specific event, including its fields, types, and other metadata.`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
getEventDescriptions(cmd, args)
eventDescriptions(cmd, args)
},
}
var enableEventCmd = &cobra.Command{
Expand Down Expand Up @@ -108,7 +108,7 @@ func listEvents(cmd *cobra.Command, args []string) {
case formatter.FormatTable:
format.PrintTableHeaders([]string{"ID", "Name", "Version", "Tags"})
for _, event := range response.Definitions {
//remove descriptions
// remove descriptions
format.PrintTableRow(prepareDescription(event)[:4])
}
default:
Expand All @@ -117,7 +117,7 @@ func listEvents(cmd *cobra.Command, args []string) {
}
}

func getEventDescriptions(cmd *cobra.Command, args []string) {
func eventDescriptions(cmd *cobra.Command, args []string) {
traceeClient, err := client.NewServiceClient(server)
if err != nil {
cmd.PrintErrln("Error creating client: ", err)
Expand All @@ -129,7 +129,6 @@ func getEventDescriptions(cmd *cobra.Command, args []string) {
if err != nil {
cmd.PrintErrln("Error getting event definitions: ", err)
return

}
format, err := formatter.NewFormatter(formatFlag, cmd)
if err != nil {
Expand All @@ -147,7 +146,6 @@ func getEventDescriptions(cmd *cobra.Command, args []string) {
default:
cmd.PrintErrln("output format not supported")
return

}
}
func prepareDescription(event *pb.EventDefinition) []string {
Expand All @@ -158,7 +156,6 @@ func prepareDescription(event *pb.EventDefinition) []string {
strings.Join(event.Tags, ", "),
event.Description,
}

}
func enableEvents(cmd *cobra.Command, eventName string) {
traceeClient, err := client.NewServiceClient(server)
Expand Down
1 change: 0 additions & 1 deletion cmd/traceectl/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ func displayMetrics(cmd *cobra.Command, _ []string) {
fmt.Fprintf(cmd.OutOrStdout(), "LostWrCount: %d\n", response.LostWrCount)
fmt.Fprintf(cmd.OutOrStdout(), "LostNtCapCount: %d\n", response.LostNtCapCount)
fmt.Fprintf(cmd.OutOrStdout(), "LostBPFLogsCount: %d\n", response.LostBPFLogsCount)

}

func displayVersion(cmd *cobra.Command, _ []string) {
Expand Down
9 changes: 4 additions & 5 deletions cmd/traceectl/cmd/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ func streamEvents(cmd *cobra.Command, args []string) {
}
defer traceeClient.CloseConnection()

//request to stream events
// request to stream events
req := &pb.StreamEventsRequest{Policies: args}
stream, err := traceeClient.StreamEvents(cmd.Context(), req)
if err != nil {
cmd.PrintErrln("Error calling Stream: ", err)
return
}
//create formatter
// create formatter
format, err := formatter.NewFormatter(formatFlag, cmd)
if err != nil {
cmd.PrintErrln("Error creating formatter: ", err)
Expand All @@ -54,7 +54,7 @@ func streamEvents(cmd *cobra.Command, args []string) {
for {
res, err := stream.Recv()
if err != nil {
//End of stream\close connection
// End of stream\close connectio
if errors.Is(err, io.EOF) {
break
}
Expand All @@ -67,7 +67,7 @@ func streamEvents(cmd *cobra.Command, args []string) {
for {
res, err := stream.Recv()
if err != nil {
//End of stream\close connection
// End of stream\close connection
if errors.Is(err, io.EOF) {
break
}
Expand All @@ -88,7 +88,6 @@ func prepareEvent(event *pb.Event) []string {
strconv.Itoa(int(event.Context.Process.Pid.Value)),
getEventData(event.Data),
}

}
func getEventData(data []*pb.EventValue) string {
var result []string
Expand Down
1 change: 0 additions & 1 deletion cmd/traceectl/pkg/cmd/flags/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func determineConnectionType(server client.ServerInfo) error {
}

return fmt.Errorf("unsupported connection type: %s", server.Addr)

}
func isValidTCPAddress(addr string) bool {
host, port, err := net.SplitHostPort(addr)
Expand Down
2 changes: 1 addition & 1 deletion cmd/traceectl/pkg/cmd/formatter/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func NewFormatter(format string, cmd *cobra.Command) (*Formatter, error) {
cmd: cmd,
}, nil
case FormatTable:
//add padding for table
// add padding for table
return &Formatter{
format: format,
cmd: cmd,
Expand Down
1 change: 0 additions & 1 deletion cmd/traceectl/pkg/cmd/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,5 @@ func TestCommand(t *testing.T, testCase TestCase, rootCmd *cobra.Command) {
assert.ErrorContains(t, err, testCase.ExpectedError.Error())
} else {
assert.Contains(t, output, testCase.ExpectedPrinter)

}
}
2 changes: 1 addition & 1 deletion cmd/traceectl/pkg/mock/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

var (
ExpectedVersion string = "v0.22.0-15-gd09d7fca0d"
ExpectedVersion = "v0.22.0-15-gd09d7fca0d"
serverInfo *client.ServerInfo = &client.ServerInfo{
Addr: client.Socket,
ConnectionType: client.Protocol_UNIX,
Expand Down

0 comments on commit 59e6e3c

Please sign in to comment.