Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) Do(req *http.Request) (*http.Response, error)
- func (c *Client) GetKey(ctx context.Context, search []byte) (keyText string, err error)
- func (c *Client) GetVersion(ctx context.Context) (string, error)
- func (c *Client) NewRequest(ctx context.Context, method string, ref *url.URL, body io.Reader) (*http.Request, error)
- func (c *Client) PKSAdd(ctx context.Context, keyText string) error
- func (c *Client) PKSAddWithResponse(ctx context.Context, keyText string) (string, error)
- func (c *Client) PKSLookup(ctx context.Context, pd *PageDetails, search, operation string, ...) (response string, err error)
- type HTTPError
- type Option
- type PageDetails
Constants ¶
const ( // OperationGet is a PKSLookup operation value to perform a "get" operation. OperationGet = "get" // OperationIndex is a PKSLookup operation value to perform a "index" operation. OperationIndex = "index" // OperationVIndex is a PKSLookup operation value to perform a "vindex" operation. OperationVIndex = "vindex" )
const OptionMachineReadable = "mr"
OptionMachineReadable is a PKSLookup options value to return machine readable output.
Variables ¶
var ErrInvalidKeyText = errors.New("invalid key text")
ErrInvalidKeyText is returned when the key text is invalid.
var ErrInvalidOperation = errors.New("invalid operation")
ErrInvalidOperation is returned when the operation is invalid.
var ErrInvalidSearch = errors.New("invalid search")
ErrInvalidSearch is returned when the search value is invalid.
var ErrTLSRequired = errors.New("TLS required when auth token provided")
ErrTLSRequired is returned when an auth token is supplied with a non-TLS BaseURL.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client describes the client details.
func NewClient ¶
NewClient returns a Client to interact with an HKP key server according to opts.
By default, the Sylabs Key Service is used. To override this behaviour, use OptBaseURL. If the key server requires authentication, consider using OptBearerToken.
If a bearer token is specified with a non-localhost base URL that does not utilize Transport Layer Security (TLS), an error wrapping ErrTLSRequired is returned.
func (*Client) GetKey ¶
GetKey retrieves an ASCII armored keyring matching search from the Key Service. A 32-bit key ID, 64-bit key ID, 128-bit version 3 fingerprint, or 160-bit version 4 fingerprint can be specified in search. The context controls the lifetime of the request.
If an non-200 HTTP status code is received, an error wrapping an HTTPError is returned.
func (*Client) GetVersion ¶
GetVersion gets version information from the Key Service. The context controls the lifetime of the request.
If an non-200 HTTP status code is received, an error wrapping an HTTPError is returned.
func (*Client) NewRequest ¶
func (c *Client) NewRequest(ctx context.Context, method string, ref *url.URL, body io.Reader) (*http.Request, error)
NewRequest returns a new Request given a method, ref, and optional body.
The context controls the entire lifetime of a request and its response: obtaining a connection, sending the request, and reading the response headers and body.
func (*Client) PKSAdd ¶
PKSAdd submits an ASCII armored keyring to the Key Service, as specified in section 4 of the OpenPGP HTTP Keyserver Protocol (HKP) specification. The context controls the lifetime of the request.
If an non-200 HTTP status code is received, an error wrapping an HTTPError is returned.
func (*Client) PKSAddWithResponse ¶ added in v0.8.0
PKSAdd submits an ASCII armored keyring to the Key Service, as specified in section 4 of the OpenPGP HTTP Keyserver Protocol (HKP) specification and returns the server response upon successful submission. The context controls the lifetime of the request.
If an non-200 HTTP status code is received, an error wrapping an HTTPError is returned.
func (*Client) PKSLookup ¶
func (c *Client) PKSLookup(ctx context.Context, pd *PageDetails, search, operation string, fingerprint, exact bool, options []string) (response string, err error)
PKSLookup requests data from the Key Service, as specified in section 3 of the OpenPGP HTTP Keyserver Protocol (HKP) specification. The context controls the lifetime of the request.
If an non-200 HTTP status code is received, an error wrapping an HTTPError is returned.
type HTTPError ¶
type HTTPError struct {
// contains filtered or unexported fields
}
HTTPError represents an error returned from an HTTP server.
type Option ¶
type Option func(co *clientOptions) error
Option are used to populate co.
func OptBaseURL ¶
OptBaseURL sets the base URL of the key server to url. The supported URL schemes are "http", "https", "hkp", and "hkps".
func OptBearerToken ¶
OptBearerToken sets the bearer token to include in the "Authorization" header of each request.
func OptHTTPClient ¶
OptHTTPClient sets the client to use to make HTTP requests.
func OptUserAgent ¶
OptUserAgent sets the HTTP user agent to include in the "User-Agent" header of each request.
type PageDetails ¶
type PageDetails struct { // Maximum number of results per page (server may ignore or return fewer). Size int // Token for next page (advanced with each request, empty for last page). Token string }
PageDetails includes pagination details.