client

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ClientFromCfg = func(hostname string, cfg config.Config) (*api.Client, error) {
	var opts []api.ClientOption

	token, err := cfg.Get(hostname, "oauth_token")
	if err != nil {
		return nil, err
	}

	if token == "" {
		return nil, fmt.Errorf("no token found in config for %s", hostname)
	}

	opts = append(opts,

		api.AddHeader("User-Agent", "GitHub CLI"),
		api.AddHeaderFunc("Authorization", func(req *http.Request) (string, error) {
			return fmt.Sprintf("token %s", token), nil
		}),
	)

	httpClient := api.NewHTTPClient(opts...)

	return api.NewClientFromHTTP(httpClient), nil
}

Functions

func ValidateHostCfg

func ValidateHostCfg(hostname string, cfg config.Config) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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