From 726b399e4747032a3d052339cd62c57ae5b6767c Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Sat, 15 Jul 2017 01:26:39 +0100 Subject: pipeline from spool to worker is done -- added examples --- commits.go | 6 +-- config.go | 41 +----------------- examples/create_spool_message.sh | 30 +++++++++++++ examples/scorsh_example.cfg | 29 +++++++++++++ examples/worker1/allowed_users.asc | 62 ++++++++++++++++++++++++++ examples/worker1/allowed_users.pgp | Bin 0 -> 3073 bytes examples/worker1/worker1.cfg | 24 +++++++++++ examples/worker2/allowed_users.asc | 62 ++++++++++++++++++++++++++ examples/worker2/allowed_users.pgp | Bin 0 -> 3073 bytes examples/worker2/worker2.cfg | 14 ++++++ sandpit/test_parse_message.go | 44 +++++++++++++++++++ sandpit/test_regexp.go | 26 +++++++++++ sandpit/test_worker_cfg.go | 63 +++++++++++++++++++++++++++ scorsh.cfg | 48 +++++++-------------- scorsh.go | 39 ++++++++++++++--- spooler.go | 42 ++++++++++++------ types.go | 86 +++++++++++++++++++++++++++++++------ workers.go | 46 ++++++++++++-------- 18 files changed, 537 insertions(+), 125 deletions(-) create mode 100755 examples/create_spool_message.sh create mode 100644 examples/scorsh_example.cfg create mode 100644 examples/worker1/allowed_users.asc create mode 100644 examples/worker1/allowed_users.pgp create mode 100644 examples/worker1/worker1.cfg create mode 100644 examples/worker2/allowed_users.asc create mode 100644 examples/worker2/allowed_users.pgp create mode 100644 examples/worker2/worker2.cfg create mode 100644 sandpit/test_parse_message.go create mode 100644 sandpit/test_regexp.go create mode 100644 sandpit/test_worker_cfg.go diff --git a/commits.go b/commits.go index d69cc2b..7703273 100644 --- a/commits.go +++ b/commits.go @@ -53,9 +53,9 @@ func walk_commits(msg SCORSHmsg, w *SCORSHworker) error { fmt.Printf("Inside parse_commits\n") - reponame := msg.repo - old_rev := msg.old_rev - new_rev := msg.new_rev + reponame := msg.Repo + old_rev := msg.Old_rev + new_rev := msg.New_rev repo, err := git.OpenRepository(reponame) if err != nil { diff --git a/config.go b/config.go index 112b158..38ce531 100644 --- a/config.go +++ b/config.go @@ -1,7 +1,6 @@ package main import ( - "bytes" "fmt" "github.com/go-yaml/yaml" "io" @@ -41,7 +40,7 @@ func ReadGlobalConfig(fname string) *SCORSHmaster { } if cfg.LogPrefix != "" { - log.SetPrefix(cfg.LogPrefix) + log.SetPrefix(cfg.LogPrefix+ " ") } // If the user has not set a spooldir, crash loudly @@ -54,46 +53,10 @@ func ReadGlobalConfig(fname string) *SCORSHmaster { // Check if the user wants to redirect the logs to a file // If we got so far, then there is some sort of config in cfg + log.Printf("----- Starting SCORSH -----\n") log.Printf("Successfully read config from %s\n", fname) return cfg } -func (cfg *SCORSHmaster) String() string { - - var buff bytes.Buffer - - buff.WriteString("spooldir: ") - buff.WriteString(cfg.Spooldir) - buff.WriteString("\nlogfile: ") - buff.WriteString(cfg.Logfile) - buff.WriteString("\nlogprefix: ") - buff.WriteString(cfg.LogPrefix) - buff.WriteString("\nWorkers: \n") - - for _, w := range cfg.Workers { - buff.WriteString("---\n name: ") - buff.WriteString(w.Name) - buff.WriteString("\n repos: ") - for _, r := range w.Repos { - buff.WriteString("\n ") - buff.WriteString(r) - } - buff.WriteString("\n folder: ") - buff.WriteString(w.Folder) - buff.WriteString("\n logfile: ") - buff.WriteString(w.Logfile) - buff.WriteString("\n tagfile: ") - buff.WriteString(w.Tagfile) - buff.WriteString("\n keyrings: ") - for _, k := range w.Keyrings { - buff.WriteString("\n ") - buff.WriteString(k) - } - buff.WriteString("\n...\n") - - } - - return buff.String() -} diff --git a/examples/create_spool_message.sh b/examples/create_spool_message.sh new file mode 100755 index 0000000..22c5839 --- /dev/null +++ b/examples/create_spool_message.sh @@ -0,0 +1,30 @@ +#!/bin/sh + + + +##function +write_message(){ + + orev=${3:-"a1b2c3d4e5f6"} + nrev=${4:-"9a8b7c6d5e4f"} + + + cat < [ [