mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-02-17 03:45:13 +00:00
Supporting multiple yamls in procBuilder
This commit is contained in:
parent
8199fe4a21
commit
c9f2346c2c
4 changed files with 113 additions and 124 deletions
|
@ -323,7 +323,7 @@ func PostApproval(c *gin.Context) {
|
||||||
Secs: secs,
|
Secs: secs,
|
||||||
Regs: regs,
|
Regs: regs,
|
||||||
Link: httputil.GetURL(c.Request),
|
Link: httputil.GetURL(c.Request),
|
||||||
Yaml: conf.Data,
|
Yamls: []string{conf.Data},
|
||||||
Envs: envs,
|
Envs: envs,
|
||||||
}
|
}
|
||||||
buildItems, err := b.Build()
|
buildItems, err := b.Build()
|
||||||
|
@ -512,7 +512,7 @@ func PostBuild(c *gin.Context) {
|
||||||
Secs: secs,
|
Secs: secs,
|
||||||
Regs: regs,
|
Regs: regs,
|
||||||
Link: httputil.GetURL(c.Request),
|
Link: httputil.GetURL(c.Request),
|
||||||
Yaml: conf.Data,
|
Yamls: []string{conf.Data},
|
||||||
Envs: buildParams,
|
Envs: buildParams,
|
||||||
}
|
}
|
||||||
buildItems, err := b.Build()
|
buildItems, err := b.Build()
|
||||||
|
|
|
@ -235,7 +235,7 @@ func PostHook(c *gin.Context) {
|
||||||
Regs: regs,
|
Regs: regs,
|
||||||
Envs: envs,
|
Envs: envs,
|
||||||
Link: httputil.GetURL(c.Request),
|
Link: httputil.GetURL(c.Request),
|
||||||
Yaml: conf.Data,
|
Yamls: []string{conf.Data},
|
||||||
}
|
}
|
||||||
buildItems, err := b.Build()
|
buildItems, err := b.Build()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -32,11 +32,12 @@ bbb`,
|
||||||
Secs: []*model.Secret{},
|
Secs: []*model.Secret{},
|
||||||
Regs: []*model.Registry{},
|
Regs: []*model.Registry{},
|
||||||
Link: "",
|
Link: "",
|
||||||
Yaml: `pipeline:
|
Yamls: []string{`pipeline:
|
||||||
xxx:
|
xxx:
|
||||||
image: scratch
|
image: scratch
|
||||||
yyy: ${DRONE_COMMIT_MESSAGE}
|
yyy: ${DRONE_COMMIT_MESSAGE}
|
||||||
`,
|
`,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := b.Build(); err != nil {
|
if _, err := b.Build(); err != nil {
|
||||||
|
|
|
@ -39,7 +39,7 @@ type procBuilder struct {
|
||||||
Secs []*model.Secret
|
Secs []*model.Secret
|
||||||
Regs []*model.Registry
|
Regs []*model.Registry
|
||||||
Link string
|
Link string
|
||||||
Yaml string
|
Yamls []string
|
||||||
Envs map[string]string
|
Envs map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,8 +51,10 @@ type buildItem struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *procBuilder) Build() ([]*buildItem, error) {
|
func (b *procBuilder) Build() ([]*buildItem, error) {
|
||||||
|
var items []*buildItem
|
||||||
|
|
||||||
axes, err := matrix.ParseString(b.Yaml)
|
for _, y := range b.Yamls {
|
||||||
|
axes, err := matrix.ParseString(y)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -60,7 +62,6 @@ func (b *procBuilder) Build() ([]*buildItem, error) {
|
||||||
axes = append(axes, matrix.Axis{})
|
axes = append(axes, matrix.Axis{})
|
||||||
}
|
}
|
||||||
|
|
||||||
var items []*buildItem
|
|
||||||
for i, axis := range axes {
|
for i, axis := range axes {
|
||||||
proc := &model.Proc{
|
proc := &model.Proc{
|
||||||
BuildID: b.Curr.ID,
|
BuildID: b.Curr.ID,
|
||||||
|
@ -91,7 +92,6 @@ func (b *procBuilder) Build() ([]*buildItem, error) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
y := b.Yaml
|
|
||||||
s, err := envsubst.Eval(y, func(name string) string {
|
s, err := envsubst.Eval(y, func(name string) string {
|
||||||
env := environ[name]
|
env := environ[name]
|
||||||
if strings.Contains(env, "\n") {
|
if strings.Contains(env, "\n") {
|
||||||
|
@ -161,19 +161,6 @@ func (b *procBuilder) Build() ([]*buildItem, error) {
|
||||||
compiler.WithMetadata(metadata),
|
compiler.WithMetadata(metadata),
|
||||||
).Compile(parsed)
|
).Compile(parsed)
|
||||||
|
|
||||||
// for _, sec := range b.Secs {
|
|
||||||
// if !sec.MatchEvent(b.Curr.Event) {
|
|
||||||
// continue
|
|
||||||
// }
|
|
||||||
// if b.Curr.Verified || sec.SkipVerify {
|
|
||||||
// ir.Secrets = append(ir.Secrets, &backend.Secret{
|
|
||||||
// Mask: sec.Conceal,
|
|
||||||
// Name: sec.Name,
|
|
||||||
// Value: sec.Value,
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
item := &buildItem{
|
item := &buildItem{
|
||||||
Proc: proc,
|
Proc: proc,
|
||||||
Config: ir,
|
Config: ir,
|
||||||
|
@ -185,6 +172,7 @@ func (b *procBuilder) Build() ([]*buildItem, error) {
|
||||||
}
|
}
|
||||||
items = append(items, item)
|
items = append(items, item)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return items, nil
|
return items, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue