options

package
v0.0.0-...-ac81b06 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2015 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package options implements command-line options that are used by all of the mongo tools.

Index

Constants

View Source
const (
	VersionStr = "3.1.5-pre-"
)

Variables

View Source
var ConnectionOptFunctions []OptionRegistrationFunction
View Source
var (
	Gitspec = "not-built-with-ldflags"
)

Gitspec that the tool was built with. Needs to be set using -ldflags

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Username  string `short:"u" long:"username" description:"username for authentication"`
	Password  string `short:"p" long:"password" description:"password for authentication"`
	Source    string `long:"authenticationDatabase" description:"database that holds the user's credentials"`
	Mechanism string `long:"authenticationMechanism" description:"authentication mechanism to use"`
}

Struct holding auth-related options

func (*Auth) RequiresExternalDB

func (auth *Auth) RequiresExternalDB() bool

func (*Auth) ShouldAskForPassword

func (auth *Auth) ShouldAskForPassword() bool

ShouldAskForPassword returns true if the user specifies a username flag but no password, and the authentication mechanism requires a password.

type Connection

type Connection struct {
	Host string `short:"h" long:"host" description:"mongodb host to connect to (setname/host1,host2 for replica sets)"`
	Port string `long:"port" description:"server port (can also use --host hostname:port)"`
}

Struct holding connection-related options

type EnabledOptions

type EnabledOptions struct {
	Auth       bool
	Connection bool
	Namespace  bool
}

type ExtraOptions

type ExtraOptions interface {
	// Name specifying what type of options these are
	Name() string
}

Interface for extra options that need to be used by specific tools

type General

type General struct {
	Help    bool `long:"help" description:"print usage"`
	Version bool `long:"version" description:"print the tool version and exit"`
}

Struct holding generic options

type HiddenOptions

type HiddenOptions struct {
	MaxProcs       int
	BulkBufferSize int

	// Specifies the number of threads to use in processing data read from the input source
	NumDecodingWorkers int

	// Deprecated flag for csv writing in mongoexport
	CSVOutputType bool

	TempUsersColl *string
	TempRolesColl *string
}

type Kerberos

type Kerberos struct {
	Service     string `long:"gssapiServiceName" description:"service name to use when authenticating using GSSAPI/Kerberos ('mongodb' by default)"`
	ServiceHost string `` /* 130-byte string literal not displayed */
}

Struct for Kerberos/GSSAPI-specific options

type Namespace

type Namespace struct {
	// Specified database and collection
	DB         string `short:"d" long:"db" description:"database to use"`
	Collection string `short:"c" long:"collection" description:"collection to use"`
}

type OptionRegistrationFunction

type OptionRegistrationFunction func(o *ToolOptions) error

type SSL

type SSL struct {
	UseSSL              bool   `long:"ssl" description:"connect to a mongod or mongos that has ssl enabled"`
	SSLCAFile           string `long:"sslCAFile" description:"the .pem file containing the root certificate chain from the certificate authority"`
	SSLPEMKeyFile       string `long:"sslPEMKeyFile" description:"the .pem file containing the certificate and key"`
	SSLPEMKeyPassword   string `long:"sslPEMKeyPassword" description:"the password to decrypt the sslPEMKeyFile, if necessary"`
	SSLCRLFile          string `long:"sslCRLFile" description:"the .pem file containing the certificate revocation list"`
	SSLAllowInvalidCert bool   `long:"sslAllowInvalidCertificates" description:"bypass the validation for server certificates"`
	SSLAllowInvalidHost bool   `long:"sslAllowInvalidHostnames" description:"bypass the validation for server name"`
	SSLFipsMode         bool   `long:"sslFIPSMode" description:"use FIPS mode of the installed openssl library"`
}

Struct holding ssl-related options

type ToolOptions

type ToolOptions struct {

	// The name of the tool
	AppName string

	// The version of the tool
	VersionStr string

	// Sub-option types
	*General
	*Verbosity
	*Connection
	*SSL
	*Auth
	*Kerberos
	*Namespace
	*HiddenOptions

	// Force direct connection to the server and disable the
	// drivers automatic repl set discovery logic.
	Direct bool

	// ReplicaSetName, if specified, will prevent the obtained session from
	// communicating with any server which is not part of a replica set
	// with the given name. The default is to communicate with any server
	// specified or discovered via the servers contacted.
	ReplicaSetName string
	// contains filtered or unexported fields
}

Struct encompassing all of the options that are reused across tools: "help", "version", verbosity settings, ssl settings, etc.

func New

func New(appName, usageStr string, enabled EnabledOptions) *ToolOptions

Ask for a new instance of tool options

func (*ToolOptions) AddOptions

func (o *ToolOptions) AddOptions(opts ExtraOptions) error

AddOptions registers an additional options group to this instance

func (*ToolOptions) GetAuthenticationDatabase

func (o *ToolOptions) GetAuthenticationDatabase() string

Get the authentication database to use. Should be the value of --authenticationDatabase if it's provided, otherwise, the database that's specified in the tool's --db arg.

func (*ToolOptions) Parse

func (o *ToolOptions) Parse() ([]string, error)

Parse the command line args. Returns any extra args not accounted for by parsing, as well as an error if the parsing returns an error.

func (*ToolOptions) PrintHelp

func (o *ToolOptions) PrintHelp(force bool) bool

Print the usage message for the tool to stdout. Returns whether or not the help flag is specified.

func (*ToolOptions) PrintVersion

func (o *ToolOptions) PrintVersion() bool

Print the tool version to stdout. Returns whether or not the version flag is specified.

type Verbosity

type Verbosity struct {
	Verbose []bool `short:"v" long:"verbose" description:"more detailed log output (include multiple times for more verbosity, e.g. -vvvvv)"`
	Quiet   bool   `long:"quiet" description:"hide all log output"`
}

Struct holding verbosity-related options

func (Verbosity) IsQuiet

func (v Verbosity) IsQuiet() bool

func (Verbosity) Level

func (v Verbosity) Level() int

Jump to

Keyboard shortcuts

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