This commit is contained in:
6543 2024-03-26 11:18:26 +01:00
parent 43ada66dde
commit 44e026e843
3 changed files with 23 additions and 2 deletions

View file

@ -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 {

View file

@ -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
}

View file

@ -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 {