summaryrefslogtreecommitdiff
path: root/types.go
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2017-07-15 01:26:39 +0100
committerKatolaZ <katolaz@freaknet.org>2017-07-15 01:26:39 +0100
commit726b399e4747032a3d052339cd62c57ae5b6767c (patch)
treeaac8350e83bb13e9628dd287ca3aae97ecafcb32 /types.go
parented637037b75cb5dfe1b49e776956fa6ab3632b68 (diff)
pipeline from spool to worker is done -- added examples
Diffstat (limited to 'types.go')
-rw-r--r--types.go86
1 files changed, 73 insertions, 13 deletions
diff --git a/types.go b/types.go
index 3ccb6cc..6b5a384 100644
--- a/types.go
+++ b/types.go
@@ -1,6 +1,7 @@
package main
import (
+ "bytes"
"golang.org/x/crypto/openpgp"
)
@@ -15,11 +16,11 @@ const (
// the SCORSHmsg type represents messages received from the spool and
// sent to workers
type SCORSHmsg struct {
- name string
- repo string
- branch string
- old_rev string
- new_rev string
+ Name string `yaml:"m_id"`
+ Repo string `yaml:"m_repo"`
+ Branch string `yaml:"m_branch"`
+ Old_rev string `yaml:"m_oldrev"`
+ New_rev string `yaml:"m_newrev"`
}
type SCORSHcmd struct {
@@ -35,17 +36,17 @@ type SCORSHtag struct {
// Configuration of a worker
type SCORSHworker_cfg struct {
- Name string `yaml:"w_name"`
- Repos []string `yaml:"w_repos"`
- Folder string `yaml:"w_folder"`
- Logfile string `yaml:"w_logfile"`
- Tagfile string `yaml:"w_tagfile"`
- Keyrings []string `yaml:"w_keyrings"`
+ Name string `yaml:"w_name"`
+ Repos []string `yaml:"w_repos"`
+ Folder string `yaml:"w_folder"`
+ Logfile string `yaml:"w_logfile"`
+ Tagfile string `yaml:"w_tagfile"`
+ Keyrings []string `yaml:"w_keyrings"`
+ Tags []SCORSHtag `yaml:"w_tags"`
}
// State of a worker
type SCORSHworker_state struct {
- Tags []SCORSHtag `yaml:"w_tags"`
Keys map[string]openpgp.KeyRing
MsgChan chan SCORSHmsg
StatusChan chan SCORSHmsg
@@ -55,7 +56,7 @@ type SCORSHworker_state struct {
// worker
type SCORSHworker struct {
SCORSHworker_cfg `yaml:",inline"`
- SCORSHworker_state `yaml:",inline"`
+ SCORSHworker_state
}
// Configuration of the master
@@ -80,3 +81,62 @@ type SCORSHmaster struct {
SCORSHmaster_cfg `yaml:",inline"`
SCORSHmaster_state
}
+
+
+
+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()
+}
+
+
+func (msg *SCORSHmsg) String() string {
+
+ var buff bytes.Buffer
+ buff.WriteString("\nName: ")
+ buff.WriteString(msg.Name)
+ buff.WriteString("\nRepo: ")
+ buff.WriteString(msg.Repo)
+ buff.WriteString("\nBranch: ")
+ buff.WriteString(msg.Branch)
+ buff.WriteString("\nOld_rev: ")
+ buff.WriteString(msg.Old_rev)
+ buff.WriteString("\nNew_rev: ")
+ buff.WriteString(msg.New_rev)
+ return buff.String()
+
+}
+