all repos — memnarch @ c28267af045fccf922a7eb484b8b6844019305ab

featherweight orchestrator

layin a base
Iris Lightshard nilix@nilfm.cc
PGP Signature
-----BEGIN PGP SIGNATURE-----

iHUEABYKAB0WIQR2zYvweXfSPsSU6pP1Tg1AaVJx1AUCZQaNbwAKCRD1Tg1AaVJx
1M1sAP9UPLHxJ5Q6ZCGVSxNr8gyPJixGSF5mYWi0HhtCNj0n4wEA1EHl4y3iTmFi
jL56PDn2049HFY6ZUWeclKAMp6REfQM=
=LGyo
-----END PGP SIGNATURE-----
commit

c28267af045fccf922a7eb484b8b6844019305ab

parent

734eab3cfdf4291d064c479653fb07cc194305bf

4 files changed, 71 insertions(+), 6 deletions(-)

jump to
A .memnarch/test.yml

@@ -0,0 +1,14 @@

+build: + cmd: go build +deploy: + hosts: + - amethyst + - vajra + artifacts: + - /opt/memnarch/: + - memnarch + before: + - step1 echo this is silly + - step2 echo we are just filling steps to test the parser + after: + - step99 echo deployment successful. always a pleasure
M action/action.goaction/action.go

@@ -12,10 +12,10 @@ Build struct {

Cmd string `yaml:"cmd"` } `yaml:"build,omitempty"` Deploy struct { - Hosts []string `yaml:"hosts"` + Hosts map[string]string `yaml:"hosts"` Artifacts map[string][]string `yaml:"artifacts"` - Before map[string]string `yaml:"before,omitempty"` - After map[string]string `yaml:"after,omitempty"` + Before map[string][]string `yaml:"before,omitempty"` + After map[string][]string `yaml:"after,omitempty"` } `yaml:"deploy,omitempty"` }
A hosts/hosts.go

@@ -0,0 +1,17 @@

+package hosts + +// a host is a name and an address +// memnarch expects an SSH private key to connect to Addr to exist at MEMNARCH_HOSTS/Name + +type Host struct { + Name string + Addr string +} + +type RemoteMachine interface { + Run(...string) error +} + +func (*Host) Run(cmdArgs ...string) error { + return nil +}
M main.gomain.go

@@ -15,6 +15,7 @@ . "hacklab.nilfm.cc/quartzgun/util"

"forge.lightcrystal.systems/lightcrystal/memnarch/action" "forge.lightcrystal.systems/lightcrystal/memnarch/webhook" + host "forge.lightcrystal.systems/lightcrystal/memnarch/hosts" ) func decode(next http.Handler) http.Handler {

@@ -87,10 +88,43 @@ // decode and perform action

// build buildCmd := exec.Command(a.Build.Cmd) buildCmd.Dir = filepath.Join(workingDir, repo) + buildOutput, err := buildCmd.CombinedOutput() + + if err != nil { + fmt.Println(buildOutput) + // log that build failed, with the complete output + } - // pre-deploy - // deploy - // post-deploy + // for each host, we gotta get the key and then, thru ssh + for name, addr := range a.Deploy.Hosts { + h := host.Host{ + Name: name, + Addr: addr, + } + // pre-deploy + for _, step := range a.Deploy.Before { + err := h.Run(step...) + if err != nil { + // log error or recover + } + } + // deploy artifacts + for path, artifacts := range a.Deploy.Artifacts { + for _, a := range artifacts { + fmt.Println(path + " :: " + a) + // use rsync to copy artifact to path on host + // return an error if we get one + } + } + + // post-deploy + for _, step := range a.Deploy.After { + err := h.Run(step...) + if err != nil { + // log error or recover + } + } + } }() AddContextValue(req, "data", "job submitted")