|
|
|
@ -4,6 +4,7 @@ import ( |
|
|
|
|
"fmt" |
|
|
|
|
"github.com/go-yaml/yaml" |
|
|
|
|
"log" |
|
|
|
|
"strings" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
type STag struct { |
|
|
|
@ -31,18 +32,25 @@ type SCORSHcfg struct { |
|
|
|
|
|
|
|
|
|
var msg_str = ` |
|
|
|
|
s_msg: |
|
|
|
|
- s_tag: BUILD |
|
|
|
|
s_args:
|
|
|
|
|
- suites/jessie
|
|
|
|
|
- suites/ascii |
|
|
|
|
- s_tag: REMOVE |
|
|
|
|
s_args:
|
|
|
|
|
- file1 |
|
|
|
|
- s_tag: CUSTOM |
|
|
|
|
[ |
|
|
|
|
{ s_tag: BUILD, |
|
|
|
|
s_args: [ suites/jessie, suites/ascii] |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
s_tag: REMOVE, |
|
|
|
|
s_args: [file1] |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
s_tag: CUSTOM, |
|
|
|
|
s_args: [first, second, third] |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|
` |
|
|
|
|
|
|
|
|
|
var other_msg = ` |
|
|
|
|
this is my comment... |
|
|
|
|
|
|
|
|
|
--- |
|
|
|
|
s_msg: [ |
|
|
|
|
{s_tag: "BUILD", s_args: [suites/jessie, suites/ascii]}, |
|
|
|
|
{s_tag: "REMOVE", s_args: [file1]}, |
|
|
|
@ -50,8 +58,9 @@ s_msg: [ |
|
|
|
|
] |
|
|
|
|
` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var cfg_str = ` |
|
|
|
|
some stuff |
|
|
|
|
--- |
|
|
|
|
s_cfg: |
|
|
|
|
- s_tag: BUILD |
|
|
|
|
s_commands: |
|
|
|
@ -69,6 +78,7 @@ s_cfg: |
|
|
|
|
{s_cmd: "file:///home/user/script/sh", s_hash: "1234567890abcdef"},
|
|
|
|
|
{s_cmd: "http://my.server.net/submit.php", s_hash: "0987654321abce"} |
|
|
|
|
] |
|
|
|
|
... |
|
|
|
|
` |
|
|
|
|
|
|
|
|
|
func main() { |
|
|
|
@ -77,9 +87,15 @@ func main() { |
|
|
|
|
|
|
|
|
|
var conf SCORSHcfg |
|
|
|
|
|
|
|
|
|
sep := "\n---\n" |
|
|
|
|
|
|
|
|
|
//log.Printf("%s\n", test_str)
|
|
|
|
|
|
|
|
|
|
err := yaml.Unmarshal([]byte(other_msg), &c) |
|
|
|
|
scorsh_idx := strings.Index(other_msg, sep) |
|
|
|
|
if scorsh_idx >= 0 { |
|
|
|
|
|
|
|
|
|
err := yaml.Unmarshal([]byte(other_msg[scorsh_idx:]), &c) |
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
log.Fatal("error: ", err) |
|
|
|
|
} |
|
|
|
@ -93,10 +109,14 @@ func main() { |
|
|
|
|
fmt.Printf(" %s\n", a) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fmt.Println("----------------------------") |
|
|
|
|
|
|
|
|
|
err = yaml.Unmarshal([]byte(cfg_str), &conf) |
|
|
|
|
scorsh_idx = strings.Index(cfg_str, sep) |
|
|
|
|
if scorsh_idx >= 0 { |
|
|
|
|
|
|
|
|
|
err := yaml.Unmarshal([]byte(cfg_str[scorsh_idx:]), &conf) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Fatal("error: ", err) |
|
|
|
|
} |
|
|
|
@ -114,5 +134,5 @@ func main() { |
|
|
|
|
fmt.Println("-+-+-") |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|