repoallowlist

package
v0.36.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2026 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAllowed

func IsAllowed(allowlist []string, target string) bool

IsAllowed reports whether the target is permitted by the allowlist. target must be a "host/owner/repo" string (e.g. "github.com/bborbe/maintainer"). If the allowlist is empty or nil, all targets are allowed (allow-all semantics). If target is empty and the allowlist is non-empty, returns false. Malformed or invalid wildcard entries are logged with glog.Errorf and skipped.

A leading '!' on an entry (immediately after TrimSpace, with no whitespace between '!' and the entry body) marks the entry as an exclusion. Example: "!github.com/bborbe/go-skeleton" excludes go-skeleton.

A target is allowed iff (includes is empty OR any include matches the target) AND (no exclude matches the target). Excludes always override includes — if both match, the target is rejected.

An exclude-only allowlist (no include entries) means "allow everything except the excluded entries" — the canonical allow-all-except case.

Example:

includes: github.com/bborbe/*
excludes: !github.com/bborbe/go-skeleton
→ allows every bborbe repo except go-skeleton.

No ctx parameter: malformed-entry errors are logged via glog and discarded; they never escape the function, so there is nothing for ctx to enrich. Validate carries the ctx since it returns the error to the caller.

func Validate

func Validate(ctx context.Context, allowlist []string) error

Validate checks all entries in the allowlist for well-formedness. Returns nil if the allowlist is empty/nil or all entries are valid. Returns an aggregate error listing every malformed entry found. Whitespace-only and empty entries are silently skipped (not malformed). A leading '!' on an entry marks it as an exclusion; the well-formedness check runs on the post-'!' portion of the entry, but the aggregated error message names the ORIGINAL '!'-prefixed entry so the operator sees what they wrote.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL