mirror of https://github.com/harness/drone.git
parent
dfb69afade
commit
da44afe021
|
@ -103,7 +103,7 @@ func (c *Controller) UpdateDefaultBranch(
|
|||
|
||||
err = c.auditService.Log(ctx,
|
||||
session.Principal,
|
||||
audit.NewResource(audit.ResourceTypeRepository, repo.Identifier),
|
||||
audit.NewResource(audit.ResourceTypeRepositorySettings, repo.Identifier),
|
||||
audit.ActionUpdated,
|
||||
paths.Parent(repo.Path),
|
||||
audit.WithOldObject(audit.RepositoryObject{
|
||||
|
|
|
@ -118,7 +118,7 @@ func (c *Controller) RuleCreate(ctx context.Context,
|
|||
|
||||
err = c.auditService.Log(ctx,
|
||||
session.Principal,
|
||||
audit.NewResource(audit.ResourceTypeBranchRule, r.Identifier),
|
||||
audit.NewResource(audit.ResourceTypeBranchRule, r.Identifier, audit.RepoName, repo.Identifier),
|
||||
audit.ActionCreated,
|
||||
paths.Parent(repo.Path),
|
||||
audit.WithNewObject(r),
|
||||
|
|
|
@ -49,7 +49,7 @@ func (c *Controller) RuleDelete(ctx context.Context,
|
|||
|
||||
err = c.auditService.Log(ctx,
|
||||
session.Principal,
|
||||
audit.NewResource(audit.ResourceTypeBranchRule, r.Identifier),
|
||||
audit.NewResource(audit.ResourceTypeBranchRule, r.Identifier, audit.RepoName, repo.Identifier),
|
||||
audit.ActionDeleted,
|
||||
paths.Parent(repo.Path),
|
||||
audit.WithOldObject(r),
|
||||
|
|
|
@ -140,7 +140,7 @@ func (c *Controller) RuleUpdate(ctx context.Context,
|
|||
|
||||
err = c.auditService.Log(ctx,
|
||||
session.Principal,
|
||||
audit.NewResource(audit.ResourceTypeBranchRule, r.Identifier),
|
||||
audit.NewResource(audit.ResourceTypeBranchRule, r.Identifier, audit.RepoName, repo.Identifier),
|
||||
audit.ActionUpdated,
|
||||
paths.Parent(repo.Path),
|
||||
audit.WithOldObject(oldRule),
|
||||
|
|
|
@ -73,7 +73,7 @@ func (c *Controller) Update(ctx context.Context,
|
|||
|
||||
err = c.auditService.Log(ctx,
|
||||
session.Principal,
|
||||
audit.NewResource(audit.ResourceTypeRepository, repo.Identifier),
|
||||
audit.NewResource(audit.ResourceTypeRepositorySettings, repo.Identifier),
|
||||
audit.ActionUpdated,
|
||||
paths.Parent(repo.Path),
|
||||
audit.WithOldObject(repoClone),
|
||||
|
|
|
@ -30,6 +30,10 @@ var (
|
|||
ErrSpacePathIsRequired = errors.New("space path is required")
|
||||
)
|
||||
|
||||
const (
|
||||
RepoName = "repoName"
|
||||
)
|
||||
|
||||
type Action string
|
||||
|
||||
const (
|
||||
|
@ -69,13 +73,20 @@ func (a ResourceType) Validate() error {
|
|||
type Resource struct {
|
||||
Type ResourceType
|
||||
Identifier string
|
||||
Data map[string]string
|
||||
}
|
||||
|
||||
func NewResource(rtype ResourceType, identifier string) Resource {
|
||||
return Resource{
|
||||
func NewResource(rtype ResourceType, identifier string, keyValues ...string) Resource {
|
||||
r := Resource{
|
||||
Type: rtype,
|
||||
Identifier: identifier,
|
||||
Data: make(map[string]string, len(keyValues)),
|
||||
}
|
||||
for i := 0; i < len(keyValues); i += 2 {
|
||||
k, v := keyValues[i], keyValues[i+1]
|
||||
r.Data[k] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (r Resource) Validate() error {
|
||||
|
@ -88,6 +99,14 @@ func (r Resource) Validate() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (r Resource) DataAsSlice() []string {
|
||||
slice := make([]string, 0, len(r.Data)*2)
|
||||
for k, v := range r.Data {
|
||||
slice = append(slice, k, v)
|
||||
}
|
||||
return slice
|
||||
}
|
||||
|
||||
type DiffObject struct {
|
||||
OldObject any
|
||||
NewObject any
|
||||
|
|
Loading…
Reference in New Issue