config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package config defines configurable values shared between Source and Destination and implements a method to parse them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfig

type AuthConfig struct {
	// Username is the username.
	Username string `json:"username"`
	// Password is the user's password.
	Password string `json:"password"`
	// DB is the name of a database that contains
	// the user's authentication data.
	DB string `json:"db"`
	// Mechanism is the authentication mechanism.
	Mechanism AuthMechanism `json:"mechanism"`
	// TLSCAFile is the path to either a single or a bundle of
	// certificate authorities to trust when making a TLS connection.
	//nolint:tagliatelle // we prefer our convention with dots as separators
	TLSCAFile string `json:"tls.caFile"`
	// TLSCertificateKeyFile is the path to the client certificate
	// file or the client private key file.
	//nolint:tagliatelle // we prefer our convention with dots as separators
	TLSCertificateKeyFile string `json:"tls.certificateKeyFile"`
	// AWSSessionToken is an AWS session token.
	AWSSessionToken string `json:"awsSessionToken"`
}

AuthConfig contains authentication-specific configurable values.

type AuthMechanism

type AuthMechanism string

AuthMechanism defines a MongoDB authentication mechanism.

const (
	SCRAMSHA256 AuthMechanism = "SCRAM-SHA-256"
	SCRAMSHA1   AuthMechanism = "SCRAM-SHA-1"
	MongoDBCR   AuthMechanism = "MONGODB-CR"
	MongoDBAWS  AuthMechanism = "MONGODB-AWS"
	MongoDBX509 AuthMechanism = "MONGODB-X509"
)

The list of available authentication mechanisms is listed below.

func (AuthMechanism) IsValid

func (am AuthMechanism) IsValid() bool

IsValid checks if the underlying AuthMechanism is valid.

type Config

type Config struct {
	// URI is the connection string.
	// The URI can contain host names, IPv4/IPv6 literals, or an SRV record.
	URIStr string `json:"uri" default:"mongodb://localhost:27017"`

	// DB is the name of a database the connector must work with.
	DB string `json:"db" validate:"required"`
	// Collection is the name of a collection the connector must
	// write to (destination) or read from (source).
	Collection string `json:"collection" validate:"required"`

	Auth AuthConfig `json:"auth"`
	// contains filtered or unexported fields
}

Config contains configurable values shared between source and destination MongoDB connector.

func (*Config) GetClientOptions

func (c *Config) GetClientOptions() *options.ClientOptions

GetClientOptions returns generated options for mongo connection depending on mechanism.

func (*Config) Validate added in v0.2.0

func (c *Config) Validate(context.Context) error

type InvalidAuthMechanismError

type InvalidAuthMechanismError struct {
	AuthMechanism AuthMechanism
}

InvalidAuthMechanismError occurs when a string is not a valid AuthMechanism.

func (*InvalidAuthMechanismError) Error

func (e *InvalidAuthMechanismError) Error() string

Error returns a formatted error message for the InvalidAuthMechanismError.

Jump to

Keyboard shortcuts

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