convert

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2020 License: Apache-2.0 Imports: 6 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

Some examples of the expected CLI format are as follow

JSON

{
  "name": "cluster_3",
  "version": "4.2.2",
  "featureCompatibilityVersion": "4.2",
  "processes": [
    {
      "hostname": "host0",
      "dbPath": "/data/cluster_3/rs1",
      "logPath": "/data/cluster_3/rs1/mongodb.log",
      "priority": 1,
      "votes": 1,
      "port": 30010
    },
    {
      "hostname": "host1",
      "dbPath": "/data/cluster_3/rs2",
      "logPath": "/data/cluster_3/rs2/mongodb.log",
      "priority": 1,
      "votes": 1,
      "port": 30020
    },
    {
      "hostname": "host2",
      "dbPath": "/data/cluster_3/rs3",
      "logPath": "/data/cluster_3/rs3/mongodb.log",
      "priority": 1,
      "votes": 1,
      "port": 30030
    }
  ]
}

YAML

name: "cluster_2"
version: 4.2.2
featureCompatibilityVersion: 4.2
processes:
  - hostname: host0
    dbPath: /data/cluster_2/rs1
    logPath: /data/cluster_2/rs1/mongodb.log
    priority: 1
    votes: 1
    port: 29010
  - hostname: host1
    dbPath: /data/cluster_2/rs2
    logPath: /data/cluster_2/rs2/mongodb.log
    priority: 1
    votes: 1
    port: 29020
  - hostname: host2
    dbPath: /data/cluster_2/rs3
    logPath: /data/cluster_2/rs3/mongodb.log
    priority: 1
    votes: 1
    port: 29030

Note: Current implementation of the mapping assumes all processes will use the same binary version and feature compatibility version

Documentation

Index

Constants

View Source
const (
	AdminDB = "admin"
)

Public constants

Variables

This section is empty.

Functions

func BuildRoles

func BuildRoles(r []string) []atlas.Role

BuildRoles converts the roles inside the array of string in an array of Atlas.Role Objects r contains roles in the format roleName@dbName

func Shutdown

func Shutdown(out *om.AutomationConfig, name string)

Shutdown a cluster processes

func Startup

func Startup(out *om.AutomationConfig, name string)

Startup a cluster processes

Types

type ClusterConfig

type ClusterConfig struct {
	FCVersion      string          `yaml:"featureCompatibilityVersion,omitempty" json:"featureCompatibilityVersion,omitempty"`
	MongoURI       string          `yaml:"mongoURI,omitempty" json:"mongoURI,omitempty"`
	Name           string          `yaml:"name" json:"name"`
	ProcessConfigs []ProcessConfig `yaml:"processes" json:"processes"`
	Version        string          `yaml:"version,omitempty" json:"version,omitempty"`
}

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

func FromAutomationConfig

func FromAutomationConfig(in *om.AutomationConfig) (out []ClusterConfig)

FromAutomationConfig convert from cloud format to mCLI format

func (*ClusterConfig) PatchAutomationConfig

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

PatchAutomationConfig add the ClusterConfig to a cloudmanager.AutomationConfig this method will modify the given AutomationConfig to add the new replica set information

type ProcessConfig

type ProcessConfig struct {
	BuildIndexes *bool   `yaml:"buildIndexes,omitempty" json:"buildIndexes,omitempty"`
	DBPath       string  `yaml:"dbPath" json:"dbPath"`
	FCVersion    string  `yaml:"featureCompatibilityVersion,omitempty" json:"featureCompatibilityVersion,omitempty"`
	Hostname     string  `yaml:"hostname" json:"hostname"`
	LogPath      string  `yaml:"logPath" json:"logPath"`
	Name         string  `yaml:"name,omitempty" json:"name,omitempty"`
	Port         int     `yaml:"port" json:"port"`
	Priority     float64 `yaml:"priority" json:"priority"`
	ProcessType  string  `yaml:"processType" json:"processType"`
	SlaveDelay   float64 `yaml:"slaveDelay" json:"slaveDelay"`
	Version      string  `yaml:"version,omitempty" json:"version,omitempty"`
	Votes        float64 `yaml:"votes" json:"votes"`
	ArbiterOnly  bool    `yaml:"arbiterOnly" json:"arbiterOnly"`
	Disabled     bool    `yaml:"disabled" json:"disabled"`
	Hidden       bool    `yaml:"hidden" json:"hidden"`
}

ProcessConfig that belongs to a cluster

Jump to

Keyboard shortcuts

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