Skip to content
This repository was archived by the owner on May 9, 2025. It is now read-only.

Commit 0074dc5

Browse files
authored
Merge pull request #8 from open-component-model/prepare-e2e-environment
feat: prepare e2e test environment
2 parents 8479b78 + 07d6be2 commit 0074dc5

File tree

4 files changed

+74
-3
lines changed

4 files changed

+74
-3
lines changed

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
22
# Ignore build and test binaries.
3-
bin/
43
testbin/

Tiltfile

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# -*- mode: Python -*-
2+
3+
kubectl_cmd = "kubectl"
4+
5+
# verify kubectl command exists
6+
if str(local("command -v " + kubectl_cmd + " || true", quiet = True)) == "":
7+
fail("Required command '" + kubectl_cmd + "' not found in PATH")
8+
9+
# Use kustomize to build the install yaml files
10+
install = kustomize('config/default')
11+
12+
# Update the root security group. Tilt requires root access to update the
13+
# running process.
14+
objects = decode_yaml_stream(install)
15+
for o in objects:
16+
if o.get('kind') == 'Deployment' and o.get('metadata').get('name') == 'git-sync-controller':
17+
o['spec']['template']['spec']['securityContext']['runAsNonRoot'] = False
18+
break
19+
20+
updated_install = encode_yaml_stream(objects)
21+
22+
# Apply the updated yaml to the cluster.
23+
# Allow duplicates so the e2e test can include this tilt file with other tilt files
24+
# setting up the same namespace.
25+
k8s_yaml(updated_install, allow_duplicates = True)
26+
27+
load('ext://restart_process', 'docker_build_with_restart')
28+
29+
# enable hot reloading by doing the following:
30+
# - locally build the whole project
31+
# - create a docker imagine using tilt's hot-swap wrapper
32+
# - push that container to the local tilt registry
33+
# Once done, rebuilding now should be a lot faster since only the relevant
34+
# binary is rebuilt and the hot swat wrapper takes care of the rest.
35+
local_resource(
36+
'git-sync-controller-binary',
37+
'CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/manager ./',
38+
deps = [
39+
"main.go",
40+
"go.mod",
41+
"go.sum",
42+
"api",
43+
"controllers",
44+
"pkg",
45+
],
46+
)
47+
48+
# Build the docker image for our controller. We use a specific Dockerfile
49+
# since tilt can't run on a scratch container.
50+
# `only` here is important, otherwise, the container will get updated
51+
# on _any_ file change. We only want to monitor the binary.
52+
# If debugging is enabled, we switch to a different docker file using
53+
# the delve port.
54+
entrypoint = ['/manager']
55+
dockerfile = 'tilt.dockerfile'
56+
docker_build_with_restart(
57+
'ghcr.io/open-component-model/git-sync-controller',
58+
'.',
59+
dockerfile = dockerfile,
60+
entrypoint = entrypoint,
61+
only=[
62+
'./bin',
63+
],
64+
live_update = [
65+
sync('./bin/manager', '/manager'),
66+
],
67+
)

config/manager/kustomization.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ images:
77
newName: controller
88
newTag: latest
99
- name: open-component-model/git-sync-controller
10-
newName: localhost:5001/open-component-model/git-sync-controller
11-
newTag: v0.0.1
10+
newName: ghcr.io/open-component-model/git-sync-controller
11+
newTag: latest

tilt.dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM alpine
2+
WORKDIR /
3+
COPY ./bin/manager /manager
4+
5+
ENTRYPOINT ["/manager"]

0 commit comments

Comments
 (0)