Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default flag values for fastedge app logs and sort parameter sanitization #28

Merged
merged 4 commits into from
Mar 19, 2024
Merged
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
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")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please hide this flag for now using https://pkg.go.dev/github.com/spf13/pflag#FlagSet.MarkHidden , I'm not sure we need to show it. Let's clarify first that it doesn't violate GDPR. It is easier to un-hide it later than remove

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