convert

package
v1.56.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

README

Convert

This package aims at converting a CLI version of the automation config to the format required by the C/OM API

Documentation

Index

Constants

View Source
const (
	AdminDB        = "admin"
	ExternalAuthDB = "$external"
)

Variables

View Source
var (
	ErrNoFeatureCompatibility = errors.New("no featureCompatibilityVersion available")
	ErrInvalidConfig          = errors.New("invalid config")
)

Functions

func BuildAtlasActions

func BuildAtlasActions(a []string) []atlasv2.DatabasePrivilegeAction

BuildAtlasActions converts the actions inside the array of string in an array of atlas.Action structs r contains roles in the format action[@dbName.collection].

func BuildAtlasInheritedRoles

func BuildAtlasInheritedRoles(r []string) []atlasv2.DatabaseInheritedRole

BuildAtlasInheritedRoles converts the inherited roles inside the array of string in an array of atlas.InheritedRole structs r contains roles in the format roleName@dbName.

func BuildAtlasRoles

func BuildAtlasRoles(r []string) []atlasv2.DatabaseUserRole

BuildAtlasRoles converts the roles inside the array of string in an array of mongodbatlas.DatabaseUserRole structs. r contains roles in the format roleName@dbName.

func BuildAtlasScopes

func BuildAtlasScopes(r []string) []atlasv2.UserScope

BuildAtlasScopes converts the scopes inside the array of string in an array of mongodbatlas.Scope structs. r contains resources in the format resourceName:resourceType.

func BuildOMRoles

func BuildOMRoles(r []string) []*opsmngr.Role

BuildOMRoles converts the roles inside the array of string in an array of opsmngr.DatabaseUserRole structs. r contains roles in the format roleName@dbName.

func GetAuthDB

func GetAuthDB(user *atlasv2.CloudDatabaseUser) string

GetAuthDB determines the authentication database based on the type of user. LDAP, X509 and AWSIAM should all use $external. SCRAM-SHA should use admin.

func ParseDeleteAfter

func ParseDeleteAfter(deleteAfter string) *time.Time

Types

type ClusterConfig

type ClusterConfig struct {
	RSConfig `yaml:",inline"`
	MongoURI string           `yaml:"mongoURI,omitempty" json:"mongoURI,omitempty"`
	Shards   []*RSConfig      `yaml:"shards,omitempty" json:"shards,omitempty"`
	Config   *RSConfig        `yaml:"config,omitempty" json:"config,omitempty"`
	Mongos   []*ProcessConfig `yaml:"mongos,omitempty" json:"mongos,omitempty"`
}

ClusterConfig configuration for a cluster This cluster can be used to patch an automation config.

func FromAutomationConfig

func FromAutomationConfig(c *opsmngr.AutomationConfig) []*ClusterConfig

FromAutomationConfig convert from opsmngr.AutomationConfig format to []*ClusterConfig the given opsmngr.AutomationConfig will be modified.

func (*ClusterConfig) PatchAutomationConfig

func (c *ClusterConfig) PatchAutomationConfig(out *opsmngr.AutomationConfig) error

PatchAutomationConfig adds the ClusterConfig to a opsmngr.AutomationConfig this method will modify the given AutomationConfig to add the new replica set or sharded cluster information.

type DefaultRWConcern

type DefaultRWConcern struct {
	DefaultReadConcern  *DefaultReadConcern  `yaml:"defaultReadConcern,omitempty" json:"defaultReadConcern,omitempty"`
	DefaultWriteConcern *DefaultWriteConcern `yaml:"defaultWriteConcern,omitempty" json:"defaultWriteConcern,omitempty"`
}

type DefaultReadConcern

type DefaultReadConcern struct {
	Level string `yaml:"level" json:"level"`
}

type DefaultWriteConcern

type DefaultWriteConcern struct {
	W        interface{} `yaml:"w,omitempty" json:"w,omitempty"` // W can be string or number
	J        *bool       `yaml:"j,omitempty" json:"j,omitempty"`
	Wtimeout int         `yaml:"wtimeout" json:"wtimeout"`
}

type ProcessConfig

type ProcessConfig struct {
	ArbiterOnly                      *bool                   `yaml:"arbiterOnly,omitempty" json:"arbiterOnly,omitempty"`
	AuditLogPath                     string                  `yaml:"auditLogPath,omitempty" json:"auditLogPath,omitempty"`
	AuditLogDestination              string                  `yaml:"auditLogDestination,omitempty" json:"auditLogDestination,omitempty"`
	AuditLogFormat                   string                  `yaml:"auditLogFormat,omitempty" json:"auditLogFormat,omitempty"`
	AuditLogFilter                   string                  `yaml:"auditLogFilter,omitempty" json:"auditLogFilter,omitempty"`
	BackupRestoreCheckpointTimestamp interface{}             `yaml:"backupRestoreCheckpointTimestamp,omitempty" json:"backupRestoreCheckpointTimestamp,omitempty"`
	BuildIndexes                     *bool                   `yaml:"buildIndexes,omitempty" json:"buildIndexes,omitempty"`
	DBPath                           string                  `yaml:"dbPath,omitempty" json:"dbPath,omitempty"`
	BindIP                           *string                 `yaml:"bindIp,omitempty" json:"bindIp,omitempty"`
	BindIPAll                        *bool                   `yaml:"bindIpAll,omitempty" json:"bindIpAll,omitempty"`
	DefaultRWConcern                 *DefaultRWConcern       `yaml:"defaultRWConcern,omitempty" json:"defaultRWConcern,omitempty"` //nolint:tagliatelle // correct from API
	DirectoryPerDB                   *bool                   `yaml:"directoryPerDB,omitempty" json:"directoryPerDB,omitempty"`
	Disabled                         bool                    `yaml:"disabled" json:"disabled"`
	Engine                           string                  `yaml:"engine,omitempty" json:"engine,omitempty"`
	EnableMajorityReadConcern        *bool                   `yaml:"enableMajorityReadConcern,omitempty" json:"enableMajorityReadConcern,omitempty"`
	FeatureCompatibilityVersion      string                  `yaml:"featureCompatibilityVersion,omitempty" json:"featureCompatibilityVersion,omitempty"`
	Hidden                           *bool                   `yaml:"hidden,omitempty" json:"hidden,omitempty"`
	Hostname                         string                  `yaml:"hostname" json:"hostname"`
	InMemory                         *map[string]interface{} `yaml:"inMemory,omitempty" json:"inMemory,omitempty"`
	IndexBuildRetry                  *bool                   `yaml:"indexBuildRetry,omitempty" json:"indexBuildRetry,omitempty"`
	IPV6                             *bool                   `yaml:"ipv6,omitempty" json:"ipv6,omitempty"`
	Journal                          *map[string]interface{} `yaml:"journal,omitempty" json:"journal,omitempty"`
	LogAppend                        bool                    `yaml:"logAppend,omitempty" json:"logAppend,omitempty"`
	LogDestination                   string                  `yaml:"logDestination,omitempty" json:"logDestination,omitempty"`
	LogPath                          string                  `yaml:"logPath" json:"logPath"`
	LogRotate                        string                  `yaml:"logRotate,omitempty" json:"logRotate,omitempty"`
	LogVerbosity                     int                     `yaml:"logVerbosity,omitempty" json:"logVerbosity,omitempty"`
	LogQuiet                         bool                    `yaml:"logQuiet,omitempty" json:"logQuiet,omitempty"`
	SyslogFacility                   string                  `yaml:"syslogFacility,omitempty" json:"syslogFacility,omitempty"`
	LogTimeStampFormat               string                  `yaml:"logTimeStampFormat,omitempty" json:"logTimeStampFormat,omitempty"`
	Name                             string                  `yaml:"name,omitempty" json:"name,omitempty"`
	OperationProfiling               *map[string]interface{} `yaml:"operationProfiling,omitempty" json:"operationProfiling,omitempty"`
	OplogMinRetentionHours           *float64                `yaml:"oplogMinRetentionHours,omitempty" json:"oplogMinRetentionHours,omitempty"`
	OplogSizeMB                      *int                    `yaml:"oplogSizeMB,omitempty" json:"oplogSizeMB,omitempty"`
	Port                             int                     `yaml:"port" json:"port"`
	Priority                         *float64                `yaml:"priority,omitempty" json:"priority,omitempty"`
	ProcessType                      string                  `yaml:"processType" json:"processType"`
	SmallFiles                       *bool                   `yaml:"smallFiles,omitempty" json:"smallFiles,omitempty"`
	SecondaryDelaySecs               *float64                `yaml:"secondaryDelaySecs,omitempty" json:"secondaryDelaySecs,omitempty"`
	SlaveDelay                       *float64                `yaml:"slaveDelay,omitempty" json:"slaveDelay,omitempty"`
	SyncPeriodSecs                   *float64                `yaml:"syncPeriodSecs,omitempty" json:"syncPeriodSecs,omitempty"`
	Votes                            *float64                `yaml:"votes,omitempty" json:"votes,omitempty"`
	Security                         *map[string]interface{} `yaml:"security,omitempty" json:"security,omitempty"`
	SetParameter                     *map[string]interface{} `yaml:"setParameter,omitempty" json:"setParameter,omitempty"`
	TLS                              *TLS                    `yaml:"tls,omitempty" json:"tls,omitempty"`
	Version                          string                  `yaml:"version,omitempty" json:"version,omitempty"`
	WiredTiger                       *map[string]interface{} `yaml:"wiredTiger,omitempty" json:"wiredTiger,omitempty"`
}

ProcessConfig that belongs to a cluster.

type RSConfig

type RSConfig struct {
	Name                        string                    `yaml:"name,omitempty" json:"name,omitempty"`
	FeatureCompatibilityVersion string                    `yaml:"featureCompatibilityVersion,omitempty" json:"featureCompatibilityVersion,omitempty"`
	Processes                   []*ProcessConfig          `yaml:"processes,omitempty" json:"processes,omitempty"`
	Tags                        []*map[string]interface{} `yaml:"tags,omitempty" json:"tags,omitempty"`
	Version                     string                    `yaml:"version,omitempty" json:"version,omitempty"`
}

RSConfig shared properties of replica sets, config servers, and sharded clusters.

type TLS

type TLS struct {
	CAFile                     string `yaml:"CAFile,omitempty" json:"CAFile,omitempty"`
	CertificateKeyFile         string `yaml:"certificateKeyFile,omitempty" json:"certificateKeyFile,omitempty"`
	CertificateKeyFilePassword string `yaml:"certificateKeyFilePassword,omitempty" json:"certificateKeyFilePassword,omitempty"`
	CertificateSelector        string `yaml:"certificateSelector,omitempty" json:"certificateSelector,omitempty"`
	ClusterCertificateSelector string `yaml:"clusterCertificateSelector,omitempty" json:"clusterCertificateSelector,omitempty"`
	ClusterFile                string `yaml:"clusterFile,omitempty" json:"clusterFile,omitempty"`
	ClusterPassword            string `yaml:"clusterPassword,omitempty" json:"clusterPassword,omitempty"`
	CRLFile                    string `yaml:"CRLFile,omitempty" json:"CRLFile,omitempty"`
	DisabledProtocols          string `yaml:"disabledProtocols,omitempty" json:"disabledProtocols,omitempty"`
	FIPSMode                   *bool  `yaml:"FIPSMode,omitempty" json:"FIPSMode,omitempty"`
	Mode                       string `yaml:"mode,omitempty" json:"mode,omitempty"`
	PEMKeyFile                 string `yaml:"PEMKeyFile,omitempty" json:"PEMKeyFile,omitempty"`
}

TLS defines TLS parameters for Net.

Jump to

Keyboard shortcuts

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