pypi

package
v0.0.0-...-8b8482c Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPackageNotFound            = errors.New("package not found")
	ErrVersionNotFound            = errors.New("version not found")
	ErrLatestVersionNotFound      = errors.New("latest version not found")
	ErrCouldNotDecodeResponse     = errors.New("could not decode registry response")
	ErrCouldNotDoRequest          = errors.New("could not start request to the registry")
	ErrCouldNotCreateRequest      = errors.New("could not create request to the registry")
	ErrMissingSdistPackageVersion = errors.New("could not find the sdist package type version")
	ErrVersionMismatch            = errors.New("version mismatch")
)
View Source
var (
	ErrNoDist = errors.New("could not find a version with 'sdist' package type")
)

Functions

This section is empty.

Types

type Digests

type Digests struct {
	MD5         string `json:"md5"`
	SHA256      string `json:"sha256"`
	Blake2bB256 string `json:"blake2b_256"`
}

type Info

type Info struct {
	Name            string `json:"name"`
	Author          string `json:"author,omitempty"`
	AuthorEmail     string `json:"author_email,omitempty"`
	Maintainer      string `json:"maintainer,omitempty"`
	MaintainerEmail string `json:"maintainer_email,omitempty"`
	Description     string `json:"description"`
	// Version is the last version (list endpoint) or the current version (version endpoint)
	Version string `json:"version"`
}

type MaintainerType

type MaintainerType string
const (
	PackageAuthorType     MaintainerType = "author"
	PackageMaintainerType MaintainerType = "maintainer"
)

type MockRegistryClient

type MockRegistryClient struct {
	// contains filtered or unexported fields
}

func NewMockRegistryClient

func NewMockRegistryClient(listFilename, versionFilename string) (*MockRegistryClient, error)

func (*MockRegistryClient) GetPackageLatestVersion

func (r *MockRegistryClient) GetPackageLatestVersion(_ context.Context, _ string) (*PackageVersion, error)

func (*MockRegistryClient) GetPackageList

func (r *MockRegistryClient) GetPackageList(_ context.Context, _ string) (*PackageList, error)

func (*MockRegistryClient) GetPackageVersion

func (r *MockRegistryClient) GetPackageVersion(_ context.Context, _, version string) (*PackageVersion, error)

type NoOpRegistryClient

type NoOpRegistryClient struct{}

func (*NoOpRegistryClient) GetPackageLatestVersion

func (c *NoOpRegistryClient) GetPackageLatestVersion(_ context.Context, _ string) (*PackageVersion, error)

func (*NoOpRegistryClient) GetPackageList

func (c *NoOpRegistryClient) GetPackageList(_ context.Context, _ string) (*PackageList, error)

func (*NoOpRegistryClient) GetPackageVersion

func (c *NoOpRegistryClient) GetPackageVersion(_ context.Context, _, _ string) (*PackageVersion, error)

type PackageList

type PackageList struct {
	Info     Info                       `json:"info"`
	Versions map[string]PackageVersions `json:"releases"`
	URLs     PackageVersions            `json:"urls"`
}

func (*PackageList) Fill

func (p *PackageList) Fill()

Fill the version and name field for all the package versions.

func (*PackageList) GetVersion

func (p *PackageList) GetVersion(version string) (*PackageVersion, error)

func (*PackageList) LatestVersionTime

func (p *PackageList) LatestVersionTime() (*time.Time, error)

func (*PackageList) MaintainersByVersion

func (p *PackageList) MaintainersByVersion(version string) (PackageMaintainers, error)

type PackageMaintainer

type PackageMaintainer struct {
	Name string
	Mail string
	Type MaintainerType
}

type PackageMaintainers

type PackageMaintainers []PackageMaintainer

func (PackageMaintainers) Emails

func (pm PackageMaintainers) Emails() []string

type PackageVersion

type PackageVersion struct {
	// These without json tags get filled in
	Name        string
	Version     string
	Authors     PackageMaintainers
	Maintainers PackageMaintainers

	URL         string    `json:"url"`
	Digests     Digests   `json:"digests"`
	PackageType string    `json:"packagetype"`
	UploadTime  time.Time `json:"upload_time_iso_8601"`
	Filename    string    `json:"filename"`
}

type PackageVersions

type PackageVersions []PackageVersion

func (PackageVersions) GetSdist

func (vs PackageVersions) GetSdist() (*PackageVersion, error)

type Registry

type Registry interface {
	GetPackageList(ctx context.Context, name string) (*PackageList, error)
	GetPackageVersion(ctx context.Context, name, version string) (*PackageVersion, error)
	GetPackageLatestVersion(ctx context.Context, name string) (*PackageVersion, error)
}

func NewNoOpRegistryClient

func NewNoOpRegistryClient() Registry

func NewRegistryClient

func NewRegistryClient(config RegistryClientConfig) (Registry, error)

type RegistryClient

type RegistryClient struct {
	// contains filtered or unexported fields
}

func (*RegistryClient) GetPackageLatestVersion

func (c *RegistryClient) GetPackageLatestVersion(parent context.Context, name string) (*PackageVersion, error)

func (*RegistryClient) GetPackageList

func (c *RegistryClient) GetPackageList(parent context.Context, name string) (*PackageList, error)

func (*RegistryClient) GetPackageVersion

func (c *RegistryClient) GetPackageVersion(parent context.Context, name, version string) (*PackageVersion, error)

type RegistryClientConfig

type RegistryClientConfig struct {
	Timeout   time.Duration
	BaseURL   string
	UserAgent string
}

type ServiceError

type ServiceError struct {
	StatusCode int
	Message    string
}

func (*ServiceError) Error

func (e *ServiceError) Error() string

Jump to

Keyboard shortcuts

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