go: cloud.google.com/go/bigtable/internal/cbtconfig Index | Files

package cbtconfig

import "cloud.google.com/go/bigtable/internal/cbtconfig"

Package cbtconfig encapsulates common code for reading configuration from .cbtrc and gcloud.

Index

Package Files

cbtconfig.go

func Filename Uses

func Filename() string

Filename returns the filename consulted for standard configuration.

type Config Uses

type Config struct {
    Project, Instance string                           // required
    Creds             string                           // optional
    AdminEndpoint     string                           // optional
    DataEndpoint      string                           // optional
    CertFile          string                           // optional
    TokenSource       oauth2.TokenSource               // derived
    TLSCreds          credentials.TransportCredentials // derived
}

Config represents a configuration.

func Load Uses

func Load() (*Config, error)

Load loads a .cbtrc file. If the file is not present, an empty config is returned.

func (*Config) CheckFlags Uses

func (c *Config) CheckFlags(required RequiredFlags) error

CheckFlags checks that the required config values are set.

func (*Config) RegisterFlags Uses

func (c *Config) RegisterFlags()

RegisterFlags registers a set of standard flags for this config. It should be called before flag.Parse.

func (*Config) SetFromGcloud Uses

func (c *Config) SetFromGcloud() error

SetFromGcloud retrieves and sets any missing config values from the gcloud configuration if possible possible

type GcloudCmdTokenSource Uses

type GcloudCmdTokenSource struct {
    Command string
    Args    []string
}

func (*GcloudCmdTokenSource) Token Uses

func (g *GcloudCmdTokenSource) Token() (*oauth2.Token, error)

Token implements the oauth2.TokenSource interface

type GcloudConfig Uses

type GcloudConfig struct {
    Configuration struct {
        Properties struct {
            Core struct {
                Project string `json:"project"`
            } `json:"core"`
        } `json:"properties"`
    }   `json:"configuration"`
    Credential GcloudCredential `json:"credential"`
}

func LoadGcloudConfig Uses

func LoadGcloudConfig(gcloudCmd string, gcloudCmdArgs []string) (*GcloudConfig, error)

LoadGcloudConfig retrieves the gcloud configuration values we need use via the 'config-helper' command

type GcloudCredential Uses

type GcloudCredential struct {
    AccessToken string    `json:"access_token"`
    Expiry      time.Time `json:"token_expiry"`
}

func (*GcloudCredential) Token Uses

func (cred *GcloudCredential) Token() *oauth2.Token

type RequiredFlags Uses

type RequiredFlags uint
const (
    ProjectRequired RequiredFlags = 1 << iota
    InstanceRequired
)
const NoneRequired RequiredFlags = 0
const ProjectAndInstanceRequired RequiredFlags = ProjectRequired | InstanceRequired

Package cbtconfig imports 17 packages (graph) and is imported by 6 packages. Updated 2017-09-24. Refresh now. Tools for package owners.