dbconfigs

package
v2.2.0-rc.1+incompatible Latest Latest
Warning

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

Go to latest
Published: May 18, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package dbconfigs is reusable by vt tools to load the db configs file.

Index

Constants

This section is empty.

Variables

View Source
var AllCredentialsServers = make(map[string]CredentialsServer)

AllCredentialsServers contains all the known CredentialsServer implementations. Note we will only access this after flags have been parsed.

View Source
var (

	// ErrUnknownUser is returned by credential server when the
	// user doesn't exist
	ErrUnknownUser = errors.New("unknown user")
)

Functions

func WithCredentials

func WithCredentials(cp *mysql.ConnParams) (mysql.ConnParams, error)

WithCredentials returns a copy of the provided ConnParams that we can use to connect, after going through the CredentialsServer.

Types

type CredentialsServer

type CredentialsServer interface {
	// GetUserAndPassword returns the user / password to use for a given
	// user. May return ErrUnknownUser. The user might be altered
	// to support versioned users.
	// Note this call needs to be thread safe, as we may call this from
	// multiple go routines.
	GetUserAndPassword(user string) (string, string, error)
}

CredentialsServer is the interface for a credential server

func GetCredentialsServer

func GetCredentialsServer() CredentialsServer

GetCredentialsServer returns the current CredentialsServer. Only valid after flag.Init was called.

type DBConfigFlag

type DBConfigFlag int

DBConfigFlag describes which flags we need

const (
	EmptyConfig DBConfigFlag = 0
	AppConfig   DBConfigFlag = 1 << iota
	AppDebugConfig
	// AllPrivs user should have more privileges than App (should include possibility to do
	// schema changes and write to internal Vitess tables), but it shouldn't have SUPER
	// privilege like Dba has.
	AllPrivsConfig
	DbaConfig
	FilteredConfig
	ReplConfig
)

config flags

func RegisterFlags

func RegisterFlags(flags DBConfigFlag) DBConfigFlag

RegisterFlags registers the flags for the given DBConfigFlag. For instance, vttablet will register client, dba and repl. Returns all registered flags.

type DBConfigs

type DBConfigs struct {
	App           mysql.ConnParams
	AppDebug      mysql.ConnParams
	AllPrivs      mysql.ConnParams
	Dba           mysql.ConnParams
	Filtered      mysql.ConnParams
	Repl          mysql.ConnParams
	SidecarDBName string
}

DBConfigs is all we need for a smart tablet server:

  • App access with db name for serving app queries
  • AllPrivs access for administrative actions (like schema changes) that should be done without SUPER privilege
  • Dba access for any dba-type operation (db creation, replication, ...)
  • Filtered access for filtered replication
  • Replication access to change master
  • SidecarDBName for storing operational metadata

func Init

func Init(socketFile string, flags DBConfigFlag) (*DBConfigs, error)

Init will initialize app, allprivs, dba, filtered and repl configs.

func (*DBConfigs) IsZero

func (dbcfgs *DBConfigs) IsZero() bool

IsZero returns true if DBConfigs was uninitialized.

func (*DBConfigs) Redact

func (dbcfgs *DBConfigs) Redact()

Redact will remove the password, so the object can be logged

func (*DBConfigs) String

func (dbcfgs *DBConfigs) String() string

type FileCredentialsServer

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

FileCredentialsServer is a simple implementation of CredentialsServer using a json file. Protected by mu.

func (*FileCredentialsServer) GetUserAndPassword

func (fcs *FileCredentialsServer) GetUserAndPassword(user string) (string, string, error)

GetUserAndPassword is part of the CredentialsServer interface

Jump to

Keyboard shortcuts

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