Documentation
¶
Index ¶
- Constants
- Variables
- func RepoFromString(str string) (string, error)
- func WithCaller(c Caller) fnOpt
- func WithEnsureToken(e bool) fnOpt
- func WithHost(h string) fnOpt
- func WithToken(t string) fnOpt
- func WithTokenReader(r TokenReader) fnOpt
- type Caller
- type Client
- type EnvTokenReader
- type FileCaller
- type NativeHTTPCaller
- type Options
- type TokenReader
Constants ¶
const DefaultAPIHostname = "api.github.com"
Variables ¶
var DefaultEnvTokenReader = EnvTokenReader{
VarName: "GITHUB_TOKEN",
}
DefaultEnvTokenReader is an env token reader configured to read the token from the GITHUB_TOKEN env variable.
Functions ¶
func RepoFromString ¶ added in v0.2.0
RepoFromString returns a repository URL from a string. It supports full URLs, repo slugs (org/repo), VCS locators and possibly more input types will be added in the future.
func WithCaller ¶
func WithCaller(c Caller) fnOpt
func WithEnsureToken ¶
func WithEnsureToken(e bool) fnOpt
func WithTokenReader ¶
func WithTokenReader(r TokenReader) fnOpt
Types ¶
type Caller ¶
type Caller interface {
RequestWithContext(context.Context, string, string, io.Reader) (*http.Response, error)
}
Replaceable caller interface
type Client ¶
type Client struct {
Options Options
// contains filtered or unexported fields
}
func NewClientWithOptions ¶
NewClientWithOptions creates a new client, taking a full options set.
func (*Client) TokenScopes ¶ added in v0.2.2
TokenScopes returns the scopes of the token as reflected by the GitHub API.
type EnvTokenReader ¶
type EnvTokenReader struct {
VarName string
}
EnvTokenReader is a token reader that extracts an API token from an environment variable
func (*EnvTokenReader) ReadToken ¶
func (etr *EnvTokenReader) ReadToken() (string, error)
ReadToken reads the token string from the convigured `VarName` environment variable.
type FileCaller ¶
FileCaller implements the Caller but returns the data as read from a file specified in SourcePath. This is intended mostly for testing.
type NativeHTTPCaller ¶ added in v0.2.0
type NativeHTTPCaller struct {
Hostname string
// contains filtered or unexported fields
}
NativeHTTPClient implements the caller interface with minimal dependencies
func NewNativeHTTPCaller ¶ added in v0.2.0
func NewNativeHTTPCaller(opts *Options) (*NativeHTTPCaller, error)
type Options ¶
type Options struct {
Host string
Token string
EnsureToken bool
TokenReader TokenReader
Caller Caller
}
type TokenReader ¶
TokenReader is an interface that abstracts a mechanism to read a token securely.