mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-06-25 00:30:47 +00:00
add platform field and selector capabilities
This commit is contained in:
parent
6f44450ef8
commit
584ec88b07
|
@ -57,12 +57,6 @@ var AgentCmd = cli.Command{
|
||||||
Usage: "docker architecture system",
|
Usage: "docker architecture system",
|
||||||
Value: "amd64",
|
Value: "amd64",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
|
||||||
EnvVar: "DRONE_STORAGE_DRIVER",
|
|
||||||
Name: "drone-storage-driver",
|
|
||||||
Usage: "docker storage driver",
|
|
||||||
Value: "overlay",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
EnvVar: "DRONE_SERVER",
|
EnvVar: "DRONE_SERVER",
|
||||||
Name: "drone-server",
|
Name: "drone-server",
|
||||||
|
@ -102,6 +96,11 @@ var AgentCmd = cli.Command{
|
||||||
Usage: "drone timeout due to log inactivity",
|
Usage: "drone timeout due to log inactivity",
|
||||||
Value: time.Minute * 5,
|
Value: time.Minute * 5,
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
EnvVar: "DRONE_FILTER",
|
||||||
|
Name: "filter",
|
||||||
|
Usage: "filter jobs processed by this agent",
|
||||||
|
},
|
||||||
cli.IntFlag{
|
cli.IntFlag{
|
||||||
EnvVar: "DRONE_MAX_LOGS",
|
EnvVar: "DRONE_MAX_LOGS",
|
||||||
Name: "max-log-size",
|
Name: "max-log-size",
|
||||||
|
@ -219,15 +218,20 @@ func start(c *cli.Context) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// subscribe to the pending build queue.
|
opts = []stomp.MessageOption{
|
||||||
client.Subscribe("/queue/pending", stomp.HandlerFunc(func(m *stomp.Message) {
|
|
||||||
go handler(m) // HACK until we a channel based Subscribe implementation
|
|
||||||
}),
|
|
||||||
stomp.WithAck("client"),
|
stomp.WithAck("client"),
|
||||||
stomp.WithPrefetch(
|
stomp.WithPrefetch(
|
||||||
c.Int("docker-max-procs"),
|
c.Int("docker-max-procs"),
|
||||||
),
|
),
|
||||||
)
|
}
|
||||||
|
if filter := c.String("filter"); filter != "" {
|
||||||
|
opts = append(opts, stomp.WithSelector(filter))
|
||||||
|
}
|
||||||
|
|
||||||
|
// subscribe to the pending build queue.
|
||||||
|
client.Subscribe("/queue/pending", stomp.HandlerFunc(func(m *stomp.Message) {
|
||||||
|
go handler(m) // HACK until we a channel based Subscribe implementation
|
||||||
|
}), opts...)
|
||||||
|
|
||||||
logrus.Infof("Server connection establish, ready to process builds.")
|
logrus.Infof("Server connection establish, ready to process builds.")
|
||||||
<-client.Done()
|
<-client.Done()
|
||||||
|
|
|
@ -351,7 +351,15 @@ func PostBuild(c *gin.Context) {
|
||||||
Yaml: string(raw),
|
Yaml: string(raw),
|
||||||
Secrets: secs,
|
Secrets: secs,
|
||||||
System: &model.System{Link: httputil.GetURL(c.Request)},
|
System: &model.System{Link: httputil.GetURL(c.Request)},
|
||||||
}, stomp.WithHeaders(yaml.ParseLabel(raw)))
|
},
|
||||||
|
stomp.WithHeader(
|
||||||
|
"platform",
|
||||||
|
yaml.ParsePlatformDefault(raw, "linux/amd64"),
|
||||||
|
),
|
||||||
|
stomp.WithHeaders(
|
||||||
|
yaml.ParseLabel(raw),
|
||||||
|
),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -237,7 +237,15 @@ func PostHook(c *gin.Context) {
|
||||||
Yaml: string(raw),
|
Yaml: string(raw),
|
||||||
Secrets: secs,
|
Secrets: secs,
|
||||||
System: &model.System{Link: httputil.GetURL(c.Request)},
|
System: &model.System{Link: httputil.GetURL(c.Request)},
|
||||||
}, stomp.WithHeaders(yaml.ParseLabel(raw)))
|
},
|
||||||
|
stomp.WithHeader(
|
||||||
|
"platform",
|
||||||
|
yaml.ParsePlatformDefault(raw, "linux/amd64"),
|
||||||
|
),
|
||||||
|
stomp.WithHeaders(
|
||||||
|
yaml.ParseLabel(raw),
|
||||||
|
),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
26
yaml/platform.go
Normal file
26
yaml/platform.go
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
package yaml
|
||||||
|
|
||||||
|
import "gopkg.in/yaml.v2"
|
||||||
|
|
||||||
|
// ParsePlatform parses the platform section of the Yaml document.
|
||||||
|
func ParsePlatform(in []byte) string {
|
||||||
|
out := struct {
|
||||||
|
Platform string `yaml:"platform"`
|
||||||
|
}{}
|
||||||
|
|
||||||
|
yaml.Unmarshal(in, &out)
|
||||||
|
return out.Platform
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParsePlatformString parses the platform section of the Yaml document.
|
||||||
|
func ParsePlatformString(in string) string {
|
||||||
|
return ParsePlatform([]byte(in))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParsePlatformDefault parses the platform section of the Yaml document.
|
||||||
|
func ParsePlatformDefault(in []byte, platform string) string {
|
||||||
|
if p := ParsePlatform([]byte(in)); p != "" {
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
return platform
|
||||||
|
}
|
Loading…
Reference in a new issue