main, lib: Build in standalone etcd

Standalone etcd is useful for when we don't want to use the embedded
version to make it easier to deploy somewhere or for testing.

This pulls in about the same amount of code since we already embedded
etcd previously. Since the embedded etcd feature of mgmt is not very
stable, we'll add this for now.
This commit is contained in:
James Shubin
2023-08-28 20:11:43 -04:00
parent bc390088b3
commit fb57fb714a
4 changed files with 34 additions and 0 deletions

14
main.go
View File

@@ -23,6 +23,7 @@ import (
"os"
mgmt "github.com/purpleidea/mgmt/lib"
"go.etcd.io/etcd/server/v3/etcdmain"
)
// These constants are some global variables that are used throughout the code.
@@ -41,6 +42,19 @@ var (
var copying string
func main() {
// embed etcd completely
if len(os.Args) >= 2 && os.Args[1] == "etcd" {
args := []string{}
for i, s := range os.Args {
if i == 0 { // pop off our argv[0] and let `etcd` be it
continue
}
args = append(args, s)
}
etcdmain.Main(args) // this will os.Exit
return // for safety
}
flags := mgmt.Flags{
Debug: Debug,
Verbose: Verbose,