beetle

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package beetle reaches cm-beetle for the access details behind a beetle* ConnectionRef. cm-beetle fronts cb-tumblebug, so its responses are plain text: nothing here decrypts anything.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDatabase

func CreateDatabase(ref commonmodel.BeetleDBRef, database, charset, collation string) error

CreateDatabase creates a logical database inside a managed RDBMS instance. A managed database has to be asked for through cm-beetle, which owns the instance, so this never falls back to connecting to the database and issuing CREATE DATABASE.

charset and collation are the source database's defaults. What the instance's engine and CSP cannot take is dropped with a warning (see charsetPolicies), and the database then follows the instance default for it. That costs the migration nothing: a managed instance is MySQL or MariaDB, whose dumps name a character set on every table they create, so the database default is never what a restored table ends up with — only tables created later see it.

func DropDatabase

func DropDatabase(ref commonmodel.BeetleDBRef, database string) error

DropDatabase removes a logical database centipede created through CreateDatabase, after its migration failed or was cancelled.

func ListDatabases

func ListDatabases(ref commonmodel.BeetleDBRef) ([]string, error)

ListDatabases returns the logical databases inside a managed RDBMS instance.

This is cm-beetle's own list, the same one CreateDatabase and DropDatabase write to. Connecting to the database directly to ask instead can disagree with it, and that answer is what decides whether centipede owns a database and must drop it after a failure.

Types

type DBConfig

type DBConfig struct {
	DBType   string // mysql | mariadb — the engines cb-tumblebug prepares
	Host     string
	Port     int
	Username string
}

DBConfig is the normalised managed-DB access info. Password is not part of it: the lookup never returns one, so the caller supplies it from the ref. Username is empty from cm-beetle v0.6.2 on, whose RDBMS read dropped adminUserName; the ref's own username is what callers use.

func GetRDBMSAccessInfo

func GetRDBMSAccessInfo(ref commonmodel.BeetleDBRef) (*DBConfig, error)

GetRDBMSAccessInfo returns host/port/user/engine for a managed RDBMS instance. The password is not among them — cm-beetle takes one when the instance is created and never hands it back — so the caller supplies it from the ref.

type OSConfig

type OSConfig struct {
	Endpoint  string
	AccessKey string
	SecretKey string
	Bucket    string
	Region    string
	UseSSL    bool
}

OSConfig is the normalised object storage access info, providing S3-compatible credentials for the MinIO driver.

func GetObjectStorageInfo

func GetObjectStorageInfo(ref commonmodel.BeetleOSRef) (*OSConfig, error)

GetObjectStorageInfo returns S3-compatible credentials for one migrated object storage.

type SSHConfig

type SSHConfig struct {
	Host       string
	Port       int
	Username   string
	Password   string // empty when key-based auth is used
	PrivateKey string // PEM-encoded private key; empty when password auth is used
}

SSHConfig is the normalised SSH access info for one migrated node. All fields are plain text.

func GetSSHAccessInfo

func GetSSHAccessInfo(ref commonmodel.BeetleSSHRef) (*SSHConfig, error)

GetSSHAccessInfo assembles SSH credentials for one migrated node from two cm-beetle calls: the infra read supplies the endpoint and user, and the sshKey read supplies the private key.

cm-beetle does not expose cb-tumblebug's ?option=accessinfo, which would return all of it at once, so two calls are the only path available.

Errors:

  • beetle unreachable or non-200 response → wrapped error (caller returns 500)
  • nodeId not present in the infra → error (caller returns 400)

type SecureTransport

type SecureTransport struct {
	// RecommendedSSLMode is DISABLED, VERIFY_CA, VERIFY_IDENTITY, or empty when
	// the server offers TLS but its CA could not be collected (see CAError).
	RecommendedSSLMode string

	// RequireSecureTransport reports that the server refuses plaintext clients.
	RequireSecureTransport bool

	// CAPEM is the topmost certificate of the chain the server presented. cb-spider
	// collects it without verifying it, so it is trusted on first use. Empty when
	// the server sent none or the collection failed.
	CAPEM string

	// CANotAfter is when CAPEM expires; zero when unknown.
	CANotAfter time.Time

	// CAError says why CAPEM is empty when the server does offer TLS.
	CAError string
}

SecureTransport is what cb-spider measured on a managed instance's transport security, as cm-beetle relays it. It is advice for choosing a TLS mode, not a connection setting of its own.

func GetSecureTransport

func GetSecureTransport(ref commonmodel.BeetleDBRef, adminUser string) (*SecureTransport, error)

GetSecureTransport asks cm-beetle how a managed RDBMS instance does transport security, for choosing a TLS mode to connect with.

adminUser is the account the connection itself uses, which the caller has already resolved; cm-beetle needs it with the password to reach the instance, and stores neither.

Jump to

Keyboard shortcuts

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