registry

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package registry adapts the four package registries installwall watches (npm, PyPI, RubyGems, crates.io) to one interface: does this package exist, and when was it first published.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Crates

type Crates struct {
	BaseURL   string
	Client    *http.Client
	UserAgent string
}

Crates looks up package metadata from the crates.io API. crates.io asks every script client to send a descriptive User-Agent with contact info, see https://crates.io/policies#crawlers.

func NewCrates

func NewCrates() *Crates

func (*Crates) Lookup

func (r *Crates) Lookup(ctx context.Context, name string) (Info, error)

func (*Crates) Name

func (r *Crates) Name() string

type Info

type Info struct {
	Exists       bool
	CreatedAt    time.Time
	HasCreatedAt bool
}

Info is what installwall needs to know about one package name.

type NPM

type NPM struct {
	BaseURL string
	Client  *http.Client
}

NPM looks up package metadata from the public npm registry. https://github.com/npm/registry/blob/main/docs/REGISTRY-API.md

func NewNPM

func NewNPM() *NPM

func (*NPM) Lookup

func (r *NPM) Lookup(ctx context.Context, name string) (Info, error)

func (*NPM) Name

func (r *NPM) Name() string

type PyPI

type PyPI struct {
	BaseURL string
	Client  *http.Client
}

PyPI looks up package metadata from pypi.org's JSON API. https://warehouse.pypa.io/api-reference/json.html

func NewPyPI

func NewPyPI() *PyPI

func (*PyPI) Lookup

func (r *PyPI) Lookup(ctx context.Context, name string) (Info, error)

func (*PyPI) Name

func (r *PyPI) Name() string

type Registry

type Registry interface {
	Name() string
	Lookup(ctx context.Context, name string) (Info, error)
}

Registry looks up a single package by name.

type RubyGems

type RubyGems struct {
	BaseURL string
	Client  *http.Client
}

RubyGems looks up package metadata from the rubygems.org API. https://guides.rubygems.org/rubygems-org-api/

func NewRubyGems

func NewRubyGems() *RubyGems

func (*RubyGems) Lookup

func (r *RubyGems) Lookup(ctx context.Context, name string) (Info, error)

func (*RubyGems) Name

func (r *RubyGems) Name() string

type UnreachableError

type UnreachableError struct {
	Registry string
	Err      error
}

UnreachableError wraps a network or transport failure so callers can tell "package does not exist" apart from "could not ask the registry". installwall fails open on this: it warns and allows rather than blocking an install because a registry was slow or down.

func (*UnreachableError) Error

func (e *UnreachableError) Error() string

func (*UnreachableError) Unwrap

func (e *UnreachableError) Unwrap() error

Jump to

Keyboard shortcuts

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