package lib
import "github.com/purpleidea/mgmt/lib"
Package lib is the home for the mgmt core library. It is implemented as a library (so that it can be reused within other programs) and our cli is just a wrapper around this.
Index ¶
Constants ¶
const ( // NS is the root namespace for etcd operations. All keys must use it! NS = "/_mgmt" // must not end with a slash! // MetadataPrefix is the etcd prefix where all our fs superblocks live. MetadataPrefix = "/fs" // StoragePrefix is the etcd prefix where all our fs data lives. StoragePrefix = "/storage" )
Types ¶
type Config ¶
type Config struct { // Program is the name of this program, usually set at compile time. Program string `arg:"-"` // cli should ignore // Version is the version of this program, usually set at compile time. Version string `arg:"-"` // cli should ignore // Debug represents if we're running in debug mode or not. Debug bool `arg:"-"` // cli should ignore // Logf is a logger which should be used. Logf func(format string, v ...interface{}) `arg:"-"` // cli should ignore // Hostname to use; nil if undefined. Useful for testing multiple // instances on same machine or for overriding a bad automatic hostname. Hostname *string `arg:"--hostname" help:"hostname to use"` // Prefix passed in; nil if undefined. Prefix *string `arg:"--prefix,env:MGMT_PREFIX" help:"specify a path to the working prefix directory"` // TmpPrefix requests a pseudo-random, temporary prefix to be used. TmpPrefix bool `arg:"--tmp-prefix" help:"request a pseudo-random, temporary prefix to be used"` // AllowTmpPrefix allows creation of a new temporary prefix if main // prefix is unavailable. AllowTmpPrefix bool `arg:"--allow-tmp-prefix" help:"allow creation of a new temporary prefix if main prefix is unavailable"` // NoWatch tells engine to not change graph under any circumstances. // TODO: We should consider deprecating this feature. NoWatch bool `arg:"--no-watch" help:"do not update graph under any switch events"` // NoStreamWatch tells engine to not update graph due to stream changes. // TODO: We should consider deprecating this feature. NoStreamWatch bool `arg:"--no-stream-watch" help:"do not update graph on stream switch events"` // NoDeployWatch tells engine to not change deploys after an initial // deploy. // TODO: We should consider deprecating this feature. NoDeployWatch bool `arg:"--no-deploy-watch" help:"do not change deploys after an initial deploy"` // NoAutoEdges tells the engine to not try and build autoedges. NoAutoEdges bool `arg:"--no-autoedges" help:"skip the autoedges stage"` // Noop globally forces all resources into no-op mode. Noop bool `arg:"--noop" help:"globally force all resources into no-op mode"` // Sema adds a semaphore with this lock count to each resource. This is // useful for reducing parallelism. Sema int `arg:"--sema" default:"-1" help:"globally add a semaphore to downloads with this lock count"` // Graphviz is the output file for graphviz data. Graphviz string `arg:"--graphviz" help:"output file for graphviz data"` // GraphvizFilter is the graphviz filter to use, such as `dot` or // `neato`. GraphvizFilter string `arg:"--graphviz-filter" help:"graphviz filter to use"` // ConvergedTimeout of approximately this many seconds of inactivity // means we're in a converged state; -1 to disable. ConvergedTimeout int `arg:"--converged-timeout,env:MGMT_CONVERGED_TIMEOUT" default:"-1" help:"after approximately this many seconds without activity, we're considered to be in a converged state"` // ConvergedTimeoutNoExit means we don't exit on converged timeout. ConvergedTimeoutNoExit bool `arg:"--converged-timeout-no-exit" help:"don't exit on converged-timeout"` // ConvergedStatusFile is a file we append converged status to. ConvergedStatusFile string `arg:"--converged-status-file" help:"file to append the current converged state to, mostly used for testing"` // MaxRuntime tells the engine to exit after a maximum of approximately // this many seconds. Use 0 to disable this. MaxRuntime uint `arg:"--max-runtime,env:MGMT_MAX_RUNTIME" help:"exit after a maximum of approximately this many seconds"` // SshUrl can be specified if we want to transport the SSH client // connection over SSH. If this is specified, the second hop is made // with the Seeds values, but they connect from this destination. You // can specify this in the standard james@server:22 format. This will // use your ~/.ssh/ directory for public key authentication and // verifying the host key in the known_hosts file. This must already be // setup for things to work. SshUrl string `arg:"--ssh-url" help:"transport the etcd client connection over SSH to this server"` // Seeds are the list of default etcd client endpoints. If empty, it // will startup a new server. Seeds []string `arg:"--seeds,env:MGMT_SEEDS" help:"default etcd client endpoints"` // ClientURLs are a list of URLs to listen on for client traffic. Ports // 2379 and 4001 are common. ClientURLs []string `arg:"--client-urls,env:MGMT_CLIENT_URLS" help:"list of URLs to listen on for client traffic"` // ServerURLs are a list of URLs to listen on for server (peer) traffic. // Ports 2380 and 7001 are common. Etcd now uses --peer-urls instead. ServerURLs []string `arg:"--server-urls,env:MGMT_SERVER_URLS" help:"list of URLs to listen on for server (peer) traffic"` // AdvertiseClientURLs are a list of URLs to advertise for client // traffic. Ports 2379 and 4001 are common. AdvertiseClientURLs []string `arg:"--advertise-client-urls,env:MGMT_ADVERTISE_CLIENT_URLS" help:"list of URLs to listen on for client traffic"` // AdvertiseServerURLs are a list of URLs to advertise for server (peer) // traffic. Ports 2380 and 7001 are common. Etcd now uses // --advertise-peer-urls instead. AdvertiseServerURLs []string `arg:"--advertise-server-urls,env:MGMT_ADVERTISE_SERVER_URLS" help:"list of URLs to listen on for server (peer) traffic"` // IdealClusterSize is the ideal number of server peers in cluster. This // value is only read by the initial server. IdealClusterSize int `arg:"--ideal-cluster-size,env:MGMT_IDEAL_CLUSTER_SIZE" default:"-1" help:"ideal number of server peers in cluster; only read by initial server"` // NoServer tells the engine to not let other servers peer with me. NoServer bool `arg:"--no-server" help:"do not start embedded etcd server (do not promote from client to peer)"` // NoNetwork tells the engine to run a single node instance without // clustering or opening tcp ports to the outside. NoNetwork bool `arg:"--no-network,env:MGMT_NO_NETWORK" help:"run single node instance without clustering or opening tcp ports to the outside"` // NoMagic turns off some things which aren't needed when used with a // simple Seeds and NoServer option. NoMagic bool `arg:"--no-magic" help:"do not do any etcd magic (for simple clients)"` // NoPgp disables pgp functionality. NoPgp bool `arg:"--no-pgp" help:"don't create pgp keys"` // PgpKeyPath is used to import a pre-made key pair. PgpKeyPath *string `arg:"--pgp-key-path" help:"path for instance key pair"` // PgpIdentity is the user string used for pgp identity. PgpIdentity *string `arg:"--pgp-identity" help:"default identity used for generation"` // Prometheus enables prometheus metrics. Prometheus bool `arg:"--prometheus" help:"start a prometheus instance"` // PrometheusListen is the prometheus instance bind specification. PrometheusListen string `arg:"--prometheus-listen" help:"specify prometheus instance binding"` }
Config is a struct of all the configuration values for the Main struct. By including this as a separate struct, it can be used as part of the API. This API is not considered stable at this time, and is subject to change.
type Main ¶
type Main struct { // Config is all of our data embedded directly for reusability. *Config // embedded config Deploy *gapi.Deploy // deploy object including GAPI for static deploys DeployFs engine.Fs // used for static deploys // contains filtered or unexported fields }
Main is the main struct for running the mgmt logic.
func (*Main) Close ¶
Close contains a number of methods which must be run after the Run method. You must run them to properly clean up after the main program execution.
func (*Main) Exit ¶
Exit causes a safe shutdown. This is often attached to the ^C signal handler.
func (*Main) FastExit ¶
FastExit causes a faster shutdown. This is often activated on the second ^C.
func (*Main) Init ¶
Init initializes the main struct after it performs some validation.
func (*Main) Interrupt ¶
Interrupt causes the fastest shutdown. The only faster method is a kill -9 which could cause corruption. This is often activated on the third ^C. This might leave some of your resources in a partial or unknown state.
func (*Main) Run ¶
Run is the main execution entrypoint to run mgmt.
func (*Main) Validate ¶
Validate validates the main structure without making any modifications to it.
Source Files ¶
- Version
- v0.0.0-20250322185616-c50a578426f1 (latest)
- Published
- Mar 22, 2025
- Platform
- linux/amd64
- Imports
- 26 packages
- Last checked
- 4 days ago –
Tools for package owners.