Skip to content

Commit 2f71668

Browse files
authored
Merge pull request #193 from saiakhil2012/akhil/spire-overlay-arch
Modular overlay architecture for SPIRE integration
2 parents 8df52ce + 7450634 commit 2f71668

File tree

1,874 files changed

+44062
-278881
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,874 files changed

+44062
-278881
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,25 @@ jobs:
149149
- name: Build SPIRE Components
150150
timeout-minutes: 10
151151
run: |
152-
echo "=== Building SPIRE ==="
153-
cd hybrid-cloud-poc
154-
155-
if [ -f "spire/bin/spire-server" ] && [ -f "spire/bin/spire-agent" ]; then
152+
echo "=== Building SPIRE with Overlay ==="
153+
154+
# Use SPIRE overlay build system instead of building from fork
155+
if [ -f "build/spire-binaries/spire-server" ] && [ -f "build/spire-binaries/spire-agent" ]; then
156156
echo "SPIRE binaries already exist."
157157
else
158-
cd spire
159-
make bin/spire-server bin/spire-agent
158+
chmod +x scripts/spire-build.sh
159+
./scripts/spire-build.sh
160160
fi
161+
162+
# Create symlink for backward compatibility with test scripts
163+
mkdir -p hybrid-cloud-poc/spire/bin
164+
ln -sf "$PWD/build/spire-binaries/spire-server" hybrid-cloud-poc/spire/bin/spire-server
165+
ln -sf "$PWD/build/spire-binaries/spire-agent" hybrid-cloud-poc/spire/bin/spire-agent
166+
167+
echo "✓ SPIRE binaries available at:"
168+
echo " - build/spire-binaries/spire-server"
169+
echo " - build/spire-binaries/spire-agent"
170+
echo " - hybrid-cloud-poc/spire/bin/ (symlinked)"
161171
162172
- name: Build Rust-Keylime Agent
163173
timeout-minutes: 15

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,7 @@ hybrid-cloud-poc/keylime/cv_data.sqlite
9898
!hybrid-cloud-poc/**/test/**/testdata/*.pem
9999
!hybrid-cloud-poc/**/test/**/testdata/*.crt
100100
!hybrid-cloud-poc/**/test/**/testdata/*.key
101+
102+
# SPIRE Development Environment (temporary, created by spire-dev-setup.sh)
103+
build/spire-dev/
104+
spire-overlay/.backup-*/

docs/SPIRE_DEV_WORKFLOW.md

Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
# SPIRE Development Workflow
2+
3+
This document explains how to develop new features for SPIRE overlay patches.
4+
5+
## Overview
6+
7+
The Aegis repository uses an **overlay system** to keep the repo clean while still allowing full SPIRE development when needed.
8+
9+
```
10+
Normal State (Clean):
11+
└── spire-overlay/ (patches only, ~50 files)
12+
13+
Development State (Temporary):
14+
├── spire-overlay/ (patches)
15+
└── build/spire-dev/ (full SPIRE fork, 17k files)
16+
```
17+
18+
## Workflow
19+
20+
### 1. Setup Development Environment
21+
22+
Generate a temporary SPIRE fork with your patches applied:
23+
24+
```bash
25+
./scripts/spire-dev-setup.sh
26+
```
27+
28+
This creates:
29+
- `build/spire-dev/spire/` - Full SPIRE repository
30+
- Applied with all your overlay patches
31+
- Ready for development with IDE support
32+
33+
### 2. Make Changes
34+
35+
Work in the development environment:
36+
37+
```bash
38+
cd build/spire-dev/spire
39+
40+
# Make your changes with full IDE support
41+
vim pkg/server/api/agent/v1/service.go
42+
43+
# Test your changes
44+
make build
45+
make test
46+
47+
# Commit your changes
48+
git add -A
49+
git commit -m "Add new attestation feature"
50+
```
51+
52+
### 3. Extract Changes Back to Patches
53+
54+
After committing your changes:
55+
56+
```bash
57+
cd $PROJECT_ROOT
58+
./scripts/spire-dev-extract.sh
59+
```
60+
61+
This:
62+
- Regenerates all patch files
63+
- Backs up old patches
64+
- Updates `spire-overlay/` directory
65+
66+
### 4. Cleanup
67+
68+
Remove the temporary fork:
69+
70+
```bash
71+
./scripts/spire-dev-cleanup.sh
72+
```
73+
74+
Your repo is now clean again with only the updated patches!
75+
76+
### 5. Test and Commit
77+
78+
```bash
79+
# Test the updated overlay
80+
./scripts/spire-build.sh
81+
82+
# Verify binaries work
83+
cd hybrid-cloud-poc
84+
./test_control_plane.sh
85+
86+
# Commit the updated patches
87+
git add spire-overlay/
88+
git commit -m "feat: add new attestation endpoint"
89+
```
90+
91+
## Best Practices
92+
93+
### ✅ DO
94+
95+
- Keep the dev environment temporary
96+
- Extract and cleanup frequently
97+
- Test after every extraction
98+
- Commit patches to git
99+
100+
### ❌ DON'T
101+
102+
- Commit the `build/spire-dev/` directory to git
103+
- Keep the dev environment for days
104+
- Make changes directly to patch files (use dev environment instead)
105+
- Forget to extract before cleanup
106+
107+
## Examples
108+
109+
### Adding a New Proto Field
110+
111+
```bash
112+
# Setup
113+
./scripts/spire-dev-setup.sh
114+
cd build/spire-dev/spire
115+
116+
# Edit proto
117+
vim proto/spire/api/types/sovereignattestation.proto
118+
119+
# Regenerate Go code
120+
make proto-generate
121+
122+
# Test
123+
make test
124+
125+
# Commit
126+
git add -A
127+
git commit -m "Add TPM quote field"
128+
129+
# Extract and cleanup
130+
cd ../../..
131+
./scripts/spire-dev-extract.sh
132+
./scripts/spire-dev-cleanup.sh
133+
134+
# Test overlay
135+
./scripts/spire-build.sh
136+
```
137+
138+
### Updating SPIRE Version
139+
140+
```bash
141+
# Update version in spire-dev-setup.sh
142+
SPIRE_VERSION="v1.11.0" ./scripts/spire-dev-setup.sh
143+
144+
# If patches fail, fix conflicts manually
145+
cd build/spire-dev/spire
146+
# ... fix conflicts ...
147+
git add -A && git commit
148+
149+
# Extract updated patches
150+
cd ../../..
151+
./scripts/spire-dev-extract.sh
152+
./scripts/spire-dev-cleanup.sh
153+
```
154+
155+
## Troubleshooting
156+
157+
### Patch doesn't apply
158+
159+
```bash
160+
# Setup dev environment
161+
./scripts/spire-dev-setup.sh
162+
163+
# If patch fails, fix manually:
164+
cd build/spire-dev/spire
165+
# Fix the conflicts
166+
git add -A && git commit
167+
cd ../../..
168+
./scripts/spire-dev-extract.sh
169+
```
170+
171+
### Lost uncommitted changes
172+
173+
```bash
174+
# Check if dev environment still exists
175+
ls build/spire-dev/spire
176+
177+
# If yes, extract now:
178+
./scripts/spire-dev-extract.sh
179+
```
180+
181+
### Need to work on multiple features
182+
183+
```bash
184+
# Create separate dev environments
185+
DEV_ENV_NAME=feature-1 ./scripts/spire-dev-setup.sh
186+
DEV_ENV_NAME=feature-2 ./scripts/spire-dev-setup.sh
187+
188+
# Work in each separately, extract independently
189+
```
190+
191+
## Repository States
192+
193+
### Clean State (Default)
194+
195+
```
196+
.
197+
├── spire-overlay/
198+
│ ├── core-patches/
199+
│ │ ├── server-api.patch (28k lines)
200+
│ │ ├── server-endpoints.patch (13k lines)
201+
│ │ └── feature-flags.patch
202+
│ ├── proto-patches/
203+
│ ├── plugins/
204+
│ └── packages/
205+
├── scripts/
206+
│ ├── spire-build.sh # Production builds
207+
│ ├── spire-dev-setup.sh # Dev environment
208+
│ ├── spire-dev-extract.sh # Extract changes
209+
│ └── spire-dev-cleanup.sh # Cleanup
210+
└── build/ # .gitignore'd
211+
```
212+
213+
### Development State (Temporary)
214+
215+
```
216+
.
217+
├── spire-overlay/ # Your patches
218+
├── scripts/ # Scripts
219+
└── build/
220+
├── spire-binaries/ # Production build
221+
└── spire-dev/ # Development (temporary)
222+
└── spire/ # Full fork
223+
```
224+
225+
## FAQ
226+
227+
**Q: Why not keep the fork permanently?**
228+
A: 17,315 files pollute the repo. Overlay keeps it clean.
229+
230+
**Q: Can I work directly in patch files?**
231+
A: Technically yes, but very error-prone. Use dev environment.
232+
233+
**Q: What if I forget to extract?**
234+
A: The cleanup script warns you and offers to extract first.
235+
236+
**Q: Is this needed for small patch edits?**
237+
A: No. For fixing line numbers, edit patches directly.

0 commit comments

Comments
 (0)