Skip to content

Commit 5d2bec3

Browse files
authored
Switch to Gitea incluster repository provider for e2e tests (#27)
1 parent dba44a3 commit 5d2bec3

11 files changed

Lines changed: 752 additions & 105 deletions

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,16 @@ You can also connect using your IDE's remote debugging features (VS Code, GoLand
184184
# Unit tests
185185
make test
186186
187-
# E2E tests
187+
# E2E tests (requires Kind cluster with Gitea)
188+
make create-kind-cluster # Sets up cluster with Gitea
188189
make test-e2e
190+
191+
# Bundle tests
192+
make test-e2e-bundle
189193
```
190194

195+
E2E tests use an in-cluster Gitea instance instead of GitHub, providing complete test isolation. See [Gitea Integration](docs/development/gitea-integration.md) for details on the test infrastructure.
196+
191197
### Linting
192198

193199
```bash
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
# Gitea Integration for E2E Tests
2+
3+
## Overview
4+
5+
The e2e test suite uses an in-cluster Gitea instance to provide git repository functionality. This eliminates external dependencies on GitHub and provides complete isolation for testing.
6+
7+
## Architecture
8+
9+
- **Gitea Installation**: Deployed via Helm during cluster setup
10+
- **Network Access**: NodePort on port 30000 (HTTP) and 30022 (SSH)
11+
- **Service Discovery**: ConfigMap in kube-public namespace contains endpoint
12+
- **Authentication**: Admin user (giteaadmin/giteapass) for test operations
13+
- **Provider Abstraction**: Tests use `RepositoryProvider` interface, allowing easy switching between Gitea/GitHub/GitLab
14+
15+
## Using Repository Provider in Tests
16+
17+
### Basic Pattern
18+
19+
```go
20+
var (
21+
repoURL string
22+
repoDir string
23+
)
24+
25+
BeforeEach(func() {
26+
var err error
27+
28+
// Create repository provider resources with automatic cleanup
29+
username, password, _, cleanup, err := repoProvider.CreateRandomUser()
30+
Expect(err).NotTo(HaveOccurred())
31+
DeferCleanup(cleanup)
32+
33+
_, repoURL, cleanup, err = repoProvider.CreateRandomRepo(username, false)
34+
Expect(err).NotTo(HaveOccurred())
35+
DeferCleanup(cleanup)
36+
37+
// Initialize with function code
38+
repoDir, err = InitializeRepoWithFunction(repoURL, username, password, "go")
39+
Expect(err).NotTo(HaveOccurred())
40+
DeferCleanup(os.RemoveAll, repoDir)
41+
})
42+
```
43+
44+
### Available Helper Methods
45+
46+
**RepositoryProvider Interface:**
47+
- `CreateUser(username, password, email string) (cleanup func(), err error)` - Create user with cleanup function
48+
- `CreateRandomUser() (username, password, email string, cleanup func(), err error)` - Create user with random credentials
49+
- `CreateRepo(owner, name string, private bool) (url string, cleanup func(), err error)` - Create repository
50+
- `CreateRandomRepo(owner string, private bool) (name, url string, cleanup func(), err error)` - Create repo with random name
51+
- `CreateAccessToken(username, password, tokenName string) (string, error)` - Generate access token
52+
53+
**E2E Helper Functions:**
54+
- `InitializeRepoWithFunction(url, user, pass, lang)` - Clone, init function, push
55+
- `CommitAndPush(repoDir, msg, file, ...otherFiles)` - Commit and push files
56+
57+
### DeferCleanup Pattern
58+
59+
All Create methods return cleanup functions that can be used with Ginkgo's `DeferCleanup`:
60+
61+
```go
62+
username, password, _, cleanup, err := repoProvider.CreateRandomUser()
63+
Expect(err).NotTo(HaveOccurred())
64+
DeferCleanup(cleanup) // Automatically deletes user after test
65+
```
66+
67+
This ensures resources are cleaned up even if tests fail.
68+
69+
## Accessing Gitea UI
70+
71+
During development, you can access the Gitea web UI:
72+
73+
1. Get the Gitea endpoint:
74+
```bash
75+
kubectl get configmap gitea-endpoint -n kube-public -o jsonpath='{.data.http}'
76+
```
77+
78+
2. Open in browser and login:
79+
- Username: `giteaadmin`
80+
- Password: `giteapass`
81+
82+
## Testing Private Repositories
83+
84+
```go
85+
// Create private repo
86+
_, repoURL, cleanup, err := repoProvider.CreateRandomRepo(username, true)
87+
Expect(err).NotTo(HaveOccurred())
88+
DeferCleanup(cleanup)
89+
90+
// Create access token
91+
token, err := repoProvider.CreateAccessToken(username, password, "test-token")
92+
93+
// Use token in Function spec
94+
Spec: functionsdevv1alpha1.FunctionSpec{
95+
Source: functionsdevv1alpha1.FunctionSpecSource{
96+
RepositoryURL: repoURL,
97+
Credentials: &functionsdevv1alpha1.Credentials{
98+
Token: token,
99+
},
100+
},
101+
}
102+
```
103+
104+
## Bundle Test Pattern
105+
106+
Bundle tests use the `TestNamespace` struct for better organization:
107+
108+
```go
109+
type TestNamespace struct {
110+
Name string
111+
RepoURL string
112+
}
113+
114+
func createNamespaceAndDeployFunction() TestNamespace {
115+
// Creates namespace and deploys function
116+
// Returns TestNamespace with both namespace and repo URL
117+
}
118+
119+
// Usage
120+
testNs := createNamespaceAndDeployFunction()
121+
CreateFunctionAndWaitForReady(testNs)
122+
```
123+
124+
## Troubleshooting
125+
126+
### Gitea not accessible
127+
128+
```bash
129+
kubectl get pods -n gitea
130+
kubectl logs -n gitea deployment/gitea
131+
```
132+
133+
### ConfigMap missing
134+
135+
```bash
136+
kubectl get configmap -n kube-public
137+
./hack/create-kind-cluster.sh # Recreate cluster
138+
```
139+
140+
### Test failures with git operations
141+
142+
- Check Gitea pod is running
143+
- Verify network connectivity to NodePort:
144+
```bash
145+
GITEA_IP=$(kubectl get configmap gitea-endpoint -n kube-public -o jsonpath='{.data.http}')
146+
curl $GITEA_IP
147+
```
148+
- Check git credentials in test
149+
150+
### Repository cleanup issues
151+
152+
If tests leave behind repositories, you can clean them manually:
153+
154+
```bash
155+
# List all users
156+
curl -u giteaadmin:giteapass http://<gitea-endpoint>/api/v1/admin/users
157+
158+
# Delete user (includes their repos)
159+
curl -X DELETE -u giteaadmin:giteapass http://<gitea-endpoint>/api/v1/admin/users/<username>
160+
```
161+
162+
## Implementation Details
163+
164+
### Cluster Setup
165+
166+
Gitea is installed during cluster creation in `hack/create-kind-cluster.sh`:
167+
168+
```bash
169+
helm install gitea gitea-charts/gitea --namespace gitea --create-namespace \
170+
--set service.http.type=NodePort \
171+
--set service.http.nodePort=30000 \
172+
--set gitea.admin.username=giteaadmin \
173+
--set gitea.admin.password=giteapass \
174+
--set persistence.enabled=false
175+
```
176+
177+
### Service Discovery
178+
179+
The cluster setup creates a ConfigMap with the Gitea endpoint:
180+
181+
```yaml
182+
apiVersion: v1
183+
kind: ConfigMap
184+
metadata:
185+
name: gitea-endpoint
186+
namespace: kube-public
187+
data:
188+
http: "http://<node-ip>:30000"
189+
ssh: "<node-ip>:30022"
190+
```
191+
192+
Tests read this ConfigMap to discover where Gitea is running.
193+
194+
### Networking
195+
196+
- **Kind Node IP**: Retrieved via Docker inspect of control-plane node
197+
- **NodePort**: Fixed ports 30000 (HTTP) and 30022 (SSH)
198+
- **Accessibility**: Node IP is reachable from both host machine and cluster pods
199+
200+
This allows the same repository URL to work in both test code (running on host) and Function resources (running in cluster).

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/functions-dev/func-operator
33
go 1.25.0
44

55
require (
6+
code.gitea.io/sdk/gitea v0.23.2
67
github.com/go-git/go-git/v6 v6.0.0-20260114124804-a8db3a6585a6
78
github.com/go-logr/logr v1.4.3
89
github.com/onsi/ginkgo/v2 v2.27.5
@@ -21,6 +22,7 @@ require (
2122
require (
2223
cel.dev/expr v0.24.0 // indirect
2324
dario.cat/mergo v1.0.2 // indirect
25+
github.com/42wim/httpsig v1.2.3 // indirect
2426
github.com/BurntSushi/toml v1.5.0 // indirect
2527
github.com/Masterminds/semver/v3 v3.4.0 // indirect
2628
github.com/Microsoft/go-winio v0.6.2 // indirect
@@ -37,6 +39,7 @@ require (
3739
github.com/coreos/go-semver v0.3.1 // indirect
3840
github.com/cyphar/filepath-securejoin v0.6.1 // indirect
3941
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
42+
github.com/davidmz/go-pageant v1.0.2 // indirect
4043
github.com/docker/cli v28.3.0+incompatible // indirect
4144
github.com/docker/distribution v2.8.3+incompatible // indirect
4245
github.com/docker/docker-credential-helpers v0.9.3 // indirect
@@ -46,6 +49,7 @@ require (
4649
github.com/felixge/httpsnoop v1.0.4 // indirect
4750
github.com/fsnotify/fsnotify v1.9.0 // indirect
4851
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
52+
github.com/go-fed/httpsig v1.1.0 // indirect
4953
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
5054
github.com/go-git/gcfg/v2 v2.0.2 // indirect
5155
github.com/go-git/go-billy/v5 v5.6.2 // indirect
@@ -77,6 +81,7 @@ require (
7781
github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83 // indirect
7882
github.com/google/uuid v1.6.0 // indirect
7983
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 // indirect
84+
github.com/hashicorp/go-version v1.7.0 // indirect
8085
github.com/inconshreveable/mousetrap v1.1.0 // indirect
8186
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
8287
github.com/json-iterator/go v1.1.12 // indirect

go.sum

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ cel.dev/expr v0.24.0 h1:56OvJKSH3hDGL0ml5uSxZmz3/3Pq4tJ+fb1unVLAFcY=
22
cel.dev/expr v0.24.0/go.mod h1:hLPLo1W4QUmuYdA72RBX06QTs6MXw941piREPl3Yfiw=
33
cloud.google.com/go/compute/metadata v0.9.0 h1:pDUj4QMoPejqq20dK0Pg2N4yG9zIkYGdBtwLoEkH9Zs=
44
cloud.google.com/go/compute/metadata v0.9.0/go.mod h1:E0bWwX5wTnLPedCKqk3pJmVgCBSM6qQI1yTBdEb3C10=
5+
code.gitea.io/sdk/gitea v0.23.2 h1:iJB1FDmLegwfwjX8gotBDHdPSbk/ZR8V9VmEJaVsJYg=
6+
code.gitea.io/sdk/gitea v0.23.2/go.mod h1:yyF5+GhljqvA30sRDreoyHILruNiy4ASufugzYg0VHM=
57
dario.cat/mergo v1.0.2 h1:85+piFYR1tMbRrLcDwR18y4UKJ3aH1Tbzi24VRW1TK8=
68
dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA=
9+
github.com/42wim/httpsig v1.2.3 h1:xb0YyWhkYj57SPtfSttIobJUPJZB9as1nsfo7KWVcEs=
10+
github.com/42wim/httpsig v1.2.3/go.mod h1:nZq9OlYKDrUBhptd77IHx4/sZZD+IxTBADvAPI9G/EM=
711
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c h1:udKWzYgxTojEKWjV8V+WSxDXJ4NFATAsZjh8iIbsQIg=
812
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
913
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
@@ -72,6 +76,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
7276
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
7377
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
7478
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
79+
github.com/davidmz/go-pageant v1.0.2 h1:bPblRCh5jGU+Uptpz6LgMZGD5hJoOt7otgT454WvHn0=
80+
github.com/davidmz/go-pageant v1.0.2/go.mod h1:P2EDDnMqIwG5Rrp05dTRITj9z2zpGcD9efWSkTNKLIE=
7581
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
7682
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
7783
github.com/docker/cli v28.3.0+incompatible h1:s+ttruVLhB5ayeuf2BciwDVxYdKi+RoUlxmwNHV3Vfo=
@@ -112,6 +118,8 @@ github.com/gliderlabs/ssh v0.3.8 h1:a4YXD1V7xMF9g5nTkdfnja3Sxy1PVDCj1Zg4Wb8vY6c=
112118
github.com/gliderlabs/ssh v0.3.8/go.mod h1:xYoytBv1sV0aL3CavoDuJIQNURXkkfPA/wxQ1pL1fAU=
113119
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
114120
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
121+
github.com/go-fed/httpsig v1.1.0 h1:9M+hb0jkEICD8/cAiNqEB66R87tTINszBRTjwjQzWcI=
122+
github.com/go-fed/httpsig v1.1.0/go.mod h1:RCMrTZvN1bJYtofsG4rd5NaO5obxQ5xBkdiS7xsT7bM=
115123
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
116124
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
117125
github.com/go-git/gcfg/v2 v2.0.2 h1:MY5SIIfTGGEMhdA7d7JePuVVxtKL7Hp+ApGDJAJ7dpo=
@@ -204,6 +212,8 @@ github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 h1:+ngKgrYPPJr
204212
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
205213
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 h1:NmZ1PKzSTQbuGHw9DGPFomqkkLWMC+vZCkfs+FHv1Vg=
206214
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3/go.mod h1:zQrxl1YP88HQlA6i9c63DSVPFklWpGX4OWAc9bFuaH4=
215+
github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY=
216+
github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
207217
github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c=
208218
github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
209219
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
@@ -402,20 +412,27 @@ go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0=
402412
go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8=
403413
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
404414
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
415+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
416+
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
417+
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
405418
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
406419
golang.org/x/crypto v0.47.0 h1:V6e3FRj+n4dbpw86FJ8Fv7XVOql7TEwpHapKoMJ/GO8=
407420
golang.org/x/crypto v0.47.0/go.mod h1:ff3Y9VzzKbwSSEzWqJsJVBnWmRwRSHt/6Op5n9bQc4A=
408421
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 h1:R84qjqJb5nVJMxqWYb3np9L5ZsaDtB+a39EqjV0JSUM=
409422
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0/go.mod h1:S9Xr4PYopiDyqSyp5NjCrhFrqg6A5zA2E/iPHPhqnS8=
410423
golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c=
411424
golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU=
425+
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
426+
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
412427
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
413428
golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o=
414429
golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8=
415430
golang.org/x/oauth2 v0.34.0 h1:hqK/t4AKgbqWkdkcAeI8XLmbK+4m4G5YeQRrmiotGlw=
416431
golang.org/x/oauth2 v0.34.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
417432
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
418433
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
434+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
435+
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
419436
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
420437
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
421438
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -427,6 +444,8 @@ golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
427444
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
428445
golang.org/x/term v0.39.0 h1:RclSuaJf32jOqZz74CkPA9qFuVTX7vhLlpfj/IGWlqY=
429446
golang.org/x/term v0.39.0/go.mod h1:yxzUCTP/U+FzoxfdKmLaA0RV1WgE0VY7hXBwKtY/4ww=
447+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
448+
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
430449
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
431450
golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE=
432451
golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8=

hack/create-kind-cluster.sh

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,40 @@ function install_keda() {
164164
kubectl wait deployment --all --timeout=-1s --for=condition=Available --namespace keda
165165
}
166166

167+
function install_gitea() {
168+
header_text "Installing Gitea"
169+
170+
helm repo add gitea-charts https://dl.gitea.com/charts/
171+
helm repo update
172+
helm install gitea gitea-charts/gitea --namespace gitea --create-namespace \
173+
--set service.http.type=NodePort \
174+
--set service.http.nodePort=30000 \
175+
--set service.ssh.type=NodePort \
176+
--set service.ssh.nodePort=30022 \
177+
--set gitea.admin.username=giteaadmin \
178+
--set gitea.admin.password=giteapass \
179+
--set gitea.admin.email=admin@gitea.local \
180+
--set persistence.enabled=false
181+
182+
header_text "Waiting for Gitea to become ready"
183+
kubectl wait deployment --all --timeout=-1s --for=condition=Available --namespace gitea
184+
185+
# Get Gitea endpoint for tests
186+
GITEA_NODE_IP=$(docker inspect kind-control-plane --format '{{.NetworkSettings.Networks.kind.IPAddress}}')
187+
188+
# Create ConfigMap with Gitea endpoint info
189+
kubectl apply -f - <<EOF
190+
apiVersion: v1
191+
kind: ConfigMap
192+
metadata:
193+
name: gitea-endpoint
194+
namespace: kube-public
195+
data:
196+
http: "http://${GITEA_NODE_IP}:30000"
197+
ssh: "${GITEA_NODE_IP}:30022"
198+
EOF
199+
}
200+
167201
if [ "$DELETE_CLUSTER_BEFORE" = "true" ]; then
168202
delete_existing_cluster
169203
fi
@@ -175,5 +209,6 @@ install_tekton
175209
install_knative_serving
176210
install_knative_eventing
177211
install_keda
212+
install_gitea
178213

179-
header_text "All components installed"
214+
header_text "All components installed"

0 commit comments

Comments
 (0)