Skip to content

Commit f880db0

Browse files
authored
Fix sorting of audit log (#91)
* Format all the things Signed-off-by: Jan Steffen <[email protected]> * Adjust sorting Signed-off-by: Jan Steffen <[email protected]> * Update dependency Signed-off-by: Jan Steffen <[email protected]>
1 parent 4804904 commit f880db0

30 files changed

+125
-110
lines changed

cmd/monoctl/auth/status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ package auth
1717
import (
1818
"fmt"
1919

20-
"github.com/spf13/cobra"
2120
"github.com/finleap-connect/monoctl/cmd/monoctl/flags"
2221
"github.com/finleap-connect/monoctl/internal/config"
22+
"github.com/spf13/cobra"
2323
)
2424

2525
func NewAuthStatusCmd() *cobra.Command {

cmd/monoctl/create/cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ import (
2121
"io/ioutil"
2222
"net/url"
2323

24-
"github.com/spf13/cobra"
2524
"github.com/finleap-connect/monoctl/cmd/monoctl/flags"
2625
"github.com/finleap-connect/monoctl/internal/config"
2726
"github.com/finleap-connect/monoctl/internal/usecases"
2827
auth_util "github.com/finleap-connect/monoctl/internal/util/auth"
2928
"github.com/finleap-connect/monoskope/pkg/k8s"
29+
"github.com/spf13/cobra"
3030
)
3131

3232
func NewCreateClusterCmd() *cobra.Command {

cmd/monoctl/get/audit_log.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ package get
1717
import (
1818
"context"
1919
"fmt"
20-
"github.com/finleap-connect/monoctl/internal/output"
2120
"time"
2221

22+
"github.com/finleap-connect/monoctl/internal/output"
23+
2324
"github.com/finleap-connect/monoctl/cmd/monoctl/flags"
2425
"github.com/finleap-connect/monoctl/internal/config"
2526
"github.com/finleap-connect/monoctl/internal/usecases"
@@ -35,7 +36,9 @@ var (
3536
now = time.Now().UTC()
3637
firstOfMonth = time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, time.UTC)
3738
lastOfMonth = firstOfMonth.AddDate(0, 1, -1)
38-
dateInputErr = func(input string) error { return fmt.Errorf("%s is invalid.\nPlease make sure to use the correct date layout. Example: %s", input, now.Format(dateLayoutISO8601)) }
39+
dateInputErr = func(input string) error {
40+
return fmt.Errorf("%s is invalid.\nPlease make sure to use the correct date layout. Example: %s", input, now.Format(dateLayoutISO8601))
41+
}
3942
)
4043

4144
func getAuditLogOptions() (*output.AuditLogOptions, error) {
@@ -52,7 +55,7 @@ func NewGetAuditLogCmd() *cobra.Command {
5255
Use: "audit-log",
5356
Aliases: []string{"audit"},
5457
Short: "Get audit log",
55-
Long: `Get audit log based on a date range. If no date range is specified the audit log of the current month will be returned. Please note that both input and output time is in UTC and should be considered when e.g. specifying the date range`,
58+
Long: `Get audit log within specified date range. If no date range is specified the audit log of the current month will be returned.`,
5659
RunE: func(cmd *cobra.Command, args []string) error {
5760
auditLogOptions, err := getAuditLogOptions()
5861
if err != nil {
@@ -72,9 +75,9 @@ func NewGetAuditLogCmd() *cobra.Command {
7275

7376
persistentFlags := cmd.PersistentFlags()
7477
persistentFlags.StringVarP(&from, "from", "f", firstOfMonth.Format(dateLayoutISO8601),
75-
fmt.Sprintf("Specifys the starting point of the date range. If not specified the first day of the current month is used. Accepted layout: %s", now.Format(dateLayoutISO8601)))
78+
fmt.Sprintf("Specifies the starting point of the date range (UTC). If not specified the first day of the current month is used. Accepted layout: %s", now.Format(dateLayoutISO8601)))
7679
persistentFlags.StringVarP(&to, "to", "t", lastOfMonth.Format(dateLayoutISO8601),
77-
fmt.Sprintf("Specifys the ending point of the date range. If not specified the last day of the current month is used. Accepted layout: %s", now.Format(dateLayoutISO8601)))
80+
fmt.Sprintf("Specifies the ending point of the date range (UTC). If not specified the last day of the current month is used. Accepted layout: %s", now.Format(dateLayoutISO8601)))
7881

7982
return cmd
8083
}

cmd/monoctl/get/audit_log_by_user.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ import (
2929
func NewGetAuditLogByUserCmd() *cobra.Command {
3030
cmd := &cobra.Command{
3131
Use: "user [EMAIL]",
32-
Short: "Get audit log by a user.",
33-
Long: `Get audit log by a user including information like who created the user, gave him/her roles and when`,
32+
Short: "Get audit log about a user.",
33+
Long: `Get audit log about a user returns every information tied to the lifecycle of the given user`,
3434
Args: cobra.ExactArgs(1),
3535
RunE: func(cmd *cobra.Command, args []string) error {
3636
if !strings.Contains(args[0], "@") {

cmd/monoctl/get/audit_log_user_actions.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ import (
2828

2929
func NewGetAuditLogUserActionsCmd() *cobra.Command {
3030
cmd := &cobra.Command{
31-
Use: "user-actions [EMAIL]",
32-
Short: "Get audit log of user actions.",
33-
Long: `Get audit log of everything a user has done. Please note that the date range is for now limited to one year max.`,
34-
Args: cobra.ExactArgs(1),
31+
Use: "user-actions [EMAIL]",
32+
Short: "Get audit log of user actions.",
33+
Long: `Get audit log of everything a user has done. Please note that the date range is for now limited to one year max.`,
34+
Args: cobra.ExactArgs(1),
3535
RunE: func(cmd *cobra.Command, args []string) error {
3636
if !strings.Contains(args[0], "@") {
3737
return fmt.Errorf("'%s' is not a valid email", args[0])

cmd/monoctl/get/audit_log_users_overview.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,21 @@ package get
1717
import (
1818
"context"
1919
"fmt"
20+
"time"
21+
2022
"github.com/finleap-connect/monoctl/cmd/monoctl/flags"
2123
"github.com/finleap-connect/monoctl/internal/config"
2224
"github.com/finleap-connect/monoctl/internal/usecases"
2325
auth_util "github.com/finleap-connect/monoctl/internal/util/auth"
2426
"github.com/spf13/cobra"
25-
"time"
2627
)
2728

2829
func NewGetAuditLogUsersOverviewCmd() *cobra.Command {
2930
cmd := &cobra.Command{
30-
Use: "users-overview [TIMESTAMP]",
31-
Short: "Get audit log overview of all users at a timestamp.",
32-
Long: fmt.Sprintf(`Get audit log overview of all users at a timestamp, tenants/clusters they belong to, and their roles within the system or tenant/cluster. Accepted layout: %s`, now.Format(time.RFC3339)),
33-
Args: cobra.ExactArgs(1),
31+
Use: "users-overview [TIMESTAMP]",
32+
Short: "Get audit log overview of all users at a given point in time.",
33+
Long: fmt.Sprintf(`Get audit log overview of all users at a given point in time, tenants/clusters they belong to, and their roles within the system or tenant/cluster. Accepted layout: %s`, now.Format(time.RFC3339)),
34+
Args: cobra.ExactArgs(1),
3435
RunE: func(cmd *cobra.Command, args []string) error {
3536
timestamp, err := time.Parse(time.RFC3339, args[0])
3637
if err != nil {

cmd/monoctl/update/cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ import (
2121
"io/ioutil"
2222
"net/url"
2323

24-
"github.com/spf13/cobra"
2524
"github.com/finleap-connect/monoctl/cmd/monoctl/flags"
2625
"github.com/finleap-connect/monoctl/internal/config"
2726
"github.com/finleap-connect/monoctl/internal/usecases"
2827
auth_util "github.com/finleap-connect/monoctl/internal/util/auth"
28+
"github.com/spf13/cobra"
2929
)
3030

3131
func NewUpdateClusterCmd() *cobra.Command {

cmd/monoctl/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ package main
1717
import (
1818
"context"
1919

20-
"github.com/spf13/cobra"
2120
"github.com/finleap-connect/monoctl/cmd/monoctl/flags"
2221
"github.com/finleap-connect/monoctl/internal/config"
2322
"github.com/finleap-connect/monoctl/internal/usecases"
2423
auth_util "github.com/finleap-connect/monoctl/internal/util/auth"
2524
"github.com/finleap-connect/monoctl/internal/version"
25+
"github.com/spf13/cobra"
2626
)
2727

2828
func NewVersionCmd() *cobra.Command {

go.mk

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,13 @@ mod: ## Do go mod tidy, download, verify
4141
$(GO) mod download
4242
$(GO) mod verify
4343

44-
vet: ## Do go ver
44+
fmt: ## Do go vet
45+
$(GO) fmt ./...
46+
47+
vet: ## Do go vet
4548
$(GO) vet ./...
4649

47-
go: mod vet lint test ## Do go mod / vet / lint /test
50+
go: mod fmt vet lint test ## Do go mod / fmt / vet / lint /test
4851

4952
run: ## run monoctl, use `ARGS="get user"` to pass arguments
5053
$(GO) run -ldflags "$(LDFLAGS)" cmd/monoctl/*.go $(ARGS)
@@ -72,7 +75,7 @@ gomock-get: ## download gomock
7275
$(shell $(TOOLS_DIR)/goget-wrapper github.com/golang/mock/mockgen@$(GOMOCK_VERSION))
7376

7477
lint: $(LINTER) ## go lint
75-
$(LINTER) run -v -E goconst -E misspell
78+
$(LINTER) run -v -E goconst -E misspell -E gofmt
7679

7780
tools: golangci-lint-get ginkgo-get gomock-get ## Target to install all required tools into TOOLS_DIR
7881

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.18
44

55
require (
66
github.com/briandowns/spinner v1.18.1
7-
github.com/finleap-connect/monoskope v0.4.0
7+
github.com/finleap-connect/monoskope v0.4.4
88
github.com/golang/mock v1.6.0
99
github.com/golang/protobuf v1.5.2
1010
github.com/google/uuid v1.3.0
@@ -51,7 +51,7 @@ require (
5151
github.com/go-logr/zapr v1.2.3 // indirect
5252
github.com/godbus/dbus/v5 v5.0.6 // indirect
5353
github.com/gogo/protobuf v1.3.2 // indirect
54-
github.com/google/go-cmp v0.5.7 // indirect
54+
github.com/google/go-cmp v0.5.8 // indirect
5555
github.com/google/gofuzz v1.2.0 // indirect
5656
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
5757
github.com/googleapis/gnostic v0.5.5 // indirect

0 commit comments

Comments
 (0)