Skip to content

Commit 172eb9a

Browse files
committed
feat: Add initial plugin version
1 parent e25a759 commit 172eb9a

36 files changed

Lines changed: 1675 additions & 1 deletion

.github/workflows/ci.yml

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
lint:
11+
name: Lint
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Install shellcheck
18+
run: sudo apt-get update && sudo apt-get install -y shellcheck
19+
20+
- name: Run shellcheck
21+
run: shellcheck kubectl-beam
22+
23+
- name: Verify POSIX compliance
24+
run: shellcheck -s sh kubectl-beam
25+
26+
unit-test:
27+
name: Unit Tests
28+
runs-on: ubuntu-latest
29+
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- name: Install bats
34+
run: |
35+
git clone --depth 1 https://github.com/bats-core/bats-core.git /tmp/bats
36+
sudo /tmp/bats/install.sh /usr/local
37+
38+
- name: Run unit tests
39+
run: bats test/kubectl-beam.bats
40+
41+
integration-test:
42+
name: Integration Tests
43+
runs-on: ubuntu-latest
44+
needs: [lint, unit-test]
45+
46+
steps:
47+
- uses: actions/checkout@v4
48+
49+
- name: Read versions from .tool-versions
50+
id: versions
51+
run: |
52+
OTP_VERSION=$(grep erlang .tool-versions | awk '{print $2}')
53+
ELIXIR_VERSION=$(grep elixir .tool-versions | awk '{print $2}' | cut -d'-' -f1)
54+
echo "otp=$OTP_VERSION" >> $GITHUB_OUTPUT
55+
echo "elixir=$ELIXIR_VERSION" >> $GITHUB_OUTPUT
56+
echo "OTP Version: $OTP_VERSION"
57+
echo "Elixir Version: $ELIXIR_VERSION"
58+
59+
- name: Setup BEAM
60+
uses: erlef/setup-beam@v1
61+
with:
62+
otp-version: ${{ steps.versions.outputs.otp }}
63+
elixir-version: ${{ steps.versions.outputs.elixir }}
64+
65+
- name: Verify BEAM installation
66+
run: |
67+
erl -version
68+
elixir --version
69+
70+
- name: Install bats
71+
run: |
72+
git clone --depth 1 https://github.com/bats-core/bats-core.git /tmp/bats
73+
sudo /tmp/bats/install.sh /usr/local
74+
75+
- name: Create kind cluster
76+
uses: helm/kind-action@v1
77+
with:
78+
cluster_name: kubectl-beam-test
79+
wait: 60s
80+
81+
- name: Verify cluster
82+
run: |
83+
kubectl cluster-info
84+
kubectl get nodes
85+
86+
- name: Build Erlang app Docker image
87+
run: |
88+
cd examples/erlang-app
89+
docker build \
90+
--build-arg OTP_VERSION=${{ steps.versions.outputs.otp }} \
91+
--build-arg ALPINE_VERSION=3.20.3 \
92+
-t erlang-app:test .
93+
94+
- name: Build Elixir app Docker image
95+
run: |
96+
cd examples/elixir-app
97+
docker build \
98+
--build-arg ELIXIR_VERSION=${{ steps.versions.outputs.elixir }} \
99+
--build-arg OTP_VERSION=${{ steps.versions.outputs.otp }} \
100+
--build-arg ALPINE_VERSION=3.20.3 \
101+
-t elixir-app:test .
102+
103+
- name: Load images to kind
104+
run: |
105+
kind load docker-image erlang-app:test --name kubectl-beam-test
106+
kind load docker-image elixir-app:test --name kubectl-beam-test
107+
108+
- name: Deploy test pods
109+
run: |
110+
kubectl apply -f examples/k8s/erlang-app-sname.yaml
111+
kubectl apply -f examples/k8s/erlang-app-name.yaml
112+
kubectl apply -f examples/k8s/elixir-app-sname.yaml
113+
kubectl apply -f examples/k8s/elixir-app-name.yaml
114+
115+
- name: Wait for pods to be ready
116+
run: |
117+
kubectl wait --for=condition=ready pod/erlang-app-sname --timeout=120s || (kubectl describe pod erlang-app-sname && kubectl logs erlang-app-sname && exit 1)
118+
kubectl wait --for=condition=ready pod/erlang-app-name --timeout=120s || (kubectl describe pod erlang-app-name && kubectl logs erlang-app-name && exit 1)
119+
kubectl wait --for=condition=ready pod/elixir-app-sname --timeout=120s || (kubectl describe pod elixir-app-sname && kubectl logs elixir-app-sname && exit 1)
120+
kubectl wait --for=condition=ready pod/elixir-app-name --timeout=120s || (kubectl describe pod elixir-app-name && kubectl logs elixir-app-name && exit 1)
121+
122+
- name: Show pod status
123+
run: |
124+
kubectl get pods
125+
kubectl logs erlang-app-sname || true
126+
kubectl logs erlang-app-name || true
127+
kubectl logs elixir-app-sname || true
128+
kubectl logs elixir-app-name || true
129+
130+
- name: Run integration tests
131+
run: bats test/kubectl-beam-integration.bats
132+
133+
- name: Show pod logs on failure
134+
if: failure()
135+
run: |
136+
echo "=== Erlang app (sname) logs ==="
137+
kubectl logs erlang-app-sname || true
138+
echo "=== Erlang app (name) logs ==="
139+
kubectl logs erlang-app-name || true
140+
echo "=== Elixir app (sname) logs ==="
141+
kubectl logs elixir-app-sname || true
142+
echo "=== Elixir app (name) logs ==="
143+
kubectl logs elixir-app-name || true

.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Temporary files
2+
*.tmp
3+
*.swp
4+
*.swo
5+
*~
6+
7+
# macOS
8+
.DS_Store
9+
10+
# Test artifacts
11+
*.scap.gz
12+
13+
# Build artifacts
14+
/bin/
15+
/dist/
16+
17+
# Editor files
18+
.vscode/
19+
.idea/
20+
*.iml
21+
22+
# Erlang crash dumps
23+
*.dump

.tool-versions

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
erlang 27.2
2+
elixir 1.18.1-otp-27

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright [yyyy] [name of copyright owner]
189+
Copyright 2026 Dairon Medina Caro <me@dairon.org>
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

Makefile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
.PHONY: install uninstall test clean help
2+
3+
PREFIX ?= $(HOME)/.local
4+
BINDIR = $(PREFIX)/bin
5+
6+
help:
7+
@echo "kubectl-beam Makefile"
8+
@echo ""
9+
@echo "Targets:"
10+
@echo " install Install kubectl-beam to $(BINDIR)"
11+
@echo " uninstall Remove kubectl-beam from $(BINDIR)"
12+
@echo " test Run test suite (requires bats)"
13+
@echo " clean Remove temporary files"
14+
@echo " help Show this help message"
15+
16+
install:
17+
@echo "Installing kubectl-beam to $(BINDIR)"
18+
@mkdir -p $(BINDIR)
19+
@cp kubectl-beam $(BINDIR)/kubectl-beam
20+
@chmod +x $(BINDIR)/kubectl-beam
21+
@echo "Installation complete. Ensure $(BINDIR) is in your PATH."
22+
@echo "Verify with: kubectl beam --version"
23+
24+
uninstall:
25+
@echo "Removing kubectl-beam from $(BINDIR)"
26+
@rm -f $(BINDIR)/kubectl-beam
27+
@echo "Uninstallation complete"
28+
29+
test:
30+
@if command -v bats >/dev/null 2>&1; then \
31+
bats test/kubectl-beam.bats; \
32+
else \
33+
echo "Error: bats is not installed"; \
34+
echo "Install with: brew install bats-core (macOS) or apt-get install bats (Linux)"; \
35+
exit 1; \
36+
fi
37+
38+
test-integration:
39+
@if command -v bats >/dev/null 2>&1; then \
40+
bats test/kubectl-beam-integration.bats; \
41+
else \
42+
echo "Error: bats is not installed"; \
43+
echo "Install with: brew install bats-core (macOS) or apt-get install bats (Linux)"; \
44+
exit 1; \
45+
fi
46+
47+
test-all: test test-integration
48+
49+
clean:
50+
@echo "Cleaning temporary files"
51+
@find . -name "*.scap.gz" -delete
52+
@echo "Clean complete"

0 commit comments

Comments
 (0)