-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add license, readme, go mod tidy linter, improved logging, systemd wa…
…tchdog, as well as tests and release ci (#1) * Add license, readme, change repo name, and a go mod tidy linter * Fix cert parsing issue, additional logging * Add support for modifying the nginx config and restarting nginx * Add retries * logging remaining time on each cert check * Simplify now that I know that tailscale calls are cached locally * Improve logging and add systemd healthchecks * Add goreleaser pipeline * Add a few tests and a CI pipeline for tests
- Loading branch information
1 parent
e6ba6c1
commit e5c8173
Showing
23 changed files
with
605 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: go mod tidy | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
gomodtidy: | ||
name: tidy | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: stable | ||
- name: go mod tidy | ||
run: go mod tidy | ||
- name: git diff | ||
run: | | ||
git diff --exit-code --quiet | ||
if [ $? -ne 0 ]; then | ||
echo "Please run 'go mod tidy' and commit the changes" | ||
exit 1 | ||
fi |
6 changes: 2 additions & 4 deletions
6
.github/workflows/golangci-lint.yaml → .github/workflows/lint.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
name: golangci-lint | ||
name: lint | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: release | ||
|
||
on: | ||
push: | ||
tags: | ||
- "*" | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: stable | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v6 | ||
with: | ||
distribution: goreleaser | ||
version: "v2.1.0" | ||
args: release --clean | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: test | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
gotest: | ||
name: test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: stable | ||
- name: go test | ||
run: go test -v -race -cover ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.vscode | ||
bin/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json | ||
# vim: set ts=2 sw=2 tw=0 fo=cnqoj | ||
|
||
version: 2 | ||
|
||
before: | ||
hooks: | ||
- go mod tidy | ||
|
||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
goarch: | ||
- arm | ||
goarm: | ||
- 7 | ||
|
||
report_sizes: true | ||
|
||
archives: | ||
- format: tar.gz | ||
name_template: >- | ||
{{ .ProjectName }}_ | ||
{{- title .Os }}_ | ||
{{- if eq .Arch "amd64" }}x86_64 | ||
{{- else if eq .Arch "386" }}i386 | ||
{{- else }}{{ .Arch }}{{ end }} | ||
{{- if .Arm }}v{{ .Arm }}{{ end }} | ||
files: | ||
- LICENSE.md | ||
- README.md | ||
- pikvm-tailscale-cert-renewer.service | ||
|
||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- "^docs:" | ||
- "^test:" | ||
|
||
gomod: | ||
proxy: true | ||
env: | ||
- GOPROXY=https://proxy.golang.org,direct | ||
- GOSUMDB=sum.golang.org | ||
mod: mod | ||
# gobinary: go1.22.5 | ||
|
||
# .goreleaser.yaml | ||
release: | ||
github: | ||
owner: nateinaction | ||
name: pikvm-tailscale-cert-renewer | ||
|
||
# TODO: Remove when comfortable with goreleaser setup | ||
draft: true | ||
|
||
# Will mark the release as not ready for production in case | ||
# there is an indicator for this in the tag e.g. v1.0.0-rc1 | ||
prerelease: auto | ||
|
||
# Header for the release body. | ||
header: | | ||
## PiKVM Tailscale Cert Renewer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Nate Gay | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# PiKVM Tailscale Cert Renewer | ||
|
||
This is a tool to automatically renew tailscale certs for a PiKVM | ||
|
||
This tool assumes you have setup your PiKVM and the [tailscale integration](https://docs.pikvm.org/tailscale/) using the [official docs](https://docs.pikvm.org/). This tool is designed around the following information from the docs: | ||
>If you have a certificate (making a cert falls outside the scope of PiKVM - please reference OpenSSL documentation or use Let's Encrypt), replace keys in /etc/kvmd/nginx/ssl, edit /etc/kvmd/nginx/ssl.conf if necessary and restart kvmd-nginx service. *[PiKVM Common Questions](https://docs.pikvm.org/faq/#common-questions)* | ||
This tool automatically discovers your tailscale domain, creates and renews certs for that domain, sets the cert path in the nginx config, and restarts NGINX. | ||
|
||
``` | ||
[root@pikvm ~]# systemctl edit --force --full pikvm-tailscale-cert-renewer.service | ||
Successfully installed edited file '/etc/systemd/system/pikvm-tailscale-cert-renewer.service'. | ||
[root@pikvm ~]# systemctl enable pikvm-tailscale-cert-re^C | ||
[root@pikvm ~]# mv pikvm-tailscale-cert-renewer /usr/local/bin/ | ||
[root@pikvm ~]# systemctl enable pikvm-tailscale-cert-renewer.service | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.