client

package
v0.2.2 Latest Latest
Warning

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

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

Documentation

Overview

Package client provides a rest client to talk to the Trusty API.

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = Options{
	Workers:            2,
	BaseURL:            defaultEndpoint,
	WaitForIngestion:   true,
	IngestionRetryWait: 5,
}

DefaultOptions is the default Trusty client options set

Functions

This section is empty.

Types

type Options

type Options struct {
	HttpClient netClient

	// Workers is the number of parallel request the client makes to the API
	Workers int

	// BaseURL of the Trusty API
	BaseURL string

	// WaitForIngestion causes the http client to wait and retry if Trusty
	// responds with a successful request but with a "pending" or "scoring" status
	WaitForIngestion bool

	// ErrOnFailedIngestion makes the client return an error on a Report call
	// when the ingestion failed internally withing trusty. If false, the
	// report data willbe returned but the application needs to check the
	// ingestion status and handle it.
	ErrOnFailedIngestion bool

	// IngestionRetryWait is the number of seconds that the client will wait for
	// package ingestion before retrying.
	IngestionRetryWait int

	// IngestionMaxRetries is the maximum number of requests the client will
	// send while waiting for ingestion to finish
	IngestionMaxRetries int
}

Options configures the Trusty API client

type Trusty

type Trusty struct {
	Options Options
}

Trusty is the main trusty client

func New

func New() *Trusty

New returns a new Trusty REST client

func NewWithOptions

func NewWithOptions(opts Options) *Trusty

NewWithOptions returns a new client with the specified options set

func (*Trusty) GroupReport

func (t *Trusty) GroupReport(_ context.Context, deps []*types.Dependency) ([]*types.Reply, error)

GroupReport queries the Trusty API in parallel for a group of dependencies.

func (*Trusty) PackageEndpoint

func (t *Trusty) PackageEndpoint(dep *types.Dependency) (string, error)

PackageEndpoint takes a dependency and returns the Trusty endpoint to query data about it.

func (*Trusty) PurlEndpoint

func (t *Trusty) PurlEndpoint(purl string) (string, error)

PurlEndpoint returns the API endpoint url to query for data about a purl

func (*Trusty) PurlToDependency

func (t *Trusty) PurlToDependency(purlString string) (*types.Dependency, error)

PurlToDependency takes a string with a package url

func (*Trusty) PurlToEcosystem

func (_ *Trusty) PurlToEcosystem(purl string) types.Ecosystem

PurlToEcosystem returns a trusty ecosystem constant from a Package URL's type

func (*Trusty) Report

func (t *Trusty) Report(_ context.Context, dep *types.Dependency) (*types.Reply, error)

Report returns a dependency report with all the data that Trusty has available for a package.

Jump to

Keyboard shortcuts

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