Skip to content

Commit

Permalink
pull projects needs to use the correct pull config
Browse files Browse the repository at this point in the history
  • Loading branch information
fitz7 committed Apr 16, 2024
1 parent c2b692d commit 44da097
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions pkg/config/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ type Projects []Project

// NewProject returns a new project composed with the default parameters.
func NewProject(name string) (p Project) {

defaults.MustSet(&p)
p.Name = name

Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import (
)

// PullProject ..
func (c *Controller) PullProject(ctx context.Context, name string) error {
func (c *Controller) PullProject(ctx context.Context, name string, pull config.ProjectPull) error {
gp, err := c.Gitlab.GetProject(ctx, name)
if err != nil {
return err
}

p := schemas.NewProject(gp.PathWithNamespace)
p.Pull = pull

projectExists, err := c.Store.ProjectExists(ctx, p.Key())
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ func NewTaskController(ctx context.Context, r *redis.Client, maximumJobsQueueSiz
}

// TaskHandlerPullProject ..
func (c *Controller) TaskHandlerPullProject(ctx context.Context, name string) error {
func (c *Controller) TaskHandlerPullProject(ctx context.Context, name string, pull config.ProjectPull) error {
defer c.unqueueTask(ctx, schemas.TaskTypePullProject, name)

return c.PullProject(ctx, name)
return c.PullProject(ctx, name, pull)
}

// TaskHandlerPullProjectsFromWildcard ..
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/webhooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func (c *Controller) triggerRefMetricsPull(ctx context.Context, ref schemas.Ref)
}

if matches {
c.ScheduleTask(context.TODO(), schemas.TaskTypePullProject, ref.Project.Name, ref.Project.Name)
c.ScheduleTask(context.TODO(), schemas.TaskTypePullProject, ref.Project.Name, ref.Project.Name, w.Pull)
log.WithFields(logFields).Info("project ref not currently exported but its configuration matches a wildcard, triggering a pull of the project")
} else {
log.WithFields(logFields).Debug("project ref not matching wildcard, skipping..")
Expand Down Expand Up @@ -284,7 +284,7 @@ func (c *Controller) triggerEnvironmentMetricsPull(ctx context.Context, env sche
}

if matches {
c.ScheduleTask(context.TODO(), schemas.TaskTypePullProject, env.ProjectName, env.ProjectName)
c.ScheduleTask(context.TODO(), schemas.TaskTypePullProject, env.ProjectName, env.ProjectName, w.Pull)
log.WithFields(logFields).Info("project environment not currently exported but its configuration matches a wildcard, triggering a pull of the project")
} else {
log.WithFields(logFields).Debug("project ref not matching wildcard, skipping..")
Expand Down

0 comments on commit 44da097

Please sign in to comment.