Skip to content

feat(source): add repo source type for AOSP/AAOS manifest-based builds#31

Draft
ambient-code[bot] wants to merge 1 commit into
mainfrom
ambient/session-efbcde36-c4b5-4fbc-a874-7e170ba44cf2
Draft

feat(source): add repo source type for AOSP/AAOS manifest-based builds#31
ambient-code[bot] wants to merge 1 commit into
mainfrom
ambient/session-efbcde36-c4b5-4fbc-a874-7e170ba44cf2

Conversation

@ambient-code
Copy link
Copy Markdown

@ambient-code ambient-code Bot commented May 12, 2026

PR Description

feat(source): add repo source type for AOSP/AAOS manifest-based builds

Fixes #28

Summary

Adds repo as a first-class source type in builder-operator, enabling AOSP,
AAOS, and Cuttlefish target builds via Google's repo tool. Previously, users
had to embed repo init/repo sync inside a build stage, which prevented
operator-managed mirror reuse and re-downloaded 100+ GB of source on every build.

Changes

API types (api/v1alpha1/buildjob_types.go)

  • Added SourceTypeRepo SourceType = "repo" constant
  • Added RepoSource struct: manifestUrl (required), branch, manifestName,
    mirrorRef (PVC name for local mirror), syncJobs (repo sync parallelism)
  • Added Repo *RepoSource field to SourceSpec
  • Updated kubebuilder validation enum from Enum=git;pvc to Enum=git;pvc;repo

Deepcopy (api/v1alpha1/zz_generated.deepcopy.go)

  • Added RepoSource.DeepCopyInto / RepoSource.DeepCopy
  • Updated SourceSpec.DeepCopyInto to handle the new Repo pointer

Pipeline builder (internal/tekton/pipelinerun_builder.go)

  • Added RepoInitImage = "python:3.12-slim" constant
  • Added repo case to the source switch in BuildPipelineRunWithConfig
  • Added buildRepoTaskSpec() — generates a repo-sync Tekton task:
    • Installs repo via pip if not already present
    • Runs repo init -u <url> [-b <branch>] [-m <manifest>]
    • Runs repo sync -j<N> (default 4)
    • When mirrorRef is set: mounts the named PVC read-only at /mnt/mirror
      and passes --reference=/mnt/mirror to repo init
  • Updated buildEnvVars to inject BOB_MANIFEST_URL and BOB_MANIFEST_BRANCH
    when source type is repo

CRD YAML (config/crd/bases/builder.sdv.cloud.redhat.com_buildjobs.yaml)

  • Updated source.type enum: [git, pvc][git, pvc, repo]
  • Added repo object definition with all five fields

Example BuildJob

apiVersion: builder.sdv.cloud.redhat.com/v1alpha1
kind: BuildJob
metadata:
  name: aaos-cuttlefish
spec:
  toolchain:
    image: registry.example.com/aaos-host-tools:android-14
  source:
    type: repo
    repo:
      manifestUrl: https://android.googlesource.com/platform/manifest
      branch: android-14.0.0_r50
      mirrorRef: aosp-mirror
      syncJobs: 16
  target:
    board: cf_x86_64_auto
    variant: userdebug
  stages:
    - name: build
      command: |
        source build/envsetup.sh
        lunch aosp_${BOB_BOARD}-${BOB_VARIANT}
        m -j$(nproc)

Testing

  • 9 new unit tests in internal/tekton/pipelinerun_builder_test.go
  • All 6 test packages pass (go test ./... -race)
  • go build ./... and go vet ./... pass

New tests

Test Covers
TestBuildPipelineRun_RepoSourceTask Basic task generation, image, script content
TestBuildPipelineRun_RepoSourceDefaultSyncJobs Default syncJobs=4
TestBuildPipelineRun_RepoSourceMirrorMount Mirror PVC volume+mount+--reference=
TestBuildPipelineRun_RepoSourceNoMirrorMount No volumes when no mirrorRef
TestBuildPipelineRun_RepoSourceEnvVars BOB_MANIFEST_URL/BRANCH injection
TestBuildPipelineRun_RepoSourceRunAfterChaining Task ordering
TestBuildPipelineRun_RepoSourceManifestName -m flag for manifestName
TestBuildPipelineRun_RepoSourceNoPipelineResult No commit-sha result
TestBuildPipelineRun_RepoSourceRepoNilSkipsTask Nil Repo spec guard

Breaking Changes

None. The Repo field is optional (omitempty). Existing git and pvc
BuildJobs are unaffected.

Reviewer Notes

  • make manifests and make generate are no-ops in this project — both the
    CRD YAML and zz_generated.deepcopy.go are maintained manually. The CRD
    YAML has been updated by hand to match the new type.
  • RepoInitImage = "python:3.12-slim" with runtime pip install repo works
    in connected clusters. An air-gapped follow-up (configurable image field or
    pre-baked image) is tracked separately.

Adds repo as a first-class source type enabling AOSP/AAOS and Cuttlefish
target builds via Google's repo tool. Previously, users had to embed
repo init/repo sync inside a build stage, which prevented operator-managed
mirror reuse and re-downloaded 100+ GB of source on every build.

Changes:
- api/v1alpha1/buildjob_types.go: add SourceTypeRepo constant, RepoSource
  struct (manifestUrl, branch, manifestName, mirrorRef, syncJobs), Repo field
  in SourceSpec, update kubebuilder enum to Enum=git;pvc;repo
- api/v1alpha1/zz_generated.deepcopy.go: add RepoSource deepcopy methods,
  update SourceSpec.DeepCopyInto to handle Repo pointer
- internal/tekton/pipelinerun_builder.go: add repo case in source switch,
  buildRepoTaskSpec() generating a repo-sync Tekton task with optional mirror
  PVC mount (--reference=<path>), inject BOB_MANIFEST_URL/BOB_MANIFEST_BRANCH
- internal/tekton/pipelinerun_builder_test.go: 9 new regression tests covering
  basic task generation, mirror mount, env vars, chaining, nil guard, and more
- config/crd/bases/builder.sdv.cloud.redhat.com_buildjobs.yaml: update enum
  to [git, pvc, repo], add repo object schema
- gofmt alignment fixes across api/ and internal/ (no logic changes)

Fixes #28

## Summary
- Added `repo` source type for AOSP/AAOS manifest-based builds
- When `mirrorRef` is set, mounts the named PVC read-only at `/mnt/mirror`
  and passes `--reference=/mnt/mirror` to `repo init` to avoid re-downloading
- Injects `BOB_MANIFEST_URL` and `BOB_MANIFEST_BRANCH` into all build stages
- 9 unit tests added; all 6 test packages pass with race detector

## Test plan
- [ ] Apply updated CRD: `kubectl apply -f config/crd/bases/builder.sdv.cloud.redhat.com_buildjobs.yaml`
- [ ] Create a BuildJob with `source.type: repo` and verify `repo-sync` task appears in PipelineRun
- [ ] Verify `BOB_MANIFEST_URL` and `BOB_MANIFEST_BRANCH` are set in build stage env
- [ ] With `mirrorRef` set, verify mirror PVC is mounted read-only at `/mnt/mirror`
- [ ] Confirm existing `git` and `pvc` source types still work unchanged

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add repo source type for AOSP/AAOS manifest-based builds

0 participants