cooldown

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

ParseDuration parses a duration string supporting days (e.g., "3d"), in addition to Go's standard time.ParseDuration formats ("48h", "30m"). "0" means disabled (returns 0).

Types

type Config

type Config struct {
	// Default is the global default cooldown duration (e.g., "3d", "48h").
	Default string `json:"default" yaml:"default"`

	// Ecosystems overrides the default for specific ecosystems.
	// Keys are ecosystem names (e.g., "npm", "pypi").
	Ecosystems map[string]string `json:"ecosystems" yaml:"ecosystems"`

	// Packages overrides the cooldown for specific packages.
	// Keys are PURLs (e.g., "pkg:npm/lodash", "pkg:npm/@babel/core").
	Packages map[string]string `json:"packages" yaml:"packages"`
	// contains filtered or unexported fields
}

Config holds cooldown settings for version filtering. Cooldown hides package versions published too recently, giving the community time to spot malicious releases before they're pulled into projects.

func (*Config) Enabled

func (c *Config) Enabled() bool

Enabled returns true if any cooldown is configured.

func (*Config) For

func (c *Config) For(ecosystem, packagePURL string) time.Duration

For returns the effective cooldown duration for a given ecosystem and package PURL. Resolution order: package override > ecosystem override > global default.

func (*Config) IsAllowed

func (c *Config) IsAllowed(ecosystem, packagePURL string, publishedAt time.Time) bool

IsAllowed returns true if a version with the given publish time has passed the cooldown period for this ecosystem/package.

Jump to

Keyboard shortcuts

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