Documentation
¶
Index ¶
- Constants
- Variables
- func CustomErrorHandler(ctx *fiber.Ctx, err error) error
- func DuplicateField(err error) *string
- func GenerateErrorDetails(validationErrors []ValidationError) string
- func NormalizeEmail(email *string) *string
- func NormalizeURL(rawURL string) string
- func ValidateRequestEntity(ctx *fiber.Ctx, request any, errorMessage string) error
- type AnalysisData
- type Base64Key
- type CatalogPatch
- type CatalogPost
- type CodeHosting
- type Environment
- type Log
- type ProblemJSONError
- type PublisherPatch
- type PublisherPost
- type Response
- type SoftwarePatch
- type SoftwarePost
- type SourceInput
- type ValidationError
- type Webhook
Constants ¶
View Source
const ( SymmetricKeyLen = 32 EventTypeCreate = "create" EventTypeUpdate = "update" EventTypeDelete = "delete" )
Variables ¶
Functions ¶
func DuplicateField ¶ added in v1.1.0
DuplicateField reports whether err is a unique constraint violation. Returns nil if it is not. Returns a pointer to the API field name that caused it (e.g. "alternativeId", "codeHosting.url") if it is, or a pointer to an empty string if the field cannot be determined.
func GenerateErrorDetails ¶ added in v0.8.0
func GenerateErrorDetails(validationErrors []ValidationError) string
func NormalizeEmail ¶ added in v0.5.1
func NormalizeURL ¶ added in v1.1.0
Types ¶
type AnalysisData ¶ added in v1.2.0
type AnalysisData map[string]json.RawMessage //nolint:recvcheck
AnalysisData is a map of { namespace: arbitrary JSON object } External software components (scanners, enrichers, security checkers, etc.) write under their own key. Every namespace must have "v" (schema version, int).
func WithTimestamps ¶ added in v1.2.0
func WithTimestamps(analysis AnalysisData, now time.Time) (AnalysisData, error)
WithTimestamps checks that each namespace is a JSON object with an integer "v", then injects "t" (current time, RFC 3339).
func (*AnalysisData) Scan ¶ added in v1.2.0
func (a *AnalysisData) Scan(value any) error
type CatalogPatch ¶ added in v1.2.0
type CatalogPatch struct {
Name *string `json:"name" validate:"omitempty,min=1,max=255"`
AlternativeID *string `json:"alternativeId" validate:"omitempty,max=255"`
Active *bool `json:"active"`
PublishersNamespace *string `json:"publishersNamespace" validate:"omitempty,max=255"`
Sources *[]SourceInput `json:"sources" validate:"omitempty,gt=0,dive"`
}
type CatalogPost ¶ added in v1.2.0
type CatalogPost struct {
Name string `json:"name" validate:"required,min=1,max=255"`
AlternativeID *string `json:"alternativeId" validate:"omitempty,min=1,max=255"`
Active *bool `json:"active"`
PublishersNamespace *string `json:"publishersNamespace" validate:"omitempty,max=255"`
Sources []SourceInput `json:"sources" validate:"required,gt=0,dive"`
}
type CodeHosting ¶
type Environment ¶
type Environment struct {
MaxRequests int `env:"MAX_REQUESTS" envDefault:"0"`
CurrentEnvironment string `env:"ENVIRONMENT" envDefault:"production"`
Database string `env:"DATABASE_DSN"`
PasetoKey *Base64Key `env:"PASETO_KEY"`
}
var EnvironmentConfig Environment //nolint:gochecknoglobals
func (*Environment) IsTest ¶
func (e *Environment) IsTest() bool
type ProblemJSONError ¶
type ProblemJSONError struct {
Code string `json:"code,omitempty"`
Title string `json:"title"`
Detail string `json:"detail,omitempty"`
Status int `json:"status"`
ValidationErrors []ValidationError `json:"validationErrors,omitempty"`
}
func ErrorWithValidationErrors ¶
func ErrorWithValidationErrors( status int, title string, validationErrors []ValidationError, ) ProblemJSONError
func InternalServerError ¶ added in v0.9.0
func InternalServerError(title string) ProblemJSONError
func (ProblemJSONError) Error ¶
func (pj ProblemJSONError) Error() string
type PublisherPatch ¶ added in v0.5.1
type PublisherPatch struct {
CodeHosting *[]CodeHosting `json:"codeHosting" validate:"omitempty,gt=0,dive"`
Description *string `json:"description"`
Email *string `json:"email" validate:"omitempty,email"`
Active *bool `json:"active"`
AlternativeID *string `json:"alternativeId" validate:"omitempty,max=255"`
}
type PublisherPost ¶ added in v0.5.1
type PublisherPost struct {
CodeHosting []CodeHosting `json:"codeHosting" validate:"required,gt=0,dive"`
Description string `json:"description" validate:"required"`
Email *string `json:"email" validate:"omitempty,email"`
Active *bool `json:"active"`
AlternativeID *string `json:"alternativeId" validate:"omitempty,min=1,max=255"`
}
type SoftwarePatch ¶ added in v0.5.0
type SoftwarePost ¶ added in v0.5.0
type SourceInput ¶ added in v1.2.0
type ValidationError ¶
type ValidationError struct {
Field string `json:"field"`
Rule string `json:"rule"`
Value string `json:"value"`
}
func ValidateStruct ¶
func ValidateStruct(validateStruct any) []ValidationError
Click to show internal directories.
Click to hide internal directories.