Skip to content

Commit c579143

Browse files
Initial scaffolding: CLI, wait-for subcommand, retry, logging, safety, Helm chart, CI/CD, docs
- Go CLI with cobra: root command + wait-for subcommand - wait-for: TCP/HTTP/HTTPS endpoint checking with retries, backoff, jitter - internal/retry: configurable retry logic with exponential backoff - internal/logging: structured text/JSON logging with secret redaction - internal/safety: path traversal prevention for file writes - Dockerfile: multi-arch scratch-based build, non-root UID 65534 - Helm chart: security-hardened initContainer injection templates - GitHub Actions: CI (lint/test/build/helm-lint) and release workflows - 28 unit tests across all packages - Examples: nginx-waitfor, postgres-migrate-seed, config-render - Docs: README with FAQ, usage guide, security threat model, design doc
0 parents  commit c579143

32 files changed

Lines changed: 2328 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-go@v5
18+
with:
19+
go-version: "1.25"
20+
- uses: golangci/golangci-lint-action@v6
21+
with:
22+
version: latest
23+
24+
test:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
- uses: actions/setup-go@v5
29+
with:
30+
go-version: "1.25"
31+
- run: go test ./... -count=1 -timeout 60s -race -coverprofile=coverage.out
32+
- uses: actions/upload-artifact@v4
33+
with:
34+
name: coverage
35+
path: coverage.out
36+
37+
build:
38+
runs-on: ubuntu-latest
39+
needs: [lint, test]
40+
steps:
41+
- uses: actions/checkout@v4
42+
- uses: actions/setup-go@v5
43+
with:
44+
go-version: "1.25"
45+
- run: make build
46+
- uses: actions/upload-artifact@v4
47+
with:
48+
name: initium-binary
49+
path: bin/initium
50+
51+
helm-lint:
52+
runs-on: ubuntu-latest
53+
steps:
54+
- uses: actions/checkout@v4
55+
- uses: azure/setup-helm@v4
56+
- run: helm lint charts/initium
57+
- run: helm template test-release charts/initium --set sampleDeployment.enabled=true --set 'initContainers[0].name=wait' --set 'initContainers[0].command[0]=wait-for' --set 'initContainers[0].args[0]=--target' --set 'initContainers[0].args[1]=tcp://localhost:5432'
58+

.github/workflows/release.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: read
10+
packages: write
11+
id-token: write
12+
13+
jobs:
14+
release:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: actions/setup-go@v5
20+
with:
21+
go-version: "1.25"
22+
23+
- run: go test ./... -count=1 -timeout 60s -race
24+
25+
- uses: docker/setup-qemu-action@v3
26+
- uses: docker/setup-buildx-action@v3
27+
28+
- uses: docker/login-action@v3
29+
with:
30+
registry: ghcr.io
31+
username: ${{ github.actor }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
33+
34+
- name: Extract version
35+
id: version
36+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
37+
38+
- uses: docker/build-push-action@v6
39+
with:
40+
context: .
41+
platforms: linux/amd64,linux/arm64
42+
push: true
43+
build-args: |
44+
VERSION=${{ steps.version.outputs.VERSION }}
45+
tags: |
46+
ghcr.io/kitstream/initium:${{ steps.version.outputs.VERSION }}
47+
ghcr.io/kitstream/initium:latest
48+
sbom: true
49+
provenance: true
50+

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# IDE
2+
.idea/
3+
*.iml
4+
# Go
5+
bin/
6+
*.exe
7+
*.dll
8+
*.so
9+
*.dylib
10+
# Test
11+
*.test
12+
*.out
13+
coverage.out
14+
# OS
15+
.DS_Store
16+
Thumbs.db

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
- Project scaffolding with Go module, CLI framework (cobra), and repo layout
12+
- `wait-for` subcommand: wait for TCP and HTTP(S) endpoints with retries, exponential backoff, and jitter
13+
- `internal/retry` package with configurable retry logic, backoff, and jitter
14+
- `internal/logging` package with text and JSON structured logging, automatic secret redaction
15+
- `internal/safety` package with path traversal prevention for file writes
16+
- Dockerfile for multi-arch scratch-based builds (runs as non-root UID 65534)
17+
- Makefile with build, test, lint, and Docker targets
18+
- Helm chart skeleton with security-hardened initContainer templates
19+
- GitHub Actions CI workflow (lint, test, build) and release workflow (container build/push with SBOM)
20+
- Unit tests for retry logic, logging, safety path validation, and wait-for subcommand
21+
- Examples for nginx-waitfor, postgres-migrate-seed, and config-render use cases
22+
- Documentation: README, usage guide, security threat model, and architecture/design docs
23+
- SECURITY.md with vulnerability reporting instructions
24+
- Apache 2.0 LICENSE
25+
26+
### Security
27+
- All file operations constrained to --workdir with path traversal prevention
28+
- Automatic redaction of sensitive keys (token, password, secret, etc.) in logs
29+
- Container runs as non-root with read-only root filesystem and all capabilities dropped
30+

Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM --platform=$BUILDPLATFORM golang:1.25-alpine AS builder
2+
3+
ARG TARGETOS TARGETARCH
4+
ARG VERSION=dev
5+
6+
WORKDIR /src
7+
COPY go.mod go.sum ./
8+
RUN go mod download
9+
10+
COPY . .
11+
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
12+
go build -trimpath -ldflags="-s -w -X main.version=${VERSION}" \
13+
-o /initium ./cmd/initium
14+
15+
FROM scratch
16+
17+
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
18+
COPY --from=builder /initium /initium
19+
20+
USER 65534:65534
21+
22+
ENTRYPOINT ["/initium"]
23+

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Apache License
2+
Version 2.0, January 2004
3+
http://www.apache.org/licenses/
4+
5+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6+
7+
Copyright 2025 Kitstream Contributors
8+
9+
Licensed under the Apache License, Version 2.0 (the "License");
10+
you may not use this file except in compliance with the License.
11+
You may obtain a copy of the License at
12+
13+
http://www.apache.org/licenses/LICENSE-2.0
14+
15+
Unless required by applicable law or agreed to in writing, software
16+
distributed under the License is distributed on an "AS IS" BASIS,
17+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
See the License for the specific language governing permissions and
19+
limitations under the License.
20+

Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
BINARY := initium
2+
MODULE := github.com/kitstream/initium
3+
VERSION ?= dev
4+
LDFLAGS := -s -w -X main.version=$(VERSION)
5+
6+
.PHONY: all build test lint clean
7+
8+
all: lint test build
9+
10+
build:
11+
CGO_ENABLED=0 go build -trimpath -ldflags="$(LDFLAGS)" -o bin/$(BINARY) ./cmd/initium
12+
13+
test:
14+
go test ./... -count=1 -timeout 60s -race
15+
16+
lint:
17+
@command -v golangci-lint >/dev/null 2>&1 || { echo "golangci-lint not installed, skipping lint"; exit 0; }
18+
golangci-lint run ./...
19+
20+
clean:
21+
rm -rf bin/
22+
23+
docker-build:
24+
docker buildx build --platform linux/amd64,linux/arm64 \
25+
--build-arg VERSION=$(VERSION) \
26+
-t ghcr.io/kitstream/initium:$(VERSION) .
27+
28+
docker-push:
29+
docker buildx build --platform linux/amd64,linux/arm64 \
30+
--build-arg VERSION=$(VERSION) \
31+
-t ghcr.io/kitstream/initium:$(VERSION) --push .
32+

0 commit comments

Comments
 (0)