---
id: w1/m18/t003
title: Wire App.spec.rootDir into build.Options at the controller
worker: worker1
status: done
estimate: 30m
depends_on: [w1/m18/t002]
---

## Objective

Make the reconciler pass the App's `spec.rootDir` through to the build engine so a repo-backed App with a subdirectory set actually builds from it end to end.

## Context

- `lego/operator/internal/controller/app_controller.go` constructs `build.Options` from the reconciled `App` CR (currently sets `Repo`/`Branch`/etc. — the exact call site needs confirming by reading the reconcile path that dispatches the BuildKit Job).
- This is the last hop between the CRD field (t001) and the build-engine mechanism (t002).

## Steps

1. Find the `build.Options{...}` construction in `app_controller.go` (or wherever the build Job is dispatched from the reconcile loop).
2. Add `RootDir: a.Spec.RootDir` to that construction.
3. Sanity-check via `make test` (envtest) that a repo-backed App with `spec.rootDir` set dispatches a Job whose BuildKit `context=` arg carries the subdir suffix.

## Files

- `lego/operator/internal/controller/app_controller.go`

## Acceptance criteria

- [x] `build.Options.RootDir` is populated from `a.Spec.RootDir` at the controller call site
- [x] An envtest/unit test asserts the dispatched Job's BuildKit args include the subdir suffix when `spec.rootDir` is set, and omit it when unset
- [x] `make test` from `lego/operator/` is green

## Out of scope

- Live verification against a real monorepo (covered by t009/test coverage and the milestone's overall DoD, not this task alone).
