diff options
author | KatolaZ <katolaz@freaknet.org> | 2017-08-07 16:22:14 +0100 |
---|---|---|
committer | KatolaZ <katolaz@freaknet.org> | 2017-08-07 16:22:14 +0100 |
commit | 9d60b3d95d49c1097ceeb641f857fe724c4d9cab (patch) | |
tree | 15442dc35e0a60b0210347c2943465f96315fd97 /types.go | |
parent | 200e2f0328b6cfc6965d5399d7750df19eec6144 (diff) |
fixed -- correct execution order of scorsh commands
Diffstat (limited to 'types.go')
-rw-r--r-- | types.go | 38 |
1 files changed, 38 insertions, 0 deletions
@@ -4,6 +4,7 @@ import ( "bytes" "fmt" "golang.org/x/crypto/openpgp" + "os" ) // error constants @@ -39,6 +40,16 @@ type commandCfg struct { Actions []action `yaml:"c_actions"` } +type commandState struct { + Env []string + Args []string +} + +type command struct { + commandCfg + commandState +} + // workerCfg represents the static configuration of a worker type workerCfg struct { Name string `yaml:"w_name"` @@ -157,3 +168,30 @@ func (msg *clientMsg) String() string { return buff.String() } + +func (cmd *command) setEnvironment(msg *spoolMsg, commitID, author, committer string) { + + env := os.Environ() + env = append(env, fmt.Sprintf("SCORSH_REPO=%s", msg.Repo)) + env = append(env, fmt.Sprintf("SCORSH_BRANCH=%s", msg.Branch)) + env = append(env, fmt.Sprintf("SCORSH_OLDREV=%s", msg.OldRev)) + env = append(env, fmt.Sprintf("SCORSH_NEWREV=%s", msg.NewRev)) + env = append(env, fmt.Sprintf("SCORSH_ID=%s", msg.ID)) + env = append(env, fmt.Sprintf("SCORSH_COMMIT=%s", commitID)) + env = append(env, fmt.Sprintf("SCORSH_COMMAND=%s", cmd.Name)) + env = append(env, fmt.Sprintf("SCORSH_AUTHOR=%s", author)) + env = append(env, fmt.Sprintf("SCORSH_COMMITTER=%s", committer)) + cmd.Env = env +} + +func (cmd *command) String() string { + + var buff bytes.Buffer + + fmt.Fprintf(&buff, "Name: %s\n", cmd.Name) + fmt.Fprintf(&buff, "Keyrings: %s\n", cmd.Keyrings) + fmt.Fprintf(&buff, "Actions: %s\n", cmd.Actions) + fmt.Fprintf(&buff, "Env: %s\n", cmd.Env) + fmt.Fprintf(&buff, "Args: %s\n", cmd.Args) + return buff.String() +} |