Skip to content

Commit 4ce44dd

Browse files
authored
Merge branch 'main' into dependabot/go_modules/k8s.io/api-0.33.4
2 parents ec941c0 + 56e0d59 commit 4ce44dd

20 files changed

Lines changed: 3184 additions & 607 deletions

.github/workflows/ci.yaml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,28 @@ jobs:
2828
runs-on: ubuntu-latest
2929
steps:
3030
- name: Checkout
31-
uses: actions/checkout@v4
31+
uses: actions/checkout@v5
3232

3333
- name: Setup Go
3434
uses: actions/setup-go@v5
3535
with:
36-
go-version: "~1.22"
36+
go-version: "~1.24"
3737

3838
- name: Test
3939
run: go test ./... -race
40+
41+
lint:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Checkout
45+
uses: actions/checkout@v5
46+
47+
- name: Setup Go
48+
uses: actions/setup-go@v5
49+
with:
50+
go-version: "~1.24"
51+
52+
- name: golangci-lint
53+
uses: golangci/golangci-lint-action@v7
54+
with:
55+
version: v2.1.6

.github/workflows/integration.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: integration
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
permissions:
10+
actions: none
11+
checks: none
12+
contents: read
13+
deployments: none
14+
issues: none
15+
packages: none
16+
pull-requests: none
17+
repository-projects: none
18+
security-events: none
19+
statuses: none
20+
21+
# Cancel in-progress runs for pull requests when developers push
22+
# additional changes
23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.ref }}
25+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
26+
27+
jobs:
28+
integration-test:
29+
runs-on: ubuntu-latest
30+
timeout-minutes: 10
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
34+
35+
- name: Setup Go
36+
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
37+
with:
38+
go-version: "~1.24"
39+
40+
- name: Create KinD cluster
41+
uses: helm/kind-action@92086f6be054225fa813e0a4b13787fc9088faab # v1.13.0
42+
with:
43+
cluster_name: integration-test
44+
45+
- name: Run integration tests
46+
run: go test -tags=integration -v -timeout=8m ./...

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
runs-on: ubuntu-latest
2121
steps:
2222
- name: Checkout
23-
uses: actions/checkout@v4
23+
uses: actions/checkout@v5
2424

2525
- name: Setup Go
2626
uses: actions/setup-go@v5

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
coder-logstream-kube
12
coder-logstream-kube-*
2-
build
3+
*.test
4+
build/

.golangci.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# See https://golangci-lint.run/usage/configuration/
2+
version: "2"
3+
4+
linters:
5+
enable:
6+
- govet
7+
- errcheck
8+
- staticcheck
9+
- unused
10+
- ineffassign
11+
- misspell
12+
- revive
13+
settings:
14+
govet:
15+
enable-all: true
16+
disable:
17+
- fieldalignment
18+
- shadow
19+
misspell:
20+
locale: US
21+
revive:
22+
rules:
23+
- name: exported
24+
arguments:
25+
- "checkPrivateReceivers"
26+
27+
formatters:
28+
enable:
29+
- goimports

Makefile

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Colors for output
2+
GREEN := $(shell printf '\033[32m')
3+
RESET := $(shell printf '\033[0m')
4+
BOLD := $(shell printf '\033[1m')
5+
6+
# Shell source files - use shfmt to find them (respects .editorconfig)
7+
SHELL_SRC_FILES := $(shell shfmt -f .)
8+
9+
.PHONY: all
10+
all: build
11+
12+
.PHONY: build
13+
build:
14+
go build ./...
15+
16+
.PHONY: test
17+
test:
18+
go test ./... -race
19+
20+
.PHONY: test/integration
21+
test/integration:
22+
go test -tags=integration -v -timeout=8m ./...
23+
24+
.PHONY: lint
25+
lint: lint/go lint/shellcheck
26+
27+
.PHONY: lint/go
28+
lint/go:
29+
golangci-lint run --timeout=5m
30+
31+
.PHONY: lint/shellcheck
32+
lint/shellcheck: $(SHELL_SRC_FILES)
33+
echo "--- shellcheck"
34+
shellcheck --external-sources $(SHELL_SRC_FILES)
35+
36+
.PHONY: fmt
37+
fmt: fmt/go fmt/shfmt
38+
39+
.PHONY: fmt/go
40+
fmt/go:
41+
go fmt ./...
42+
43+
.PHONY: fmt/shfmt
44+
fmt/shfmt: $(SHELL_SRC_FILES)
45+
ifdef FILE
46+
# Format single shell script
47+
if [[ -f "$(FILE)" ]] && [[ "$(FILE)" == *.sh ]]; then \
48+
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/shfmt$(RESET) $(FILE)"; \
49+
shfmt -w "$(FILE)"; \
50+
fi
51+
else
52+
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/shfmt$(RESET)"
53+
# Only do diff check in CI, errors on diff.
54+
ifdef CI
55+
shfmt -d $(SHELL_SRC_FILES)
56+
else
57+
shfmt -w $(SHELL_SRC_FILES)
58+
endif
59+
endif
60+
61+
.PHONY: clean
62+
clean:
63+
rm -f coder-logstream-kube
64+
65+
.PHONY: kind/create
66+
kind/create:
67+
./scripts/kind-setup.sh create
68+
69+
.PHONY: kind/delete
70+
kind/delete:
71+
./scripts/kind-setup.sh delete
72+
73+
.PHONY: help
74+
help:
75+
@echo "Available targets:"
76+
@echo " build - Build the project"
77+
@echo " test - Run unit tests"
78+
@echo " test/integration - Run integration tests (requires KinD cluster)"
79+
@echo " lint - Run all linters"
80+
@echo " lint/go - Run golangci-lint"
81+
@echo " lint/shellcheck - Run shellcheck on shell scripts"
82+
@echo " fmt - Format all code"
83+
@echo " fmt/go - Format Go code"
84+
@echo " fmt/shfmt - Format shell scripts"
85+
@echo " kind/create - Create KinD cluster for integration tests"
86+
@echo " kind/delete - Delete KinD cluster"
87+
@echo " clean - Remove build artifacts"

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ helm install coder-logstream-kube coder-logstream-kube/coder-logstream-kube \
2424
--set url=<your-coder-url-including-http-or-https>
2525
```
2626

27+
> **Multi-Namespace support**
28+
>
29+
> By default, coder-logstream-kube will watch all namespaces in the cluster. To limit which namespaces are monitored, you can specify them in the [values.yaml](helm/values.yaml) file:
30+
>
31+
> ```yaml
32+
> # Watch specific namespaces only
33+
> namespaces: ["default", "kube-system"]
34+
>
35+
> # Watch all namespaces (default)
36+
> namespaces: []
37+
> ```
38+
>
39+
> When `namespaces` is empty or not specified, the service will monitor all namespaces in the cluster.
40+
2741
> **Note**
2842
> For additional customization (such as customizing the image, pull secrets, annotations, etc.), you can use the
2943
> [values.yaml](helm/values.yaml) file directly.
@@ -50,3 +64,42 @@ Kubernetes provides an [informers](https://pkg.go.dev/k8s.io/client-go/informers
5064
5165
- [`SSL_CERT_FILE`](https://go.dev/src/crypto/x509/root_unix.go#L19): Specifies the path to an SSL certificate.
5266
- [`SSL_CERT_DIR`](https://go.dev/src/crypto/x509/root_unix.go#L25): Identifies which directory to check for SSL certificate files.
67+
68+
## Development
69+
70+
### Running Tests
71+
72+
Unit tests can be run with:
73+
74+
```console
75+
go test ./... -race
76+
```
77+
78+
### Integration Tests
79+
80+
Integration tests run against a real Kubernetes cluster using [KinD (Kubernetes in Docker)](https://kind.sigs.k8s.io/).
81+
82+
**Prerequisites:**
83+
- [Docker](https://docs.docker.com/get-docker/)
84+
- [KinD](https://kind.sigs.k8s.io/docs/user/quick-start/#installation)
85+
- [kubectl](https://kubernetes.io/docs/tasks/tools/)
86+
87+
**Setup and run:**
88+
89+
```console
90+
# Create a KinD cluster
91+
./scripts/kind-setup.sh create
92+
93+
# Run integration tests
94+
go test -tags=integration -v ./...
95+
96+
# Clean up when done
97+
./scripts/kind-setup.sh delete
98+
```
99+
100+
The integration tests validate:
101+
- Pod event streaming with real Kubernetes informers
102+
- ReplicaSet event handling
103+
- Multi-namespace support
104+
- Label selector filtering
105+

0 commit comments

Comments
 (0)