config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package config provides methods for fetching and storing configuration.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoGoogleClientConfig indicates that the client configuration is missing.
	ErrNoGoogleClientConfig = errors.New("missing google client config")
	// ErrNoGoogleToken indicatges that the token is missing.
	ErrNoGoogleToken = errors.New("missing google token")
)

Functions

func ReadGoogleClientConfigFromFile

func ReadGoogleClientConfigFromFile(filepath string) (*oauth2.Config, error)

ReadGoogleClientConfigFromFile reads the content of a file and parses it as an *oauth2.Config

Types

type FileProvider

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

FileProvider is a Provider which uses files to store data.

func NewFileProvider

func NewFileProvider() (*FileProvider, error)

NewFileProvider returns a new FileProvider with the default filepath.

func (*FileProvider) GoogleClientConfig

func (f *FileProvider) GoogleClientConfig() (*oauth2.Config, error)

GoogleClientConfig returns the Google client configuration from the configuration file.

func (*FileProvider) GoogleClientConfigExists

func (f *FileProvider) GoogleClientConfigExists() bool

GoogleClientConfigExists returns true if the config is readable and valid, false otherwise.

func (*FileProvider) GoogleToken

func (f *FileProvider) GoogleToken() (*oauth2.Token, error)

GoogleToken fetches the Google token from the configuration file.

func (*FileProvider) GoogleTokenExists

func (f *FileProvider) GoogleTokenExists() bool

GoogleTokenExists returns true if the token is readable and valid, false otherwise.

func (*FileProvider) StoreGoogleClientConfig

func (f *FileProvider) StoreGoogleClientConfig(conf *oauth2.Config) error

StoreGoogleClientConfig writes the Google client config to the configuration file.

func (*FileProvider) StoreGoogleToken

func (f *FileProvider) StoreGoogleToken(token *oauth2.Token) error

StoreGoogleToken writes the Google token to the configuration file.

type Provider

type Provider interface {
	// GoogleClientConfig returns the Google client config.
	GoogleClientConfig() (*oauth2.Config, error)

	// StoreGoogleClientConfig writes the Google client config.
	StoreGoogleClientConfig(*oauth2.Config) error

	// GoogleClientConfigExists returns true if the client config is readable, false otherwise.
	GoogleClientConfigExists() bool

	// GoogleToken returns the Google token.
	GoogleToken() (*oauth2.Token, error)

	// StoreGoogleToken writes the Google token.
	StoreGoogleToken(*oauth2.Token) error

	// GoogleTokenExists returns true if the token is readable, false otherwise.
	GoogleTokenExists() bool
}

Provider is a token provider.

Jump to

Keyboard shortcuts

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