Skip to content

Commit 045b277

Browse files
committed
✨ init: Initialise flapjak with usual foxygoat start (#1)
Start flapjak with the MIT license, hermit for repo tooling and the common foxygoat Makefile and GitHub CI/CD. This merges the following commits: * init: Add MIT license * init: Hermitise repository * init: Add initial README * init: Bootstrap project .github/workflows/cd.yaml | 30 ++++++++ .github/workflows/ci.yaml | 12 +++ .gitignore | 1 + .golangci.yaml | 44 +++++++++++ LICENSE | 21 ++++++ Makefile | 136 ++++++++++++++++++++++++++++++++++ README.md | 28 +++++++ bin/.gh-2.69.0.pkg | 1 + bin/.go-1.24.6.pkg | 1 + bin/.golangci-lint-1.64.8.pkg | 1 + bin/.make-4.4.pkg | 1 + bin/README.hermit.md | 7 ++ bin/activate-hermit | 21 ++++++ bin/activate-hermit.fish | 24 ++++++ bin/gengodoc.awk | 12 +++ bin/gh | 1 + bin/go | 1 + bin/gofmt | 1 + bin/golangci-lint | 1 + bin/hermit | 43 +++++++++++ bin/hermit.hcl | 4 + bin/make | 1 + go.mod | 5 ++ go.sum | 8 ++ main.go | 33 +++++++++ 25 files changed, 438 insertions(+) Pull-request: #1
2 parents 4ed72cc + 85211ac commit 045b277

25 files changed

+438
-0
lines changed

.github/workflows/cd.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: cd
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
7+
jobs:
8+
ci:
9+
uses: ./.github/workflows/ci.yaml
10+
11+
release:
12+
runs-on: ubuntu-latest
13+
needs: [ ci ]
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
- env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
run: ./bin/make release
21+
22+
howl-on-fail:
23+
runs-on: ubuntu-latest
24+
needs: [ ci, release ]
25+
if: failure()
26+
steps:
27+
- uses: foxygoat/howl@v1
28+
env:
29+
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
30+
SLACK_TEXT: <!here|here>

.github/workflows/ci.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: ci
2+
3+
on:
4+
pull_request:
5+
workflow_call:
6+
7+
jobs:
8+
ci:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- run: ./bin/make ci

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/out/

.golangci.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
issues:
2+
exclude-use-default: false
3+
exclude:
4+
- "^don't use ALL_CAPS"
5+
- "^ST1003: should not use ALL_CAPS"
6+
- "^G304: Potential file inclusion via variable"
7+
exclude-rules:
8+
# Dynamic errors are OK in main (top-level dir). Packages should use sentinels.
9+
- path: "^[^/]*$"
10+
linters:
11+
- err113
12+
13+
linters:
14+
enable-all: true
15+
disable:
16+
- cyclop
17+
- depguard
18+
- exhaustive
19+
- exhaustruct
20+
- forbidigo
21+
- forcetypeassert
22+
- funlen
23+
- gci
24+
- gochecknoglobals
25+
- gocognit
26+
- goconst
27+
- gocyclo
28+
- godox
29+
- ireturn
30+
- lll
31+
- mnd
32+
- nlreturn
33+
- nonamedreturns
34+
- paralleltest
35+
- revive
36+
- rowserrcheck
37+
- sqlclosecheck
38+
- tagalign
39+
- tenv
40+
- testpackage
41+
- varnamelen
42+
- wastedassign
43+
- wrapcheck
44+
- wsl

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 the foxygoat authors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Run `make help` to display help
2+
.DEFAULT_GOAL := help
3+
4+
# --- Global -------------------------------------------------------------------
5+
O = out
6+
COVERAGE = 0
7+
VERSION ?= $(shell git describe --tags --dirty --always)
8+
9+
## Build and lint
10+
all: build lint
11+
@if [ -e .git/rebase-merge ]; then git --no-pager log -1 --pretty='%h %s'; fi
12+
@echo '$(COLOUR_GREEN)Success$(COLOUR_NORMAL)'
13+
14+
## Full clean build and up-to-date checks as run on CI
15+
ci: clean check-uptodate all
16+
17+
# GENERATED_FILES is apended at targets that generate or modify files that are
18+
# required to be up-to-date.
19+
GENERATED_FILES :=
20+
check-uptodate: tidy godoc
21+
test -z "$$(git status --porcelain -- $(GENERATED_FILES))" || { git status; false; }
22+
23+
## Remove generated files
24+
clean::
25+
-rm -rf $(O)
26+
27+
.PHONY: all check-uptodate ci clean
28+
29+
# --- Build --------------------------------------------------------------------
30+
BIN_NAME = flapjak
31+
GO_TAGS =
32+
GO_LDFLAGS = -X main.version=$(VERSION)
33+
GO_FLAGS += $(if $(GO_TAGS),-tags='$(GO_TAGS)')
34+
GO_FLAGS += $(if $(GO_LDFLAGS),-ldflags='$(GO_LDFLAGS)')
35+
GO_BIN_SUFFIX = $(if $(GOOS),_$(GOOS))$(if $(GOARCH),_$(GOARCH))
36+
GO_BIN_NAME = $(BIN_NAME)$(GO_BIN_SUFFIX)
37+
38+
## Build flapjak binary
39+
build: | $(O)
40+
go build -o $(O)/$(GO_BIN_NAME) $(GO_FLAGS) .
41+
42+
GENERATED_FILES += go.mod go.sum
43+
## Tidy go modules with "go mod tidy"
44+
tidy:
45+
go mod tidy
46+
47+
.PHONY: build tidy
48+
49+
# --- Lint ---------------------------------------------------------------------
50+
## Lint go source code
51+
lint:
52+
golangci-lint run
53+
54+
.PHONY: lint
55+
56+
# --- Docs ---------------------------------------------------------------------
57+
58+
GENERATED_FILES += main.go
59+
## Generate Go doc comment for command with usage.
60+
godoc: build
61+
./bin/gengodoc.awk main.go > $(O)/out.go
62+
mv $(O)/out.go main.go
63+
64+
.PHONY: godoc
65+
66+
# --- Release ------------------------------------------------------------------
67+
RELEASE_DIR = $(O)/release
68+
69+
## Tag and release binaries for different OS on GitHub release
70+
release: tag-release .WAIT build-release .WAIT publish-release
71+
72+
tag-release: nexttag
73+
git tag $(RELEASE_TAG)
74+
git push origin $(RELEASE_TAG)
75+
76+
build-release:
77+
$(MAKE) build GOOS=linux GOARCH=amd64 O=$(RELEASE_DIR)
78+
$(MAKE) build GOOS=linux GOARCH=arm64 O=$(RELEASE_DIR)
79+
$(MAKE) build GOOS=darwin GOARCH=amd64 O=$(RELEASE_DIR)
80+
$(MAKE) build GOOS=darwin GOARCH=arm64 O=$(RELEASE_DIR)
81+
82+
publish-release:
83+
gh release create $(RELEASE_TAG) --generate-notes $(RELEASE_DIR)/*
84+
85+
nexttag:
86+
$(if $(RELEASE_TAG),,$(eval RELEASE_TAG := $(shell $(NEXTTAG_CMD))))
87+
88+
.PHONY: build-release nexttag publish-release release tag-release
89+
90+
define NEXTTAG_CMD
91+
{ git tag --list --merged HEAD --sort=-v:refname; echo v0.0.0; }
92+
| grep -E "^v?[0-9]+.[0-9]+.[0-9]+$$"
93+
| head -n1
94+
| awk -F . '{ print $$1 "." $$2 "." $$3 + 1 }'
95+
endef
96+
97+
# --- Utilities ----------------------------------------------------------------
98+
COLOUR_NORMAL = $(shell tput sgr0 2>/dev/null)
99+
COLOUR_RED = $(shell tput setaf 1 2>/dev/null)
100+
COLOUR_GREEN = $(shell tput setaf 2 2>/dev/null)
101+
COLOUR_WHITE = $(shell tput setaf 7 2>/dev/null)
102+
103+
help:
104+
$(eval export HELP_AWK)
105+
@awk "$${HELP_AWK}" $(MAKEFILE_LIST) | sort | column -s "$$(printf \\t)" -t
106+
107+
$(O):
108+
@mkdir -p $@
109+
110+
.PHONY: help
111+
112+
# Awk script to extract and print target descriptions for `make help`.
113+
define HELP_AWK
114+
/^## / { desc = desc substr($$0, 3) }
115+
/^[A-Za-z0-9%_-]+:/ && desc {
116+
sub(/::?$$/, "", $$1)
117+
printf "$(COLOUR_WHITE)%s$(COLOUR_NORMAL)\t%s\n", $$1, desc
118+
desc = ""
119+
}
120+
endef
121+
122+
define nl
123+
124+
125+
endef
126+
ifndef ACTIVE_HERMIT
127+
$(eval $(subst \n,$(nl),$(shell bin/hermit env -r | sed 's/^\(.*\)$$/export \1\\n/')))
128+
endif
129+
130+
# Ensure make version is gnu make 4.4 or higher (for .WAIT target)
131+
ifeq ($(filter shell-export,$(value .FEATURES)),)
132+
$(error Unsupported Make version. \
133+
$(nl)Use GNU Make 4.4 or higher (current: $(MAKE_VERSION)). \
134+
$(nl)Activate 🐚 hermit with `. bin/activate-hermit` and run again \
135+
$(nl)or use `bin/make`)
136+
endif

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# flapjak
2+
3+
Featherweight LDAP server configured with jsonnet and Kubernetes.
4+
5+
I need a little LDAP server. I don't have many records to serve, but some record
6+
types I want to serve are `automountMap` and `automount`. None of the little
7+
LDAP servers I can find serve these records. So I run OpenLDAP in order to serve
8+
these. It is big and complicated and annoying to restore from backup for my
9+
situation.
10+
11+
So, using the [gldap] module for implementing an LDAP server, it seems I should
12+
be able to serve any sort of record I want. I would not want to deploy a
13+
large-scale LDAP server with this repo, but it's not for that.
14+
15+
The "jsonnet" bit is because I add a sprinkling of jsonnet anywhere it makes
16+
sense. All the records I configure will be configured via jsonnet. As there is a
17+
bunch of repeated values in attributes across the records, jsonnet works well to
18+
eliminate that duplication.
19+
20+
I would also like to be able to deploy applications on Kubernetes that need
21+
their own UID/GID for NFS storage. I want to deploy these IDs along with the
22+
applications, so flapjak can also be configured with CRDs.
23+
24+
jsonnet can be considered static config to this application. One day, it may use
25+
a DB to store record and allow them to be updated. Today is not that day. Today
26+
the records will all be specified in jsonnet configs or Kubernetes CRDs.
27+
28+
[gldap]: https://github.com/jimlambrt/gldap

bin/.gh-2.69.0.pkg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hermit

bin/.go-1.24.6.pkg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hermit

bin/.golangci-lint-1.64.8.pkg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hermit

0 commit comments

Comments
 (0)