Skip to content
Merged
Show file tree
Hide file tree
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
38 changes: 38 additions & 0 deletions app/controlplane/pkg/auditor/events/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
var (
_ auditor.LogEntry = (*ProjectCreated)(nil)
_ auditor.LogEntry = (*ProjectVersionCreated)(nil)
_ auditor.LogEntry = (*ProjectVersionUpdated)(nil)
_ auditor.LogEntry = (*ProjectVersionDeleted)(nil)
_ auditor.LogEntry = (*ProjectMembershipAdded)(nil)
_ auditor.LogEntry = (*ProjectMembershipRemoved)(nil)
Expand All @@ -39,6 +40,7 @@ const (
ProjectType auditor.TargetType = "Project"
ProjectCreatedActionType string = "ProjectCreated"
ProjectVersionCreatedActionType string = "ProjectVersionCreated"
ProjectVersionUpdatedActionType string = "ProjectVersionUpdated"
ProjectVersionDeletedActionType string = "ProjectVersionDeleted"
ProjectMembershipAddedActionType string = "ProjectMembershipAdded"
ProjectMembershipRemovedActionType string = "ProjectMembershipRemoved"
Expand Down Expand Up @@ -156,6 +158,42 @@ func (p *ProjectVersionDeleted) Description() string {
return fmt.Sprintf("%s has deleted %s version '%s' for project '%s'", auditor.GetActorIdentifier(), releaseType, p.Version, p.ProjectName)
}

// ProjectVersionUpdated represents the update of a project version
type ProjectVersionUpdated struct {
Copy link
Member

Choose a reason for hiding this comment

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

I'd not define the event here, projectversions belong to chainloop

ProjectVersionCreatedActionType string = "ProjectVersionCreated"

Copy link
Collaborator Author

@Piskoo Piskoo Feb 2, 2026

Choose a reason for hiding this comment

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

It is chainloop, the PR I mean

Copy link
Member

Choose a reason for hiding this comment

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

my bad :)

*ProjectBase
VersionID *uuid.UUID `json:"version_id,omitempty"`
Version string `json:"version,omitempty"`
NewVersion *string `json:"new_version,omitempty"`
}

func (p *ProjectVersionUpdated) ActionType() string {
return ProjectVersionUpdatedActionType
}

func (p *ProjectVersionUpdated) ActionInfo() (json.RawMessage, error) {
if _, err := p.ProjectBase.ActionInfo(); err != nil {
return nil, err
}

if p.VersionID == nil || p.Version == "" {
return nil, errors.New("version id and version are required")
}

return json.Marshal(&p)
}

func (p *ProjectVersionUpdated) Description() string {
desc := fmt.Sprintf("%s has updated version '%s' for project '%s'",
auditor.GetActorIdentifier(), p.Version, p.ProjectName)

if p.NewVersion != nil {
desc = fmt.Sprintf("%s has renamed version '%s' to '%s' for project '%s'",
auditor.GetActorIdentifier(), p.Version, *p.NewVersion, p.ProjectName)
}

return desc
}

// Helper function to make role names more user-friendly
func prettyRole(role string) string {
// Convert the role to a prettier format
Expand Down
19 changes: 19 additions & 0 deletions app/controlplane/pkg/auditor/events/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@ func TestProjectEvents(t *testing.T) {
actor: auditor.ActorTypeUser,
actorID: userUUID,
},
{
name: "ProjectVersionUpdated",
event: &events.ProjectVersionUpdated{
ProjectBase: &events.ProjectBase{
ProjectID: &projectUUID,
ProjectName: projectName,
},
VersionID: &versionUUID,
Version: "v1.0.0",
NewVersion: stringPtr("v1.0.1"),
},
expected: "testdata/projects/project_version_updated.json",
actor: auditor.ActorTypeUser,
actorID: userUUID,
},
{
name: "ProjectMembershipAdded",
event: &events.ProjectMembershipAdded{
Expand Down Expand Up @@ -353,3 +368,7 @@ func TestProjectEventsFailed(t *testing.T) {
})
}
}

func stringPtr(s string) *string {
return &s
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"ActionType": "ProjectVersionUpdated",
"TargetType": "Project",
"TargetID": "3089bb36-e27b-428b-8009-d015c8737c56",
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Connor",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "John Connor has renamed version 'v1.0.0' to 'v1.0.1' for project 'test-project'",
"Info": {
"project_id": "3089bb36-e27b-428b-8009-d015c8737c56",
"project_name": "test-project",
"version_id": "5089bb36-e27b-428b-8009-d015c8737c58",
"version": "v1.0.0",
"new_version": "v1.0.1"
},
"Digest": "sha256:f86470cccd6d88b274433350b0ff3958b9f081a12bffcbcd20b6648d28182c1f"
}
Loading