mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-09-24 12:40:06 +00:00
wip
This commit is contained in:
parent
43ada66dde
commit
44e026e843
3 changed files with 23 additions and 2 deletions
|
@ -187,7 +187,6 @@ func run(c *cli.Context, backends []types.Backend) error {
|
|||
"hostname": hostname,
|
||||
"platform": engInfo.Platform,
|
||||
"backend": backendEngine.Name(),
|
||||
"repo": "*", // allow all repos by default
|
||||
}
|
||||
|
||||
if err := stringSliceAddToMap(c.StringSlice("filter"), labels); err != nil {
|
||||
|
|
|
@ -39,3 +39,20 @@ func (Agent) TableName() string {
|
|||
func (a *Agent) IsSystemAgent() bool {
|
||||
return a.OwnerID == -1
|
||||
}
|
||||
|
||||
func (a *Agent) GetFilters() map[string]string {
|
||||
filters := a.Filters
|
||||
if filters == nil {
|
||||
filters = make(map[string]string)
|
||||
}
|
||||
|
||||
// enforce filters for user and organization agents
|
||||
if a.IsSystemAgent() {
|
||||
filters["repo"] = "*" // allow all repos by default
|
||||
filters["owner"] = "*" // allow all owners by default
|
||||
} else {
|
||||
filters["owner"] = "*" // we dont have org agents implemented jet
|
||||
}
|
||||
|
||||
return filters
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ func queuePipeline(ctx context.Context, repo *model.Repo, pipelineItems []*stepb
|
|||
for k, v := range item.Labels {
|
||||
task.Labels[k] = v
|
||||
}
|
||||
task.Labels["repo"] = repo.FullName
|
||||
enforcedLabels(task, repo)
|
||||
task.Dependencies = taskIDs(item.DependsOn, pipelineItems)
|
||||
task.RunOn = item.RunsOn
|
||||
task.DepStatus = make(map[string]model.StatusValue)
|
||||
|
@ -57,6 +57,11 @@ func queuePipeline(ctx context.Context, repo *model.Repo, pipelineItems []*stepb
|
|||
return server.Config.Services.Queue.PushAtOnce(ctx, tasks)
|
||||
}
|
||||
|
||||
func enforcedLabels(task *model.Task, repo *model.Repo) {
|
||||
task.Labels["repo"] = repo.FullName
|
||||
task.Labels["owner"] = repo.Owner
|
||||
}
|
||||
|
||||
func taskIDs(dependsOn []string, pipelineItems []*stepbuilder.Item) (taskIDs []string) {
|
||||
for _, dep := range dependsOn {
|
||||
for _, pipelineItem := range pipelineItems {
|
||||
|
|
Loading…
Reference in a new issue