Documentation
¶
Index ¶
- Variables
- func AllTrue[K comparable](m map[K]bool) bool
- func AppendStringToFile(filename, text string)
- func Average(data []int) int
- func CheckIfImageHasRequiredAttestations(ctx context.Context, image name.Reference, ...) (map[AttestationType]bool, error)
- func Contains[T comparable](s []T, e T) bool
- func ExtractBaseURL(u string) (string, error)
- func Filter[T any](s []T, f func(T) bool) []T
- func Find[T any](s []T, f func(T) bool) *T
- func Flatten[T any](s [][]T) []T
- func FormatContributorsByValue(obfuscatedContributors map[string]int, unit string) string
- func FormatStringBoolMap[K ~string](data map[K]bool) string
- func GetBytesFromAPI(ctx context.Context, URL string, httpHeader map[string]string) ([]byte, error)
- func GetEnvOrNil(key string) *string
- func GetEnvWithDefault[T string](key string, defaultValue string) string
- func GetIndexOfLargestElement[T cmp.Ordered](s []T) int
- func GetIndexOfSmallestElement[T cmp.Ordered](s []T) int
- func GetJSONFromAPI(ctx context.Context, target any, URL string) error
- func GetOrDefault[T any](val *T, deflt T) T
- func GetOrDefaultStr(val *string, deflt string) string
- func Index[T comparable](s []T, e T) int
- func IsImageValidSemVer(image string) (name.Reference, *semver.Version, error)
- func Map[T, U any](s []T, f func(T) U) []U
- func Median(data []int) int
- func ObfuscateEmail(val string) string
- func ObfuscateEmails(mapping map[string]int) map[string]int
- func ObfuscateString(val string) string
- func Ptr[T any](v T) *T
- func Reduce[T any, U any](s []T, f func(U, T) U, initial U) U
- func SafeDeref(ptr *int) string
- func TimeMidnight(t time.Time) time.Time
- func TimeMidnightOffsetDays(t time.Time, days int) time.Time
- func TimeMidnightOffsetMonth(month int) time.Time
- func TimeMidnightTomorrow() time.Time
- func ToDescriptionString[T Describer](elements []T) string
- func Unique[T comparable](s []T) []T
- func UniqueBy[T any, U comparable](s []T, extractor func(el T) U) []T
- func UserAgent() string
- func WaitAll[T any](tasks []func() (T, error)) ([]T, error)
- type AttestationType
- type Branch
- type CIPipeline
- type Commit
- type CommitRef
- type CommitVerificationStatus
- type ContainerRegistryTag
- type CosignAttestationClient
- type CosignAttestationClientImpl
- type DateRangeListOptions
- type Describer
- type GetCommitOptions
- type GetProjectOptions
- type Issue
- type IssueEvent
- type IssueState
- type KeyInt
- type ListCIPipelineRunsOptions
- type ListCommitsOptions
- type ListMergeRequestsOptions
- type ListReleasesOptions
- type ListTagsOptions
- type MergeRequest
- type MergeRequestApprovals
- type MergeRequestReviewers
- type Package
- type Project
- type ProjectMember
- type ProtectedBranch
- type ProtectedTag
- type RateLimiter
- type Release
- type RpsRateLimiter
- type Tag
- type TagSignature
- type User
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("not found") ErrForbidden = errors.New("forbidden") ErrNotSupported = errors.New("not supported by this git provider") )
Sentinel errors that git clients translate provider errors into, so observers can react without knowing the provider's error shape.
var AllAttestationTypes = []AttestationType{ BuildProvenance, SourceProvenance, SARIF, SBOM, VEX, }
var AttestationRegex = map[AttestationType][]*regexp.Regexp{ SBOM: { regexp.MustCompile(`^https://cyclonedx\.org/bom(/v[\d\.]+)?$`), regexp.MustCompile(`^https://spdx\.dev/Document/v[\d\.]+$`), }, VEX: { regexp.MustCompile(`^https://cyclonedx\.org/vex$`), }, SARIF: { regexp.MustCompile(`^https://www\.schemastore\.org/schemas/json/sarif-[\d\.]+.json$`), }, BuildProvenance: { regexp.MustCompile(`^https://slsa\.dev/provenance/v[\d\.]+$`), regexp.MustCompile(`^https://cosign\.sigstore\.dev/attestation/v[\d\.]+$`), }, SourceProvenance: { regexp.MustCompile(`^https://gitlab\.opencode\.de/open-code/badgebackend/source-provenance-attestation-service/schema/source-provenance-report-v[\d]+$`), regexp.MustCompile(`^https://gitlab\.opencode\.de/open-code/badgebackend/source-provenance-attestation-service/-/raw/main/schema/source-provenance-schema-1\.\d+\.\d+\.json$`), }, }
var Version = GetEnvWithDefault[string]("BADGE_API_VERSION", "dev")
Version is the Badge API version. The container image bakes it in at build time (see the BADGE_API_VERSION build argument in the Dockerfile), so a deployed instance reports the tag it was built from. Anything running outside that image - a local `make run`, a test, a locally built image without the build argument - reports "dev".
Functions ¶
func AllTrue ¶
func AllTrue[K comparable](m map[K]bool) bool
func CheckIfImageHasRequiredAttestations ¶
func CheckIfImageHasRequiredAttestations(ctx context.Context, image name.Reference, cosignClient CosignAttestationClient, attestationTypes []AttestationType) (map[AttestationType]bool, error)
func Contains ¶
func Contains[T comparable](s []T, e T) bool
func FormatContributorsByValue ¶
func GetBytesFromAPI ¶
func Index ¶
func Index[T comparable](s []T, e T) int
func IsImageValidSemVer ¶
func ObfuscateString ¶
Obfuscate string by replacing all chars in the middle with * while allowing special chars like dots and dashes (e.g. david.luhmer would be d***.*****r)
func TimeMidnightOffsetMonth ¶
today 0am X month ago
func Unique ¶
func Unique[T comparable](s []T) []T
func UniqueBy ¶
func UniqueBy[T any, U comparable](s []T, extractor func(el T) U) []T
Types ¶
type AttestationType ¶
type AttestationType string
const ( SBOM AttestationType = "sbom" VEX AttestationType = "vex" SARIF AttestationType = "sarif" BuildProvenance AttestationType = "build-provenance" SourceProvenance AttestationType = "source-provenance" )
type Branch ¶
type CIPipeline ¶
type Commit ¶
type CommitVerificationStatus ¶
type ContainerRegistryTag ¶
type CosignAttestationClient ¶
type CosignAttestationClientImpl ¶
type CosignAttestationClientImpl struct {
// contains filtered or unexported fields
}
func NewCosignAttestationClient ¶
func NewCosignAttestationClient(opts ...cosignRemote.Option) *CosignAttestationClientImpl
type DateRangeListOptions ¶
type GetCommitOptions ¶
type GetCommitOptions struct {
}
type Issue ¶
type IssueEvent ¶
type IssueState ¶
type IssueState string
const ( IssueStateOpen IssueState = "open" IssueStateClosed IssueState = "closed" )
type KeyInt ¶
type ListCIPipelineRunsOptions ¶
type ListCommitsOptions ¶
type ListMergeRequestsOptions ¶
type ListReleasesOptions ¶
type ListTagsOptions ¶
type MergeRequest ¶
type MergeRequestApprovals ¶
type MergeRequestReviewers ¶
type MergeRequestReviewers interface {
GetReviewers() []ProjectMember
}
type Project ¶
type ProjectMember ¶
type ProtectedBranch ¶
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
func NewRateLimiter ¶
func NewRateLimiter(limit int, gauge gauge) *RateLimiter
func (*RateLimiter) Done ¶
func (r *RateLimiter) Done()
func (*RateLimiter) Wait ¶
func (r *RateLimiter) Wait()
type Release ¶
type RpsRateLimiter ¶
type RpsRateLimiter struct {
// contains filtered or unexported fields
}
RpsRateLimiter limits how many requests per second reach the origin server.
Every request has to take a token before it is sent, so the origin never sees more than maxRequestsPerSecond - not in the long run and not in a burst. A request the caching proxy answered itself never reached the origin though, so Refund puts its token straight back. Cache hits therefore cost nothing but the moment they are in flight, and the tokens keep circulating between them.
func NewRpsLimiter ¶
func NewRpsLimiter(maxRequestsPerSecond int, gauge gauge) *RpsRateLimiter
Requests per second limiter
func (*RpsRateLimiter) Done ¶
func (r *RpsRateLimiter) Done()
func (*RpsRateLimiter) Refund ¶
func (r *RpsRateLimiter) Refund()
Refund returns a token that was not spent on the origin after all.
func (*RpsRateLimiter) Wait ¶
func (r *RpsRateLimiter) Wait()
Wait blocks until a token is available and takes it.
type Tag ¶
Source Files
¶
- concurrency.go
- cosign.go
- errors.go
- file-io.go
- http-api.go
- oci_attestation.go
- ratelimiter.go
- slices.go
- types.go
- utils.go
- version.go