completed refactoring from tags to commands

devel 0.3
KatolaZ 8 years ago
parent b31fe15e0d
commit 200e2f0328
  1. 5
      commits.go
  2. 15
      examples/worker1/worker1.cfg
  3. 12
      examples/worker2/worker2.cfg
  4. 6
      scorsh.sh
  5. 6
      types.go

@ -176,7 +176,12 @@ func walkCommits(msg spoolMsg, w *worker) error {
// 2) then for each command in the message // 2) then for each command in the message
for _, c := range cmdMsg.Commands { for _, c := range cmdMsg.Commands {
if c.Cmd == "" {
log.Printf("[worker: %s] empty command\n", w.Name)
continue
}
// a) check that the command is among those accepted by the worker // a) check that the command is among those accepted by the worker
debug.log("[worker: %s] validating command: %s\n", w.Name, c.Cmd)
cmdCfg, goodCmd := findCmdConfig(c.Cmd, w) cmdCfg, goodCmd := findCmdConfig(c.Cmd, w)
debug.log("[worker: %s] goodCmd: %s\n", w.Name, goodCmd) debug.log("[worker: %s] goodCmd: %s\n", w.Name, goodCmd)

@ -11,9 +11,9 @@
w_commands: w_commands:
[ [
{ {
t_name: "LOG", c_name: "LOG",
t_keyrings: ["allowed_users.asc"], c_keyrings: ["allowed_users.asc"],
t_actions: [ c_actions: [
{ {
a_url: "file:///home/katolaz/bin/scorsh_script.sh" a_url: "file:///home/katolaz/bin/scorsh_script.sh"
## a_hash: "12da324fb76s924acbce" ## a_hash: "12da324fb76s924acbce"
@ -21,11 +21,12 @@ w_commands:
] ]
}, },
{ {
t_name: "build", c_name: "build",
t_keyrings: ["allowed_users.asc"], c_keyrings: ["allowed_users.asc"],
t_actions: [ c_actions: [
{ {
a_url: "file:///home/katolaz/bin/scorsh_script.sh" a_url: "file:///home/katolaz/bin/scorsh_script.sh",
a_hash: "aa606bc152824c1b650d7e71e2e92bb69a9b7c861c69cd439d17902488e5f76e"
} }
] ]
} }

@ -2,18 +2,18 @@
w_commands: w_commands:
[ [
{ {
t_name: "DEPLOY", c_name: "DEPLOY",
t_keyrings: ["allowed_users.asc"], c_keyrings: ["allowed_users.asc"],
t_actions: [ c_actions: [
{ {
a_url: "file:///home/katolaz/bin/deploy.sh" a_url: "file:///home/katolaz/bin/deploy.sh"
} }
] ]
}, },
{ {
t_name: "build", c_name: "build",
t_keyrings: ["allowed_users.asc"], c_keyrings: ["allowed_users.asc"],
t_actions: [ c_actions: [
{ {
a_url: "file:///home/katolaz/bin/scorsh_build.sh" a_url: "file:///home/katolaz/bin/scorsh_build.sh"
} }

@ -7,7 +7,7 @@
## func ## func
build_command(){ build_command(){
TAG=$1 CMD=$1
shift shift
ARGS=$@ ARGS=$@
@ -22,7 +22,7 @@ build_command(){
scorsh: scorsh:
[ [
{ {
s_tag: "$TAG", s_cmd: "$CMD",
s_args: [${ARGLIST}] s_args: [${ARGLIST}]
} }
] ]
@ -34,7 +34,7 @@ EOF
if [ $# -le 0 ]; then if [ $# -le 0 ]; then
echo "Usage: $0 <tag> [<arg>...]" echo "Usage: $0 <cmd> [<arg>...]"
exit 1 exit 1
fi fi

@ -34,9 +34,9 @@ type action struct {
// commandCfg represents a command configured on the server side // commandCfg represents a command configured on the server side
type commandCfg struct { type commandCfg struct {
Name string `yaml:"t_name"` Name string `yaml:"c_name"`
Keyrings []string `yaml:"t_keyrings"` Keyrings []string `yaml:"c_keyrings"`
Actions []action `yaml:"t_actions"` Actions []action `yaml:"c_actions"`
} }
// workerCfg represents the static configuration of a worker // workerCfg represents the static configuration of a worker

Loading…
Cancel
Save