File tree Expand file tree Collapse file tree 8 files changed +100
-10
lines changed Expand file tree Collapse file tree 8 files changed +100
-10
lines changed Original file line number Diff line number Diff line change @@ -8,9 +8,29 @@ temp "Tempfile" {
8
8
}
9
9
}
10
10
11
+ git "dev" {
12
+ add_type = " u"
13
+ commit = " "
14
+ }
15
+
16
+ docker {
17
+ repo = " deoops/dotam"
18
+ tag = " {{versions.prod}}"
19
+ username = " $reg_passwd"
20
+ passpord = " $reg_passwd"
21
+ }
22
+
11
23
var "data" {
12
24
temp = << TEMP
13
25
abc
14
26
bcd
15
27
TEMP
28
+ }
29
+
30
+ arg "reg_user" {
31
+ type = " string"
32
+ }
33
+
34
+ arg "reg_passwd" {
35
+ type = " string"
16
36
}
Original file line number Diff line number Diff line change 9
9
* 模板插件完整支持
10
10
* cli基本命令支持` build, init `
11
11
* plugin完整支持
12
+ * 完善文档
12
13
13
14
** todos:**
14
15
18
19
- [x] yaml
19
20
- [x] hcl
20
21
- [ ] !! init命令
22
+ - [ ] !! 文档
23
+ - [ ] template syntax
24
+ - [ ] en
25
+ - [ ] zh
21
26
- [ ] ! 自举
22
27
- [ ] ! git 插件
23
28
- [ ] ! docker 插件
24
29
- [ ] ! refactor code
30
+ - [ ] !! build args
25
31
26
32
----
27
33
28
34
## V 2.0.0
35
+
36
+ ** 目标:**
37
+
38
+ * 兼容drone
Original file line number Diff line number Diff line change 1
- abcd
2
- {{#success build.status}}
1
+ abc
2
+ bcd
3
+
4
+
5
+ {{#success build.status}}
6
+
7
+
8
+ abc
Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ func (r RunCmd) Run(args []string) (extCode int) {
30
30
var err error
31
31
var dotamFile string
32
32
var renderData pongo2.Context
33
+ var buildArgs []string
34
+ log .WithFields (log.Fields {"BUILD" : "ARGS" }).Debug (args )
33
35
34
36
defer func () {
35
37
if err != nil {
@@ -48,7 +50,17 @@ func (r RunCmd) Run(args []string) (extCode int) {
48
50
}
49
51
dotamFile = Abs (defaultConf )
50
52
} else {
51
- dotamFile = Abs (args [0 ])
53
+ dotamFile , buildArgs = ParseBuildArgs (args )
54
+ if dotamFile == "" {
55
+ if ! exist {
56
+ err = errors .New ("you need at least a conf file, pls see help doc" )
57
+ return
58
+ } else {
59
+ dotamFile = defaultConf
60
+ }
61
+ }
62
+ log .WithFields (log.Fields {"BUILD" : "PARSED ARGS" }).Debug (buildArgs )
63
+
52
64
}
53
65
54
66
data := ReadFile (dotamFile )
@@ -61,23 +73,20 @@ func (r RunCmd) Run(args []string) (extCode int) {
61
73
if config .Var != nil {
62
74
renderData = VarToTplContext (config .Var )
63
75
}
64
- log .Debug ("ooo" )
65
76
log .Debug (renderData )
66
- log .Debug ("******" )
67
77
68
78
newDotamSrc , err := Render (string (data ), renderData )
69
79
if err != nil {
70
80
// log.Error(err)
71
81
return - 1
72
82
}
73
- log . Debug ( "!!!!" )
83
+
74
84
log .Debug (newDotamSrc )
75
85
76
86
newConfig := DotamConf {}
77
87
if err = parseConf (& newConfig , newDotamSrc , dotamFile ); err != nil {
78
88
return
79
89
}
80
- log .Debug ("00000" )
81
90
log .Debug (newConfig )
82
91
83
92
if err = RunTasks (newConfig ); err != nil {
Original file line number Diff line number Diff line change 1
1
{{data}}
2
- {{ "{{#success build.status}}"|safe }}
2
+ {{ "{{#success build.status}}"|safe }}
3
+ {# foothing{{#abc}} #}
4
+ {% comment %}
5
+ foo
6
+ {% endcomment%}
7
+ abc
Original file line number Diff line number Diff line change @@ -29,7 +29,6 @@ func TestExist(t *testing.T) {
29
29
results := []bool {}
30
30
31
31
for _ , f := range files {
32
- t .Log (Exist (f ))
33
32
results = append (results , Exist (f ))
34
33
}
35
34
if ! reflect .DeepEqual (expects , results ) {
@@ -46,6 +45,32 @@ func TestParseYaml(t *testing.T) {
46
45
fmt .Println (err )
47
46
t .Fail ()
48
47
}
49
- fmt .Println (c )
50
48
51
49
}
50
+
51
+ func TestParseArgs (t * testing.T ) {
52
+ data := []string {"Dotamfile.hcl" , "reg_user=tom" , "reg_pass=foo" }
53
+ data2 := []string {"reg_user=tom" , "foo=bar" }
54
+
55
+ f , a := ParseBuildArgs (data )
56
+ if ! reflect .DeepEqual ([]string {"reg_user=tom" , "reg_pass=foo" }, a ) {
57
+ t .Log (a )
58
+ t .Fail ()
59
+ }
60
+
61
+ if f != "Dotamfile.hcl" {
62
+ t .Log (f )
63
+ t .Fail ()
64
+ }
65
+
66
+ f2 , a2 := ParseBuildArgs (data2 )
67
+ if ! reflect .DeepEqual ([]string {"reg_user=tom" , "foo=bar" }, a2 ) {
68
+ t .Log (a2 )
69
+ t .Fail ()
70
+ }
71
+
72
+ if f2 != "" {
73
+ t .Log (f2 )
74
+ t .Fail ()
75
+ }
76
+ }
Original file line number Diff line number Diff line change 4
4
"fmt"
5
5
"io/ioutil"
6
6
"os"
7
+ "strings"
7
8
8
9
"github.com/flosch/pongo2"
9
10
log "github.com/sirupsen/logrus"
@@ -108,3 +109,17 @@ func Exist(path string) bool {
108
109
}
109
110
110
111
}
112
+
113
+ func ParseBuildArgs (src []string ) (dotamFile string , dest []string ) {
114
+
115
+ str := strings .Join (src , " " )
116
+ for _ , d := range DEFAULT_DOTAMFILES {
117
+ if strings .Contains (str , d ) {
118
+ dotamFile = d
119
+ }
120
+ str = strings .Replace (str , d , "" , - 1 )
121
+ str = strings .TrimSpace (str )
122
+ }
123
+ dest = strings .Split (str , " " )
124
+ return
125
+ }
You can’t perform that action at this time.
0 commit comments