Skip to content

adding workspace_build resource #4636

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

Merged
merged 13 commits into from
Oct 25, 2022
Merged

adding workspace_build resource #4636

merged 13 commits into from
Oct 25, 2022

Conversation

Kira-Pilot
Copy link
Member

@Kira-Pilot Kira-Pilot commented Oct 18, 2022

resolves #4625

We now log start/stop for workspace builds
Screen Shot 2022-10-21 at 2 33 16 PM

@@ -43,6 +43,8 @@ func ResourceTarget[T Auditable](tgt T) string {
return typed.Username
case database.Workspace:
return typed.Name
case database.WorkspaceBuild:
return string(typed.Transition)

This comment was marked as outdated.

@Kira-Pilot
Copy link
Member Author

@coadler I'm close with this!
Screen Shot 2022-10-19 at 1 15 10 PM

But I want to get the workspace name in this friendly string, which does not exist on the workspace_build resource.

I figured I would just add an optional argument to InitRequest: AlternativeResource and pass that through; however, it seems there aren't optional arguments in Go. Also, maybe that's ugly.

Do you have any ideas?

@Kira-Pilot Kira-Pilot requested a review from coadler October 19, 2022 17:18
@coadler
Copy link
Contributor

coadler commented Oct 20, 2022

Audit logs have a field called additional_resources, which is intended for this scenario. I haven't really piped it through yet though. This is where you could put the workspace name!

@@ -43,6 +44,9 @@ func ResourceTarget[T Auditable](tgt T) string {
return typed.Username
case database.Workspace:
return typed.Name
case database.WorkspaceBuild:
// this isn't used
return string(typed.BuildNumber)
Copy link
Member Author

Choose a reason for hiding this comment

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

Ug tell me there's a better way.

workspace_bytes := []byte(alog.AdditionalFields)
var workspaceResourceInfo WorkspaceResourceInfo
json.Unmarshal(workspace_bytes, &workspaceResourceInfo)
str += " for workspace " + workspaceResourceInfo.WorkspaceName
Copy link
Member Author

Choose a reason for hiding this comment

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

I would prefer not to add this here and instead to use the ResourceTarget function.

@Kira-Pilot Kira-Pilot marked this pull request as ready for review October 21, 2022 18:36
@Kira-Pilot Kira-Pilot requested a review from a team as a code owner October 21, 2022 18:36
@Kira-Pilot Kira-Pilot requested review from BrunoQuaresma and removed request for a team October 21, 2022 18:36
Copy link
Collaborator

@BrunoQuaresma BrunoQuaresma left a comment

Choose a reason for hiding this comment

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

FE and BE code looks good to me! I don't have answers for your questions tho.

@Kira-Pilot Kira-Pilot merged commit 145faf4 into main Oct 25, 2022
@Kira-Pilot Kira-Pilot deleted the audit-on-build/kira-pilot branch October 25, 2022 13:27
@github-actions github-actions bot locked and limited conversation to collaborators Oct 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

audit: log workspace start and stop actions
3 participants