Documentation
¶
Index ¶
- Constants
- Variables
- func GetRealIP(ctx context.Context) string
- func GetRequestID(ctx context.Context) string
- func GetRequestMethod(ctx context.Context) string
- func Middleware() func(next http.Handler) http.Handler
- type Action
- type BranchObject
- type CommitObject
- type DiffObject
- type Event
- type FuncOption
- type Noop
- type Option
- type PullRequestObject
- type RegistryUpstreamProxyConfigObject
- type RepositoryObject
- type Resource
- type ResourceType
- type Service
Constants ¶
View Source
const ( ResourceName = "resourceName" RepoName = "repoName" BypassedResourceType = "bypassedResourceType" BypassedResourceName = "bypassedResourceName" RepoPath = "repoPath" BypassedResourceTypePullRequest = "pull_request" BypassedResourceTypeBranch = "branch" BypassedResourceTypeCommit = "commit" BypassAction = "bypass_action" BypassActionDeleted = "deleted" BypassActionCreated = "created" BypassActionCommitted = "committed" BypassActionMerged = "merged" BypassSHALabelFormat = "%s @%s" BypassPullReqLabelFormat = "%s #%s" )
Variables ¶
View Source
var ( ErrActionUndefined = errors.New("undefined action") ErrResourceTypeUndefined = errors.New("undefined resource type") ErrResourceIdentifierIsRequired = errors.New("resource identifier is required") ErrUserIsRequired = errors.New("user is required") ErrSpacePathIsRequired = errors.New("space path is required") )
View Source
var WireSet = wire.NewSet( ProvideAuditService, )
Functions ¶
func GetRequestID ¶
GetRequestID returns requestID from context.
func GetRequestMethod ¶
GetRequestMethod returns http method from context.
Types ¶
type BranchObject ¶
type BranchObject struct {
BranchName string `yaml:"branch_name"`
RepoPath string `yaml:"repo_path"`
RuleViolations []types.RuleViolations `yaml:"rule_violations"`
}
type CommitObject ¶
type CommitObject struct {
CommitSHA string `yaml:"commit_sha"`
RepoPath string `yaml:"repo_path"`
RuleViolations []types.RuleViolations `yaml:"rule_violations"`
}
type DiffObject ¶
type Event ¶
type Event struct {
ID string
Timestamp int64
Action Action // example: ActionCreated
User types.Principal // example: Admin
SpacePath string // example: /root/projects
Resource Resource
DiffObject DiffObject
ClientIP string
RequestMethod string
Data map[string]string // internal data like correlationID/requestID
}
type FuncOption ¶
type FuncOption func(e *Event)
func WithClientIP ¶
func WithClientIP(value string) FuncOption
func WithData ¶
func WithData(keyValues ...string) FuncOption
func WithID ¶
func WithID(value string) FuncOption
func WithNewObject ¶
func WithNewObject(value any) FuncOption
func WithOldObject ¶
func WithOldObject(value any) FuncOption
func WithRequestMethod ¶
func WithRequestMethod(value string) FuncOption
func (FuncOption) Apply ¶
func (f FuncOption) Apply(event *Event)
type PullRequestObject ¶
type PullRequestObject struct {
PullReq types.PullReq
RepoPath string `yaml:"repo_path"`
RuleViolations []types.RuleViolations `yaml:"rule_violations"`
}
type RepositoryObject ¶
type RepositoryObject struct {
types.Repository
IsPublic bool `yaml:"is_public"`
}
RepositoryObject is the object used for emitting repository related audits. TODO: ensure audit only takes audit related objects?
type Resource ¶
type Resource struct {
Type ResourceType
Identifier string
Data map[string]string
}
func NewResource ¶
func NewResource(rtype ResourceType, identifier string, keyValues ...string) Resource
func (Resource) DataAsSlice ¶
type ResourceType ¶
type ResourceType string
const ( ResourceTypeRepository ResourceType = "repository" ResourceTypeBranchRule ResourceType = "branch_rule" ResourceTypeBranch ResourceType = "branch" ResourceTypePullRequest ResourceType = "pull_request" ResourceTypeRepositorySettings ResourceType = "repository_settings" ResourceTypeRegistry ResourceType = "registry" ResourceTypeRegistryUpstreamProxy ResourceType = "registry_upstream_proxy" )
func (ResourceType) Validate ¶
func (a ResourceType) Validate() error
Click to show internal directories.
Click to hide internal directories.