Skip to content

Commit 09b8d18

Browse files
authored
Merge pull request #2 from jralmaraz/copilot/fix-7cd97c98-a7ac-4279-88a6-9b1db4122d76
Implement complete OpenFGA Kubernetes operator with status checks and build system
2 parents dc933e9 + e1c39a5 commit 09b8d18

File tree

11 files changed

+1181
-0
lines changed

11 files changed

+1181
-0
lines changed

.github/workflows/ci.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [ main, develop ]
6+
push:
7+
branches: [ main, develop ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
compile:
14+
name: Compile Check
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Install Rust
19+
uses: dtolnay/rust-toolchain@stable
20+
- name: Cache cargo registry
21+
uses: actions/cache@v4
22+
with:
23+
path: |
24+
~/.cargo/registry
25+
~/.cargo/git
26+
target
27+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
28+
- name: Run compile check
29+
run: make compile
30+
31+
build:
32+
name: Build Check
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v4
36+
- name: Install Rust
37+
uses: dtolnay/rust-toolchain@stable
38+
- name: Cache cargo registry
39+
uses: actions/cache@v4
40+
with:
41+
path: |
42+
~/.cargo/registry
43+
~/.cargo/git
44+
target
45+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
46+
- name: Run build check
47+
run: make build
48+
49+
test:
50+
name: Test
51+
runs-on: ubuntu-latest
52+
steps:
53+
- uses: actions/checkout@v4
54+
- name: Install Rust
55+
uses: dtolnay/rust-toolchain@stable
56+
- name: Cache cargo registry
57+
uses: actions/cache@v4
58+
with:
59+
path: |
60+
~/.cargo/registry
61+
~/.cargo/git
62+
target
63+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
64+
- name: Run tests
65+
run: make test
66+
67+
fmt:
68+
name: Format Check
69+
runs-on: ubuntu-latest
70+
steps:
71+
- uses: actions/checkout@v4
72+
- name: Install Rust
73+
uses: dtolnay/rust-toolchain@stable
74+
with:
75+
components: rustfmt
76+
- name: Check formatting
77+
run: cargo fmt -- --check
78+
79+
clippy:
80+
name: Clippy Check
81+
runs-on: ubuntu-latest
82+
steps:
83+
- uses: actions/checkout@v4
84+
- name: Install Rust
85+
uses: dtolnay/rust-toolchain@stable
86+
with:
87+
components: clippy
88+
- name: Cache cargo registry
89+
uses: actions/cache@v4
90+
with:
91+
path: |
92+
~/.cargo/registry
93+
~/.cargo/git
94+
target
95+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
96+
- name: Run clippy
97+
run: make clippy

.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Rust
2+
/target/
3+
Cargo.lock
4+
5+
# IDE
6+
.vscode/
7+
.idea/
8+
*.swp
9+
*.swo
10+
*~
11+
12+
# OS
13+
.DS_Store
14+
Thumbs.db
15+
16+
# Kubernetes
17+
*.kubeconfig
18+
kubeconfig
19+
20+
# Logs
21+
*.log
22+
23+
# Build artifacts
24+
/dist/
25+
/build/

Cargo.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "openfga-operator"
3+
version = "0.1.0"
4+
edition = "2021"
5+
authors = ["OpenFGA Team"]
6+
description = "Kubernetes operator for OpenFGA"
7+
license = "Apache-2.0"
8+
9+
[dependencies]
10+
kube = { version = "0.87", features = ["runtime", "derive", "client"] }
11+
k8s-openapi = { version = "0.20", features = ["v1_28"] }
12+
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
13+
serde = { version = "1.0", features = ["derive"] }
14+
serde_json = "1.0"
15+
serde_yaml = "0.9"
16+
anyhow = "1.0"
17+
thiserror = "1.0"
18+
tracing = "0.1"
19+
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
20+
futures = "0.3"
21+
schemars = "0.8"

Makefile

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
.PHONY: compile build test fmt clippy clean install-crds uninstall-crds run dev
2+
3+
# Default target
4+
all: compile build
5+
6+
# Compile the project (check syntax and dependencies)
7+
compile:
8+
@echo "Compiling OpenFGA Operator..."
9+
cargo check
10+
11+
# Build the project
12+
build:
13+
@echo "Building OpenFGA Operator..."
14+
cargo build --release
15+
16+
# Run tests
17+
test:
18+
@echo "Running tests..."
19+
cargo test
20+
21+
# Format code
22+
fmt:
23+
@echo "Formatting code..."
24+
cargo fmt
25+
26+
# Run clippy for linting
27+
clippy:
28+
@echo "Running clippy..."
29+
cargo clippy -- -D warnings
30+
31+
# Clean build artifacts
32+
clean:
33+
@echo "Cleaning build artifacts..."
34+
cargo clean
35+
36+
# Install CRDs to the cluster
37+
install-crds:
38+
@echo "Installing CRDs..."
39+
kubectl apply -f crds/
40+
41+
# Uninstall CRDs from the cluster
42+
uninstall-crds:
43+
@echo "Uninstalling CRDs..."
44+
kubectl delete -f crds/
45+
46+
# Run the operator locally
47+
run:
48+
@echo "Running OpenFGA Operator locally..."
49+
cargo run
50+
51+
# Development mode with auto-reload
52+
dev:
53+
@echo "Running in development mode..."
54+
cargo watch -x run
55+
56+
# Build Docker image
57+
docker-build:
58+
@echo "Building Docker image..."
59+
docker build -t openfga-operator:latest .
60+
61+
# Run all quality checks
62+
check-all: fmt clippy compile test
63+
@echo "All checks passed!"
64+
65+
# Help target
66+
help:
67+
@echo "Available targets:"
68+
@echo " compile - Check syntax and dependencies"
69+
@echo " build - Build the project in release mode"
70+
@echo " test - Run tests"
71+
@echo " fmt - Format code"
72+
@echo " clippy - Run clippy linter"
73+
@echo " clean - Clean build artifacts"
74+
@echo " install-crds - Install CRDs to Kubernetes cluster"
75+
@echo " uninstall-crds - Remove CRDs from Kubernetes cluster"
76+
@echo " run - Run the operator locally"
77+
@echo " dev - Run in development mode with auto-reload"
78+
@echo " docker-build - Build Docker image"
79+
@echo " check-all - Run all quality checks"
80+
@echo " help - Show this help message"

0 commit comments

Comments
 (0)