---
id: w1/m18/t001
title: Add RootDir to AppSpec CRD + codegen
worker: worker1
status: done
estimate: 30m
depends_on: []
---

## Objective

Add the `RootDir` field to the `App` CRD's spec so a monorepo repo can name the subdirectory the operator should build/deploy from, and regenerate the deepcopy + CRD YAML that the field requires.

## Context

- `lego/types/v1alpha1/app_types.go` — `AppSpec` already carries `Repo`, `Branch`, `Builder`, `Image` (build-from-git fields, roughly lines 73-92).
- CRD/deepcopy codegen is driven from `lego/operator/` (`make manifests generate`), reading markers from `../types/...`; both `zz_generated.deepcopy.go` and `config/crd/bases/*.yaml` are generated — never hand-edit them.
- `docs/ADR004-deployment.md:157` already documents the gap this field closes.

## Steps

1. Add `RootDir string` to `AppSpec` with `+optional` doc comment explaining it selects the build subdirectory (default = repo root); model the doc comment style on the existing `Repo`/`Branch` fields.
2. From `lego/operator/`, run `make manifests generate` to regenerate deepcopy + CRD YAML.
3. Confirm the new field appears in `config/crd/bases/` and `zz_generated.deepcopy.go` with no unrelated diff.

## Files

- `lego/types/v1alpha1/app_types.go`
- `lego/types/v1alpha1/zz_generated.deepcopy.go` (generated)
- `lego/operator/config/crd/bases/*.yaml` (generated)

## Acceptance criteria

- [x] `AppSpec.RootDir` exists, optional, empty-string default (repo root)
- [x] `make manifests generate` run from `lego/operator/` produces a clean regeneration (no manual edits to generated files)
- [x] `go build ./...` succeeds in both `lego/types/` and `lego/operator/`

## Out of scope

- Threading the field into the build engine, controller, webhook, or API surfaces (t002-t005).
