Skip to content

Commit 8c7cc62

Browse files
authored
feat: implement crud operators for builder templates (#6)
* feat: implement crud operators for builder templates * chore: bump lib deps + update ci and dockerfile * chore: update ci trigger
1 parent ad8bf9e commit 8c7cc62

19 files changed

Lines changed: 2261 additions & 33 deletions

File tree

.github/workflows/on-push.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1+
---
12
name: On Push
23

3-
on:
4+
"on":
45
push:
56
branches:
67
- main
7-
- master
88
pull_request:
99
branches:
1010
- main
11-
- master
1211

1312
jobs:
1413
build-and-push:
1514
permissions:
1615
contents: read
1716
packages: write
18-
uses: builderhub/actions-internal/.github/workflows/build-push-image.yaml@main
17+
uses: BuilderHub/actions/.github/workflows/buildah-build-push-workflow.yaml@v0.1.0-beta.2
1918
with:
20-
image-name: build-api
21-
dockerfile: Dockerfile
19+
image: build-api
20+
tags: ${{ github.sha }}
21+
containerfiles: Dockerfile
2222
context: .
23-
buildx-args: --secret id=netrc,env=SECRET_SLOT_0
24-
push-to-registry: ${{ github.event_name == 'push' }}
23+
registry: ghcr.io/builderhub
24+
push: ${{ github.event_name == 'push' }}
2525
secrets:
26-
registry-password: ${{ secrets.GITHUB_TOKEN }}
27-
secret-slot-0: |
28-
machine github.com login x-access-token password ${{ secrets.ORG_REPO_READ_ONLY }}
26+
REGISTRY_USERNAME: ${{ github.actor }}
27+
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
28+

Dockerfile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
# BuilderHub Build API - multi-stage, distroless, multi-arch
2-
# Requires netrc for go mod download (private build-operator): --secret id=netrc,env=SECRET_SLOT_0
3-
# Build from build-api repo: docker buildx build --secret id=netrc,env=SECRET_SLOT_0 .
42

53
FROM --platform=$BUILDPLATFORM golang:1.25-alpine AS builder
64
WORKDIR /workspace
75

86
RUN apk add --no-cache git ca-certificates tzdata
97

108
COPY go.mod go.sum ./
11-
COPY . .
9+
RUN go mod download
1210

13-
# go mod download fetches build-operator from github.com/builderhub/build-operator (netrc for private repo auth)
14-
ENV GOPRIVATE=github.com/builderhub/*
15-
RUN --mount=type=secret,id=netrc,target=/root/.netrc go mod download
11+
COPY . .
1612

1713
ARG TARGETARCH
1814
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH go build -ldflags="-w -s" -o build-api ./cmd/server

README.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ BuilderHub public-facing API. Manages BuildkitBuilder CRs via gRPC and REST.
44

55
## Features
66

7-
- **gRPC** on port 9090 (ListBuilders, GetBuilder, CreateBuilder, WakeBuilder, HealthCheck)
7+
- **gRPC** on port 9090 (builders, organizations, templates, auth, health)
88
- **REST** via grpc-gateway on port 8080
99
- **Swagger UI** at `/docs`, OpenAPI spec at `/openapi.json`
1010
- **Health** endpoints at `/health` and `/ready`
@@ -48,6 +48,11 @@ Set `GOPRIVATE=github.com/builderhub/*` and configure `~/.netrc` for private mod
4848
| GET | /v1/namespaces/{ns}/builders/{name} | Get builder |
4949
| POST | /v1/namespaces/{ns}/builders | Create builder |
5050
| POST | /v1/namespaces/{ns}/builders/{name}/wake | Wake sleepy builder |
51+
| GET | /v1/namespaces/{ns}/templates | List builder templates (org/namespace-scoped) |
52+
| GET | /v1/namespaces/{ns}/templates/{name} | Get builder template |
53+
| POST | /v1/namespaces/{ns}/templates | Create builder template |
54+
| PATCH | /v1/namespaces/{ns}/templates/{name} | Update builder template |
55+
| DELETE | /v1/namespaces/{ns}/templates/{name} | Delete builder template |
5156
| GET | /v1/health | Health check |
5257
| GET | /docs | Swagger UI |
5358
| GET | /openapi.json | OpenAPI spec |
@@ -57,11 +62,9 @@ Set `GOPRIVATE=github.com/builderhub/*` and configure `~/.netrc` for private mod
5762
### Docker
5863

5964
```bash
60-
docker buildx build -f Dockerfile --secret id=netrc,env=SECRET_SLOT_0 .
65+
docker buildx build -f Dockerfile .
6166
```
6267

63-
Requires `SECRET_SLOT_0` env var with netrc content for private repo access.
64-
6568
### Helm
6669

6770
```bash
@@ -70,6 +73,16 @@ helm install build-api helm/build-api -n builderhub --create-namespace \
7073
--set image.tag=v0.0.0-beta.0
7174
```
7275

76+
## Scopes for API keys
77+
78+
When creating API keys (via AuthService), the following scopes are available:
79+
80+
- `builders:read`, `builders:write`
81+
- `organizations:read`, `organizations:write`
82+
- `templates:read`, `templates:write` (new — for managing BuildkitBuilderTemplates)
83+
84+
JWT sessions from `auth login` have full access.
85+
7386
## License
7487

7588
This project is licensed under the [MIT License](LICENSE).

api/gen/buildapi/v1/auth.pb.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/gen/buildapi/v1/auth_grpc.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/gen/buildapi/v1/buildapi_grpc.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/gen/buildapi/v1/organizations_grpc.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)