Skip to content

Commit

Permalink
Default flag values for fastedge app logs and sort parameter sanitiza…
Browse files Browse the repository at this point in the history
…tion (#28)

* Default flag values for fastedge app logs and sort parameter sanitization

* Imporing proper packages for errors
  • Loading branch information
KenanHH authored Mar 19, 2024
1 parent b6ef3c5 commit baa4d73
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions internal/commands/fastedge/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package fastedge
import (
"bufio"
"context"
"errors"
"fmt"
"net/http"
"os"
Expand All @@ -16,11 +17,12 @@ import (
)

func appLogsFilterFlags(cmd *cobra.Command) {
cmd.Flags().StringP("from", "", "", "From time")
cmd.Flags().StringP("to", "", "", "To time")
cmd.Flags().StringP("sort", "", "asc", "Sort order")
cmd.Flags().StringP("edge", "", "", "Edge name")
cmd.Flags().StringP("client-ip", "", "", "Client IP")
cmd.Flags().String("from", "today", "Reporting period start, UTC")
cmd.Flags().String("to", "now", "Reporting period end, UTC")
cmd.Flags().String("sort", "asc", "Log sort order, asc or desc")
cmd.Flags().String("edge", "", "Edge name filter")
cmd.Flags().String("client-ip", "", "Client IP filter")
cmd.Flags().MarkHidden("client-ip")
}

// logs-related commands
Expand Down Expand Up @@ -71,6 +73,9 @@ This command allows you filtering by edge name, client ip and time range.`,

if sortFlag != "" {
logParamSort := sdk.GetV1AppsIdLogsParamsSort(sortFlag)
if logParamSort != sdk.Asc && logParamSort != sdk.Desc {
return errors.New("invalid value for `sort` expected asc or desc")
}
sort = &logParamSort
}

Expand Down

0 comments on commit baa4d73

Please sign in to comment.