Skip to content

Implement Audit API - #70

Merged
Gerrit91 merged 21 commits into
mainfrom
audit-api
Apr 25, 2025
Merged

Implement Audit API#70
Gerrit91 merged 21 commits into
mainfrom
audit-api

Conversation

@AnnaSchreiner

Copy link
Copy Markdown
Contributor

No description provided.

@ostempel
ostempel marked this pull request as ready for review January 27, 2025 10:53
Comment threadgo.mod Outdated
github.com/fatih/color v1.18.0
github.com/google/go-cmp v0.7.0
github.com/metal-stack-cloud/api v0.12.0
github.com/metal-stack-cloud/api v0.13.1-0.20250325121620-df8dd0323b54

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Update metal-stack-cloud/api dependency, after audit-api got merged: metal-stack-cloud/api#186

Comment threadcmd/api/v1/audit.go Outdated
defer cancel()

project := a.c.GetProject()
fmt.Printf("project: %s", project)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Needs to be cleaned up.

Comment threadcmd/api/v1/audit.go
Comment threadcmd/api/v1/audit.go
Comment threadcmd/api/v1/audit.go Outdated
Comment on lines +98 to +99
err = json.Unmarshal([]byte(trimmed), &body)
if err == nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
err=json.Unmarshal([]byte(trimmed), &body)
iferr==nil {
iferr:=json.Unmarshal([]byte(trimmed), &body); err==nil {

Comment threadcmd/api/v1/audit.go
Comment threadcmd/sorters/audit.go
Comment threadcmd/tableprinters/audit.go Outdated
rows [][]string
)

header := []string{"TIME", "REQUEST-ID", "USER", "PROJECT", "METHOD", "PHASE"}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The used library automatically turns headers into capitals.

Comment threadcmd/tableprinters/audit.go Outdated

header := []string{"TIME", "REQUEST-ID", "USER", "PROJECT", "METHOD", "PHASE"}
if wide {
header = []string{"TIME", "REQUEST-ID", "USER", "PROJECT", "METHOD", "PHASE", "SOURCE-IP", "RESULT-CODE", "BODY"}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
header= []string{"TIME", "REQUEST-ID", "USER", "PROJECT", "METHOD", "PHASE", "SOURCE-IP", "RESULT-CODE", "BODY"}
header= []string{"TIME", "REQUEST-ID", "USER", "PROJECT", "METHOD", "PHASE", "SOURCE-IP", "CODE", "BODY"}

Comment threadcmd/tableprinters/audit.go Outdated
}
rows = append(rows, []string{time, id, user, project, method, phase, sourceIp, resultCode, body})
} else {
rows = append(rows, []string{time, id, user, project, method, phase})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we can add the status code column here as well? It's quite short and intersting?

Comment threadcmd/tableprinters/audit.go Outdated
Comment on lines +52 to +54
func truncateToSeconds(t time.Time) time.Time {
return time.Date(t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), 0, t.Location())
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this really required? I think by using the format layout specified this should already be done.

@Gerrit91
Gerrit91 marked this pull request as draft April 24, 2025 10:50
@Gerrit91Gerrit91 changed the title WIP: Audit APIImplement Audit APIApr 24, 2025
@Gerrit91
Gerrit91 requested a review from vknabelApril 25, 2025 06:53
@Gerrit91
Gerrit91 marked this pull request as ready for review April 25, 2025 06:53
@Gerrit91
Gerrit91 merged commit e2ec3a9 into mainApr 25, 2025
@Gerrit91
Gerrit91 deleted the audit-api branch April 25, 2025 06:56
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@AnnaSchreiner@Gerrit91@ostempel