Skip to content

Commit 820b029

Browse files
committed
Initial function-approve implementation
Signed-off-by: Yury Tsarev <[email protected]>
1 parent 9283ab9 commit 820b029

16 files changed

+916
-3944
lines changed

NOTES.txt

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,41 @@
1-
To get started:
2-
3-
1. Replace `function-template-go` with your function in `go.mod`,
4-
`package/crossplane.yaml`, and any Go imports. (You can also do this
5-
automatically by running the `./init.sh <function-name>` script.)
6-
2. Update `input/v1beta1/` to reflect your desired input (and run `go generate`)
7-
3. Add your logic to `RunFunction` in `fn.go`
8-
4. Add tests for your logic in `fn_test.go`
9-
5. Update `README.md`, to be about your function!
1+
FUNCTION-APPROVE IMPLEMENTATION NOTES
2+
3+
This function implements a serverless manual approval workflow for Crossplane, as requested by the customer.
4+
5+
Key Components:
6+
7+
1. Hash Calculation:
8+
- Computes a hash of specified field (e.g., spec.resources)
9+
- Supports md5, sha256, and sha512 algorithms
10+
- Stores current hash in status.newHash
11+
12+
2. Hash Comparison:
13+
- Compares new hash with previously approved hash (status.oldHash)
14+
- If different, indicates a change requiring approval
15+
16+
3. Approval Mechanism:
17+
- Uses status.approved (boolean) for manual approval
18+
- When changes detected, pauses reconciliation until approved
19+
- After approval, updates oldHash to newHash for future comparisons
20+
21+
4. Reconciliation Pausing:
22+
- Adds crossplane.io/paused annotation when changes detected
23+
- Removes annotation when changes approved
24+
- Prevents drift of managed resources
25+
26+
5. Condition Reporting:
27+
- Sets ApprovalRequired condition when changes detected
28+
- Provides detailed information about changes and approval steps
29+
30+
Usage Flow:
31+
1. Resource created or updated (hash calculated & stored)
32+
2. If not previously approved or hash changed:
33+
- Set ApprovalRequired condition
34+
- Add pause annotation
35+
3. Admin approves by setting status.approved = true
36+
4. Next reconciliation:
37+
- Store approved hash
38+
- Remove pause annotation
39+
- Resume reconciliation
40+
41+
No external dependencies required - all functionality implemented using Crossplane native mechanisms.

0 commit comments

Comments
 (0)